62 private int slot;
63 // This is guaranteed to be interned by the VM in the 1.4
64 // reflection implementation
65 private String name;
66 private Class<?> returnType;
67 private Class<?>[] parameterTypes;
68 private Class<?>[] exceptionTypes;
69 private int modifiers;
70 // Generics and annotations support
71 private transient String signature;
72 // generic info repository; lazily initialized
73 private transient MethodRepository genericInfo;
74 private byte[] annotations;
75 private byte[] parameterAnnotations;
76 private byte[] annotationDefault;
77 private volatile MethodAccessor methodAccessor;
78 // For sharing of MethodAccessors. This branching structure is
79 // currently only two levels deep (i.e., one root Method and
80 // potentially many Method objects pointing to it.)
81 private Method root;
82 // This is set by the vm at Method creation
83 private byte[] typeAnnotations;
84
85 // Generics infrastructure
86 private String getGenericSignature() {return signature;}
87
88 // Accessor for factory
89 private GenericsFactory getFactory() {
90 // create scope and factory
91 return CoreReflectionFactory.make(this, MethodScope.make(this));
92 }
93
94 // Accessor for generic info repository
95 @Override
96 MethodRepository getGenericInfo() {
97 // lazily initialize repository if necessary
98 if (genericInfo == null) {
99 // create and cache generic info repository
100 genericInfo = MethodRepository.make(getGenericSignature(),
101 getFactory());
102 }
103 return genericInfo; //return cached repository
134
135 /**
136 * Package-private routine (exposed to java.lang.Class via
137 * ReflectAccess) which returns a copy of this Method. The copy's
138 * "root" field points to this Method.
139 */
140 Method copy() {
141 // This routine enables sharing of MethodAccessor objects
142 // among Method objects which refer to the same underlying
143 // method in the VM. (All of this contortion is only necessary
144 // because of the "accessibility" bit in AccessibleObject,
145 // which implicitly requires that new java.lang.reflect
146 // objects be fabricated for each reflective call on Class
147 // objects.)
148 Method res = new Method(clazz, name, parameterTypes, returnType,
149 exceptionTypes, modifiers, slot, signature,
150 annotations, parameterAnnotations, annotationDefault);
151 res.root = this;
152 // Might as well eagerly propagate this if already present
153 res.methodAccessor = methodAccessor;
154
155 res.typeAnnotations = typeAnnotations;
156 return res;
157 }
158
159 @Override
160 boolean hasGenericInformation() {
161 return (getGenericSignature() != null);
162 }
163
164 @Override
165 byte[] getAnnotationBytes() {
166 return annotations;
167 }
168 @Override
169 byte[] getTypeAnnotationBytes() {
170 return typeAnnotations;
171 }
172
173 /**
174 * {@inheritDoc}
175 */
176 @Override
177 public Class<?> getDeclaringClass() {
178 return clazz;
179 }
180
181 /**
182 * Returns the name of the method represented by this {@code Method}
183 * object, as a {@code String}.
184 */
185 @Override
186 public String getName() {
187 return name;
188 }
189
190 /**
|
62 private int slot;
63 // This is guaranteed to be interned by the VM in the 1.4
64 // reflection implementation
65 private String name;
66 private Class<?> returnType;
67 private Class<?>[] parameterTypes;
68 private Class<?>[] exceptionTypes;
69 private int modifiers;
70 // Generics and annotations support
71 private transient String signature;
72 // generic info repository; lazily initialized
73 private transient MethodRepository genericInfo;
74 private byte[] annotations;
75 private byte[] parameterAnnotations;
76 private byte[] annotationDefault;
77 private volatile MethodAccessor methodAccessor;
78 // For sharing of MethodAccessors. This branching structure is
79 // currently only two levels deep (i.e., one root Method and
80 // potentially many Method objects pointing to it.)
81 private Method root;
82
83 // Generics infrastructure
84 private String getGenericSignature() {return signature;}
85
86 // Accessor for factory
87 private GenericsFactory getFactory() {
88 // create scope and factory
89 return CoreReflectionFactory.make(this, MethodScope.make(this));
90 }
91
92 // Accessor for generic info repository
93 @Override
94 MethodRepository getGenericInfo() {
95 // lazily initialize repository if necessary
96 if (genericInfo == null) {
97 // create and cache generic info repository
98 genericInfo = MethodRepository.make(getGenericSignature(),
99 getFactory());
100 }
101 return genericInfo; //return cached repository
132
133 /**
134 * Package-private routine (exposed to java.lang.Class via
135 * ReflectAccess) which returns a copy of this Method. The copy's
136 * "root" field points to this Method.
137 */
138 Method copy() {
139 // This routine enables sharing of MethodAccessor objects
140 // among Method 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 Method res = new Method(clazz, name, parameterTypes, returnType,
147 exceptionTypes, modifiers, slot, signature,
148 annotations, parameterAnnotations, annotationDefault);
149 res.root = this;
150 // Might as well eagerly propagate this if already present
151 res.methodAccessor = methodAccessor;
152 return res;
153 }
154
155 @Override
156 boolean hasGenericInformation() {
157 return (getGenericSignature() != null);
158 }
159
160 @Override
161 byte[] getAnnotationBytes() {
162 return annotations;
163 }
164 @Override
165 byte[] getTypeAnnotationBytes() {
166 return getTypeAnnotationBytes0();
167 }
168
169 /**
170 * {@inheritDoc}
171 */
172 @Override
173 public Class<?> getDeclaringClass() {
174 return clazz;
175 }
176
177 /**
178 * Returns the name of the method represented by this {@code Method}
179 * object, as a {@code String}.
180 */
181 @Override
182 public String getName() {
183 return name;
184 }
185
186 /**
|