77 return CoreReflectionFactory.make(this, ConstructorScope.make(this));
78 }
79
80 // Accessor for generic info repository
81 @Override
82 ConstructorRepository getGenericInfo() {
83 // lazily initialize repository if necessary
84 if (genericInfo == null) {
85 // create and cache generic info repository
86 genericInfo =
87 ConstructorRepository.make(getSignature(),
88 getFactory());
89 }
90 return genericInfo; //return cached repository
91 }
92
93 private volatile ConstructorAccessor constructorAccessor;
94 // For sharing of ConstructorAccessors. This branching structure
95 // is currently only two levels deep (i.e., one root Constructor
96 // and potentially many Constructor objects pointing to it.)
97 private Constructor<T> root;
98
99 /**
100 * Package-private constructor used by ReflectAccess to enable
101 * instantiation of these objects in Java code from the java.lang
102 * package via sun.reflect.LangReflectAccess.
103 */
104 Constructor(Class<T> declaringClass,
105 Class<?>[] parameterTypes,
106 Class<?>[] checkedExceptions,
107 int modifiers,
108 int slot,
109 String signature,
110 byte[] annotations,
111 byte[] parameterAnnotations) {
112 this.clazz = declaringClass;
113 this.parameterTypes = parameterTypes;
114 this.exceptionTypes = checkedExceptions;
115 this.modifiers = modifiers;
116 this.slot = slot;
117 this.signature = signature;
118 this.annotations = annotations;
119 this.parameterAnnotations = parameterAnnotations;
120 }
121
122 /**
123 * Package-private routine (exposed to java.lang.Class via
124 * ReflectAccess) which returns a copy of this Constructor. The copy's
125 * "root" field points to this Constructor.
126 */
127 Constructor<T> copy() {
128 // This routine enables sharing of ConstructorAccessor objects
129 // among Constructor objects which refer to the same underlying
130 // method in the VM. (All of this contortion is only necessary
131 // because of the "accessibility" bit in AccessibleObject,
132 // which implicitly requires that new java.lang.reflect
133 // objects be fabricated for each reflective call on Class
134 // objects.)
135 Constructor<T> res = new Constructor<>(clazz,
136 parameterTypes,
137 exceptionTypes, modifiers, slot,
138 signature,
139 annotations,
140 parameterAnnotations);
141 res.root = this;
142 // Might as well eagerly propagate this if already present
143 res.constructorAccessor = constructorAccessor;
144 return res;
145 }
146
147 @Override
148 boolean hasGenericInformation() {
149 return (getSignature() != null);
150 }
151
152 @Override
153 byte[] getAnnotationBytes() {
154 return annotations;
|
77 return CoreReflectionFactory.make(this, ConstructorScope.make(this));
78 }
79
80 // Accessor for generic info repository
81 @Override
82 ConstructorRepository getGenericInfo() {
83 // lazily initialize repository if necessary
84 if (genericInfo == null) {
85 // create and cache generic info repository
86 genericInfo =
87 ConstructorRepository.make(getSignature(),
88 getFactory());
89 }
90 return genericInfo; //return cached repository
91 }
92
93 private volatile ConstructorAccessor constructorAccessor;
94 // For sharing of ConstructorAccessors. This branching structure
95 // is currently only two levels deep (i.e., one root Constructor
96 // and potentially many Constructor objects pointing to it.)
97 //
98 // If this branching structure would ever contain cycles, deadlocks can
99 // occur in annotation code.
100 private Constructor<T> root;
101
102 /**
103 * Used by Excecutable for annotation sharing.
104 */
105 @Override
106 Executable getRoot() {
107 return root;
108 }
109
110 /**
111 * Package-private constructor used by ReflectAccess to enable
112 * instantiation of these objects in Java code from the java.lang
113 * package via sun.reflect.LangReflectAccess.
114 */
115 Constructor(Class<T> declaringClass,
116 Class<?>[] parameterTypes,
117 Class<?>[] checkedExceptions,
118 int modifiers,
119 int slot,
120 String signature,
121 byte[] annotations,
122 byte[] parameterAnnotations) {
123 this.clazz = declaringClass;
124 this.parameterTypes = parameterTypes;
125 this.exceptionTypes = checkedExceptions;
126 this.modifiers = modifiers;
127 this.slot = slot;
128 this.signature = signature;
129 this.annotations = annotations;
130 this.parameterAnnotations = parameterAnnotations;
131 }
132
133 /**
134 * Package-private routine (exposed to java.lang.Class via
135 * ReflectAccess) which returns a copy of this Constructor. The copy's
136 * "root" field points to this Constructor.
137 */
138 Constructor<T> copy() {
139 // This routine enables sharing of ConstructorAccessor objects
140 // among Constructor objects which refer to the same underlying
141 // method in the VM. (All of this contortion is only necessary
142 // because of the "accessibility" bit in AccessibleObject,
143 // which implicitly requires that new java.lang.reflect
144 // objects be fabricated for each reflective call on Class
145 // objects.)
146 if (this.root != null)
147 throw new IllegalArgumentException("Can not copy a non-root Constructor");
148
149 Constructor<T> res = new Constructor<>(clazz,
150 parameterTypes,
151 exceptionTypes, modifiers, slot,
152 signature,
153 annotations,
154 parameterAnnotations);
155 res.root = this;
156 // Might as well eagerly propagate this if already present
157 res.constructorAccessor = constructorAccessor;
158 return res;
159 }
160
161 @Override
162 boolean hasGenericInformation() {
163 return (getSignature() != null);
164 }
165
166 @Override
167 byte[] getAnnotationBytes() {
168 return annotations;
|