--- old/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java 2020-04-06 16:20:02.347005001 -0700 +++ new/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java 2020-04-06 16:20:02.091005001 -0700 @@ -38,8 +38,25 @@ import sun.reflect.annotation.AnnotationType; /** - * Represents an annotated element of the program currently running in this - * VM. This interface allows annotations to be read reflectively. All + * Represents an annotated construct of the program currently running in this + * VM. + * + * A construct is either an element or a type. Annotations on an + * element are on a declaration, whereas annotations on a + * type are on a specific use of a type name. + * + * As defined by The Java™ Language Specification + * section {@jls 9.7.4}, an annotation on an element is a + * declaration annotation and an annotation on a type is a + * type annotation. + * + * Note that any annotations returned by methods on the {@link + * AnnotatedType AnnotatedType} interface and its subinterfaces are + * type annotations as the entity being potentially annotated is a + * type. Annotations returned by methods outside of the {@code + * AnnotatedType} hierarchy are declaration annotations. + * + *
This interface allows annotations to be read reflectively. All * annotations returned by methods in this interface are immutable and * serializable. The arrays returned by methods of this interface may be modified * by callers without affecting the arrays returned to other callers. @@ -47,8 +64,8 @@ *
The {@link #getAnnotationsByType(Class)} and {@link * #getDeclaredAnnotationsByType(Class)} methods support multiple * annotations of the same type on an element. If the argument to - * either method is a repeatable annotation type (JLS 9.6), then the - * method will "look through" a container annotation (JLS 9.7), if + * either method is a repeatable annotation type (JLS {@jls 9.6}), then the + * method will "look through" a container annotation (JLS {@jls 9.7}), if * present, and return any annotations inside the container. Container * annotations may be generated at compile-time to wrap multiple * annotations of the argument type. @@ -260,8 +277,8 @@ *
The truth value returned by this method is equivalent to: * {@code getAnnotation(annotationClass) != null} * - *
The body of the default method is specified to be the code - * above. + * @implSpec The body of the default method is specified to be returning the the value of the code + * expression above. * * @param annotationClass the Class object corresponding to the * annotation type @@ -310,7 +327,7 @@ * * The difference between this method and {@link #getAnnotation(Class)} * is that this method detects if its argument is a repeatable - * annotation type (JLS 9.6), and if so, attempts to find one or + * annotation type (JLS {@jls 9.6}), and if so, attempts to find one or * more annotations of that type by "looking through" a container * annotation. * @@ -406,7 +423,7 @@ * * The difference between this method and {@link * #getDeclaredAnnotation(Class)} is that this method detects if its - * argument is a repeatable annotation type (JLS 9.6), and if so, + * argument is a repeatable annotation type (JLS {@jls 9.6}), and if so, * attempts to find one or more annotations of that type by "looking * through" a container annotation if one is present. * --- old/src/java.base/share/classes/java/lang/reflect/AnnotatedType.java 2020-04-06 16:20:02.851005001 -0700 +++ new/src/java.base/share/classes/java/lang/reflect/AnnotatedType.java 2020-04-06 16:20:02.591005001 -0700 @@ -25,12 +25,18 @@ package java.lang.reflect; +import java.lang.annotation.Annotation; + /** * {@code AnnotatedType} represents the potentially annotated use of a type in * the program currently running in this VM. The use may be of any type in the * Java programming language, including an array type, a parameterized type, a * type variable, or a wildcard type. * + * Note that any annotations returned by methods on this + * interface are type annotations (JLS {@jls 9.7.4}) as the + * entity being potentially annotated is a type. + * * @since 1.8 */ public interface AnnotatedType extends AnnotatedElement { @@ -72,4 +78,30 @@ * @return the type this annotated type represents */ public Type getType(); + + /** + * {@inheritDoc} + *
Note that any annotation returned by this method is a type
+ * annotation.
+ *
+ * @throws NullPointerException {@inheritDoc}
+ */
+ @Override
+ Note that any annotations returned by this method are type
+ * annotations.
+ */
+ @Override
+ Annotation[] getAnnotations();
+
+ /**
+ * {@inheritDoc}
+ * Note that any annotations returned by this method are type
+ * annotations.
+ */
+ @Override
+ Annotation[] getDeclaredAnnotations();
}
--- old/src/java.base/share/classes/java/lang/Class.java 2020-04-06 16:20:03.555005001 -0700
+++ new/src/java.base/share/classes/java/lang/Class.java 2020-04-06 16:20:03.291005001 -0700
@@ -3779,9 +3779,14 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotation returned by this method is a
+ * declaration annotation.
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
+ @Override
@SuppressWarnings("unchecked")
public A getAnnotation(Class annotationClass) {
Objects.requireNonNull(annotationClass);
@@ -3800,6 +3805,10 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@@ -3814,13 +3823,22 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @since 1.5
*/
+ @Override
public Annotation[] getAnnotations() {
return AnnotationParser.toArray(annotationData().annotations);
}
/**
+ * {@inheritDoc}
+ * Note that any annotation returned by this method is a
+ * declaration annotation.
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@@ -3833,6 +3851,10 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@@ -3845,8 +3867,13 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @since 1.5
*/
+ @Override
public Annotation[] getDeclaredAnnotations() {
return AnnotationParser.toArray(annotationData().declaredAnnotations);
}
--- old/src/java.base/share/classes/java/lang/Module.java 2020-04-06 16:20:04.627005001 -0700
+++ new/src/java.base/share/classes/java/lang/Module.java 2020-04-06 16:20:04.055005001 -0700
@@ -1381,6 +1381,8 @@
/**
* {@inheritDoc}
* This method returns {@code null} when invoked on an unnamed module.
+ * Note that any annotation returned by this method is a
+ * declaration annotation.
*/
@Override
public Note that any annotations returned by this method are
+ * declaration annotations.
* This method returns an empty array when invoked on an unnamed module.
*/
@Override
@@ -1398,6 +1402,8 @@
/**
* {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
* This method returns an empty array when invoked on an unnamed module.
*/
@Override
--- old/src/java.base/share/classes/java/lang/Package.java 2020-04-06 16:20:05.183005001 -0700
+++ new/src/java.base/share/classes/java/lang/Package.java 2020-04-06 16:20:04.927005001 -0700
@@ -434,9 +434,14 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotation returned by this method is a
+ * declaration annotation.
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
+ @Override
public A getAnnotation(Class annotationClass) {
return getPackageInfo().getAnnotation(annotationClass);
}
@@ -452,6 +457,10 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@@ -461,13 +470,21 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
* @since 1.5
*/
+ @Override
public Annotation[] getAnnotations() {
return getPackageInfo().getAnnotations();
}
/**
+ * {@inheritDoc}
+ * Note that any annotation returned by this method is a
+ * declaration annotation.
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@@ -486,8 +503,12 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
* @since 1.5
*/
+ @Override
public Annotation[] getDeclaredAnnotations() {
return getPackageInfo().getDeclaredAnnotations();
}
--- old/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java 2020-04-06 16:20:05.711005001 -0700
+++ new/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java 2020-04-06 16:20:05.455005001 -0700
@@ -509,9 +509,14 @@
new ReflectionFactory.GetReflectionFactoryAction());
/**
+ * {@inheritDoc}
+ * Note that any annotation returned by this method is a
+ * declaration annotation.
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
+ @Override
public Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@@ -536,13 +545,22 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @since 1.5
*/
+ @Override
public Annotation[] getAnnotations() {
return getDeclaredAnnotations();
}
/**
+ * {@inheritDoc}
+ * Note that any annotation returned by this method is a
+ * declaration annotation.
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@@ -555,6 +573,10 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@@ -567,8 +589,13 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @since 1.5
*/
+ @Override
public Annotation[] getDeclaredAnnotations() {
throw new AssertionError("All subclasses should override this method");
}
--- old/src/java.base/share/classes/java/lang/reflect/Field.java 2020-04-06 16:20:06.263005001 -0700
+++ new/src/java.base/share/classes/java/lang/reflect/Field.java 2020-04-06 16:20:05.999005001 -0700
@@ -1132,9 +1132,12 @@
}
/**
+ * {@inheritDoc}
+ *
* @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
+ @Override
public Note that any annotation returned by this method is a
+ * declaration annotation.
* @throws NullPointerException {@inheritDoc}
*/
+ @Override
public Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @throws NullPointerException {@inheritDoc}
*/
@Override
@@ -300,14 +309,22 @@
/**
* {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
*/
+ @Override
public Annotation[] getDeclaredAnnotations() {
return executable.getParameterAnnotations()[index];
}
/**
+ * {@inheritDoc}
+ * Note that any annotation returned by this method is a
+ * declaration annotation.
+ *
* @throws NullPointerException {@inheritDoc}
*/
+ @Override
public Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @throws NullPointerException {@inheritDoc}
*/
@Override
@@ -328,7 +349,10 @@
/**
* {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
*/
+ @Override
public Annotation[] getAnnotations() {
return getDeclaredAnnotations();
}
--- old/src/java.base/share/classes/java/lang/reflect/RecordComponent.java 2020-04-06 16:20:07.247005001 -0700
+++ new/src/java.base/share/classes/java/lang/reflect/RecordComponent.java 2020-04-06 16:20:06.999005001 -0700
@@ -180,6 +180,9 @@
}
/**
+ * {@inheritDoc}
+ * Note that any annotation returned by this method is a
+ * declaration annotation.
* @throws NullPointerException {@inheritDoc}
*/
@Override
@@ -215,6 +218,8 @@
/**
* {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
*/
@Override
public Annotation[] getAnnotations() {
@@ -223,6 +228,8 @@
/**
* {@inheritDoc}
+ * Note that any annotations returned by this method are
+ * declaration annotations.
*/
@Override
public Annotation[] getDeclaredAnnotations() { return AnnotationParser.toArray(declaredAnnotations()); }
--- old/src/java.base/share/classes/java/lang/reflect/Executable.java 2020-04-06 16:20:07.955005001 -0700
+++ new/src/java.base/share/classes/java/lang/reflect/Executable.java 2020-04-06 16:20:07.703005001 -0700
@@ -544,6 +544,9 @@
* ("synthetic") to the parameter list for a method. See {@link
* java.lang.reflect.Parameter} for more information.
*
+ * Note that any annotations returned by this method are
+ * declaration annotations.
+ *
* @see java.lang.reflect.Parameter
* @see java.lang.reflect.Parameter#getAnnotations
* @return an array of arrays that represent the annotations on
@@ -577,6 +580,7 @@
* {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
*/
+ @Override
public