8224243: Add implSpec's to AccessibleObject and seal Executable
Reviewed-by: alanb
This commit is contained in:
parent
594d454475
commit
0b77359384
src/java.base/share/classes/java/lang/reflect
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -497,6 +497,7 @@ public class AccessibleObject implements AnnotatedElement {
|
||||
/**
|
||||
* Constructor: only used by the Java Virtual Machine.
|
||||
*/
|
||||
@Deprecated(since="17")
|
||||
protected AccessibleObject() {}
|
||||
|
||||
// Indicates whether language-level access checks are overridden
|
||||
@ -520,12 +521,16 @@ public class AccessibleObject implements AnnotatedElement {
|
||||
* <p> Note that any annotation returned by this method is a
|
||||
* declaration annotation.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation throws {@link
|
||||
* UnsupportedOperationException}; subclasses should override this method.
|
||||
*
|
||||
* @throws NullPointerException {@inheritDoc}
|
||||
* @since 1.5
|
||||
*/
|
||||
@Override
|
||||
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
|
||||
throw new AssertionError("All subclasses should override this method");
|
||||
throw new UnsupportedOperationException("All subclasses should override this method");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -545,12 +550,16 @@ public class AccessibleObject implements AnnotatedElement {
|
||||
* <p> Note that any annotations returned by this method are
|
||||
* declaration annotations.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation throws {@link
|
||||
* UnsupportedOperationException}; subclasses should override this method.
|
||||
*
|
||||
* @throws NullPointerException {@inheritDoc}
|
||||
* @since 1.8
|
||||
*/
|
||||
@Override
|
||||
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
|
||||
throw new AssertionError("All subclasses should override this method");
|
||||
throw new UnsupportedOperationException("All subclasses should override this method");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -606,11 +615,15 @@ public class AccessibleObject implements AnnotatedElement {
|
||||
* <p> Note that any annotations returned by this method are
|
||||
* declaration annotations.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation throws {@link
|
||||
* UnsupportedOperationException}; subclasses should override this method.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
@Override
|
||||
public Annotation[] getDeclaredAnnotations() {
|
||||
throw new AssertionError("All subclasses should override this method");
|
||||
throw new UnsupportedOperationException("All subclasses should override this method");
|
||||
}
|
||||
|
||||
// Shared access checking logic.
|
||||
|
@ -47,11 +47,12 @@ import sun.reflect.generics.repository.ConstructorRepository;
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public abstract class Executable extends AccessibleObject
|
||||
implements Member, GenericDeclaration {
|
||||
public abstract sealed class Executable extends AccessibleObject
|
||||
implements Member, GenericDeclaration permits Constructor, Method {
|
||||
/*
|
||||
* Only grant package-visibility to the constructor.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
Executable() {}
|
||||
|
||||
/**
|
||||
|
@ -116,6 +116,7 @@ class Field extends AccessibleObject implements Member {
|
||||
/**
|
||||
* Package-private constructor
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
Field(Class<?> declaringClass,
|
||||
String name,
|
||||
Class<?> type,
|
||||
|
Loading…
x
Reference in New Issue
Block a user