--- a/jdk/src/java.base/share/classes/java/lang/reflect/Executable.java Mon Sep 08 20:29:15 2014 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Executable.java Tue Sep 09 10:48:01 2014 +0200
@@ -53,6 +53,11 @@
abstract byte[] getAnnotationBytes();
/**
+ * Accessor method to allow code sharing
+ */
+ abstract Executable getRoot();
+
+ /**
* Does the Executable have generic information.
*/
abstract boolean hasGenericInformation();
@@ -540,11 +545,16 @@
private synchronized Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
if (declaredAnnotations == null) {
- declaredAnnotations = AnnotationParser.parseAnnotations(
- getAnnotationBytes(),
- sun.misc.SharedSecrets.getJavaLangAccess().
- getConstantPool(getDeclaringClass()),
- getDeclaringClass());
+ Executable root = getRoot();
+ if (root != null) {
+ declaredAnnotations = root.declaredAnnotations();
+ } else {
+ declaredAnnotations = AnnotationParser.parseAnnotations(
+ getAnnotationBytes(),
+ sun.misc.SharedSecrets.getJavaLangAccess().
+ getConstantPool(getDeclaringClass()),
+ getDeclaringClass());
+ }
}
return declaredAnnotations;
}