src/share/classes/java/lang/reflect/Executable.java
Print this page
rev 10466 : 8054987: (reflect) Add sharing of annotations between instances of Executable
Reviewed-by: duke
*** 51,60 ****
--- 51,65 ----
* Accessor method to allow code sharing
*/
abstract byte[] getAnnotationBytes();
/**
+ * Accessor method to allow code sharing
+ */
+ abstract Executable getRoot();
+
+ /**
* Does the Executable have generic information.
*/
abstract boolean hasGenericInformation();
abstract ConstructorRepository getGenericInfo();
*** 538,553 ****
--- 543,563 ----
private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
private synchronized Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
if (declaredAnnotations == null) {
+ Executable root = getRoot();
+ if (root != null) {
+ declaredAnnotations = root.declaredAnnotations();
+ } else {
declaredAnnotations = AnnotationParser.parseAnnotations(
getAnnotationBytes(),
sun.misc.SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
getDeclaringClass());
}
+ }
return declaredAnnotations;
}
/**
* Returns an {@code AnnotatedType} object that represents the use of a type to