183 }
184 return UnsafeFieldAccessorFactory.newFieldAccessor(field, override);
185 }
186
187 public MethodAccessor newMethodAccessor(Method method) {
188 checkInitted();
189
190 if (Reflection.isCallerSensitive(method)) {
191 Method altMethod = findMethodForReflection(method);
192 if (altMethod != null) {
193 method = altMethod;
194 }
195 }
196
197 // use the root Method that will not cache caller class
198 Method root = langReflectAccess.getRoot(method);
199 if (root != null) {
200 method = root;
201 }
202
203 if (noInflation && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) {
204 return new MethodAccessorGenerator().
205 generateMethod(method.getDeclaringClass(),
206 method.getName(),
207 method.getParameterTypes(),
208 method.getReturnType(),
209 method.getExceptionTypes(),
210 method.getModifiers());
211 } else {
212 NativeMethodAccessorImpl acc =
213 new NativeMethodAccessorImpl(method);
214 DelegatingMethodAccessorImpl res =
215 new DelegatingMethodAccessorImpl(acc);
216 acc.setParent(res);
217 return res;
218 }
219 }
220
221 public ConstructorAccessor newConstructorAccessor(Constructor<?> c) {
222 checkInitted();
223
227 }
228 if (declaringClass == Class.class) {
229 return new InstantiationExceptionConstructorAccessorImpl
230 ("Can not instantiate java.lang.Class");
231 }
232
233 // use the root Constructor that will not cache caller class
234 Constructor<?> root = langReflectAccess.getRoot(c);
235 if (root != null) {
236 c = root;
237 }
238
239 // Bootstrapping issue: since we use Class.newInstance() in
240 // the ConstructorAccessor generation process, we have to
241 // break the cycle here.
242 if (Reflection.isSubclassOf(declaringClass,
243 ConstructorAccessorImpl.class)) {
244 return new BootstrapConstructorAccessorImpl(c);
245 }
246
247 if (noInflation && !ReflectUtil.isVMAnonymousClass(c.getDeclaringClass())) {
248 return new MethodAccessorGenerator().
249 generateConstructor(c.getDeclaringClass(),
250 c.getParameterTypes(),
251 c.getExceptionTypes(),
252 c.getModifiers());
253 } else {
254 NativeConstructorAccessorImpl acc =
255 new NativeConstructorAccessorImpl(c);
256 DelegatingConstructorAccessorImpl res =
257 new DelegatingConstructorAccessorImpl(acc);
258 acc.setParent(res);
259 return res;
260 }
261 }
262
263 //--------------------------------------------------------------------------
264 //
265 // Routines used by java.lang
266 //
267 //
|
183 }
184 return UnsafeFieldAccessorFactory.newFieldAccessor(field, override);
185 }
186
187 public MethodAccessor newMethodAccessor(Method method) {
188 checkInitted();
189
190 if (Reflection.isCallerSensitive(method)) {
191 Method altMethod = findMethodForReflection(method);
192 if (altMethod != null) {
193 method = altMethod;
194 }
195 }
196
197 // use the root Method that will not cache caller class
198 Method root = langReflectAccess.getRoot(method);
199 if (root != null) {
200 method = root;
201 }
202
203 if (noInflation && !method.getDeclaringClass().isHidden()
204 && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) {
205 return new MethodAccessorGenerator().
206 generateMethod(method.getDeclaringClass(),
207 method.getName(),
208 method.getParameterTypes(),
209 method.getReturnType(),
210 method.getExceptionTypes(),
211 method.getModifiers());
212 } else {
213 NativeMethodAccessorImpl acc =
214 new NativeMethodAccessorImpl(method);
215 DelegatingMethodAccessorImpl res =
216 new DelegatingMethodAccessorImpl(acc);
217 acc.setParent(res);
218 return res;
219 }
220 }
221
222 public ConstructorAccessor newConstructorAccessor(Constructor<?> c) {
223 checkInitted();
224
228 }
229 if (declaringClass == Class.class) {
230 return new InstantiationExceptionConstructorAccessorImpl
231 ("Can not instantiate java.lang.Class");
232 }
233
234 // use the root Constructor that will not cache caller class
235 Constructor<?> root = langReflectAccess.getRoot(c);
236 if (root != null) {
237 c = root;
238 }
239
240 // Bootstrapping issue: since we use Class.newInstance() in
241 // the ConstructorAccessor generation process, we have to
242 // break the cycle here.
243 if (Reflection.isSubclassOf(declaringClass,
244 ConstructorAccessorImpl.class)) {
245 return new BootstrapConstructorAccessorImpl(c);
246 }
247
248 if (noInflation && !c.getDeclaringClass().isHidden()
249 && !ReflectUtil.isVMAnonymousClass(c.getDeclaringClass())) {
250 return new MethodAccessorGenerator().
251 generateConstructor(c.getDeclaringClass(),
252 c.getParameterTypes(),
253 c.getExceptionTypes(),
254 c.getModifiers());
255 } else {
256 NativeConstructorAccessorImpl acc =
257 new NativeConstructorAccessorImpl(c);
258 DelegatingConstructorAccessorImpl res =
259 new DelegatingConstructorAccessorImpl(acc);
260 acc.setParent(res);
261 return res;
262 }
263 }
264
265 //--------------------------------------------------------------------------
266 //
267 // Routines used by java.lang
268 //
269 //
|