--- a/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java Mon Sep 08 20:29:15 2014 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java Tue Sep 09 10:48:01 2014 +0200
@@ -94,9 +94,20 @@
// For sharing of ConstructorAccessors. This branching structure
// is currently only two levels deep (i.e., one root Constructor
// and potentially many Constructor objects pointing to it.)
+ //
+ // If this branching structure would ever contain cycles, deadlocks can
+ // occur in annotation code.
private Constructor<T> root;
/**
+ * Used by Excecutable for annotation sharing.
+ */
+ @Override
+ Executable getRoot() {
+ return root;
+ }
+
+ /**
* Package-private constructor used by ReflectAccess to enable
* instantiation of these objects in Java code from the java.lang
* package via sun.reflect.LangReflectAccess.
@@ -132,6 +143,9 @@
// which implicitly requires that new java.lang.reflect
// objects be fabricated for each reflective call on Class
// objects.)
+ if (this.root != null)
+ throw new IllegalArgumentException("Can not copy a non-root Constructor");
+
Constructor<T> res = new Constructor<>(clazz,
parameterTypes,
exceptionTypes, modifiers, slot,