equal
deleted
inserted
replaced
82 * |
82 * |
83 * <p>An instance of this class can be used as the argument of |
83 * <p>An instance of this class can be used as the argument of |
84 * <code>AccessController.doPrivileged</code>. |
84 * <code>AccessController.doPrivileged</code>. |
85 */ |
85 */ |
86 public static final class GetReflectionFactoryAction |
86 public static final class GetReflectionFactoryAction |
87 implements PrivilegedAction { |
87 implements PrivilegedAction<ReflectionFactory> { |
88 public Object run() { |
88 public ReflectionFactory run() { |
89 return getReflectionFactory(); |
89 return getReflectionFactory(); |
90 } |
90 } |
91 } |
91 } |
92 |
92 |
93 /** |
93 /** |
162 } |
162 } |
163 |
163 |
164 public ConstructorAccessor newConstructorAccessor(Constructor c) { |
164 public ConstructorAccessor newConstructorAccessor(Constructor c) { |
165 checkInitted(); |
165 checkInitted(); |
166 |
166 |
167 Class declaringClass = c.getDeclaringClass(); |
167 Class<?> declaringClass = c.getDeclaringClass(); |
168 if (Modifier.isAbstract(declaringClass.getModifiers())) { |
168 if (Modifier.isAbstract(declaringClass.getModifiers())) { |
169 return new InstantiationExceptionConstructorAccessorImpl(null); |
169 return new InstantiationExceptionConstructorAccessorImpl(null); |
170 } |
170 } |
171 if (declaringClass == Class.class) { |
171 if (declaringClass == Class.class) { |
172 return new InstantiationExceptionConstructorAccessorImpl |
172 return new InstantiationExceptionConstructorAccessorImpl |
202 // |
202 // |
203 // |
203 // |
204 |
204 |
205 /** Creates a new java.lang.reflect.Field. Access checks as per |
205 /** Creates a new java.lang.reflect.Field. Access checks as per |
206 java.lang.reflect.AccessibleObject are not overridden. */ |
206 java.lang.reflect.AccessibleObject are not overridden. */ |
207 public Field newField(Class declaringClass, |
207 public Field newField(Class<?> declaringClass, |
208 String name, |
208 String name, |
209 Class type, |
209 Class<?> type, |
210 int modifiers, |
210 int modifiers, |
211 int slot, |
211 int slot, |
212 String signature, |
212 String signature, |
213 byte[] annotations) |
213 byte[] annotations) |
214 { |
214 { |
221 annotations); |
221 annotations); |
222 } |
222 } |
223 |
223 |
224 /** Creates a new java.lang.reflect.Method. Access checks as per |
224 /** Creates a new java.lang.reflect.Method. Access checks as per |
225 java.lang.reflect.AccessibleObject are not overridden. */ |
225 java.lang.reflect.AccessibleObject are not overridden. */ |
226 public Method newMethod(Class declaringClass, |
226 public Method newMethod(Class<?> declaringClass, |
227 String name, |
227 String name, |
228 Class[] parameterTypes, |
228 Class<?>[] parameterTypes, |
229 Class returnType, |
229 Class<?> returnType, |
230 Class[] checkedExceptions, |
230 Class<?>[] checkedExceptions, |
231 int modifiers, |
231 int modifiers, |
232 int slot, |
232 int slot, |
233 String signature, |
233 String signature, |
234 byte[] annotations, |
234 byte[] annotations, |
235 byte[] parameterAnnotations, |
235 byte[] parameterAnnotations, |
248 annotationDefault); |
248 annotationDefault); |
249 } |
249 } |
250 |
250 |
251 /** Creates a new java.lang.reflect.Constructor. Access checks as |
251 /** Creates a new java.lang.reflect.Constructor. Access checks as |
252 per java.lang.reflect.AccessibleObject are not overridden. */ |
252 per java.lang.reflect.AccessibleObject are not overridden. */ |
253 public Constructor newConstructor(Class declaringClass, |
253 public Constructor newConstructor(Class<?> declaringClass, |
254 Class[] parameterTypes, |
254 Class<?>[] parameterTypes, |
255 Class[] checkedExceptions, |
255 Class<?>[] checkedExceptions, |
256 int modifiers, |
256 int modifiers, |
257 int slot, |
257 int slot, |
258 String signature, |
258 String signature, |
259 byte[] annotations, |
259 byte[] annotations, |
260 byte[] parameterAnnotations) |
260 byte[] parameterAnnotations) |
308 } |
308 } |
309 |
309 |
310 /** Makes a copy of the passed constructor. The returned |
310 /** Makes a copy of the passed constructor. The returned |
311 constructor is a "child" of the passed one; see the comments |
311 constructor is a "child" of the passed one; see the comments |
312 in Constructor.java for details. */ |
312 in Constructor.java for details. */ |
313 public Constructor copyConstructor(Constructor arg) { |
313 public <T> Constructor<T> copyConstructor(Constructor<T> arg) { |
314 return langReflectAccess().copyConstructor(arg); |
314 return langReflectAccess().copyConstructor(arg); |
315 } |
315 } |
316 |
316 |
317 //-------------------------------------------------------------------------- |
317 //-------------------------------------------------------------------------- |
318 // |
318 // |
319 // Routines used by serialization |
319 // Routines used by serialization |
320 // |
320 // |
321 // |
321 // |
322 |
322 |
323 public Constructor newConstructorForSerialization |
323 public Constructor newConstructorForSerialization |
324 (Class classToInstantiate, Constructor constructorToCall) |
324 (Class<?> classToInstantiate, Constructor constructorToCall) |
325 { |
325 { |
326 // Fast path |
326 // Fast path |
327 if (constructorToCall.getDeclaringClass() == classToInstantiate) { |
327 if (constructorToCall.getDeclaringClass() == classToInstantiate) { |
328 return constructorToCall; |
328 return constructorToCall; |
329 } |
329 } |
364 static initializer (more properly, that for |
364 static initializer (more properly, that for |
365 java.lang.reflect.AccessibleObject) causes this class's to be |
365 java.lang.reflect.AccessibleObject) causes this class's to be |
366 run, before the system properties are set up. */ |
366 run, before the system properties are set up. */ |
367 private static void checkInitted() { |
367 private static void checkInitted() { |
368 if (initted) return; |
368 if (initted) return; |
369 AccessController.doPrivileged(new PrivilegedAction() { |
369 AccessController.doPrivileged( |
370 public Object run() { |
370 new PrivilegedAction<Void>() { |
|
371 public Void run() { |
371 // Tests to ensure the system properties table is fully |
372 // Tests to ensure the system properties table is fully |
372 // initialized. This is needed because reflection code is |
373 // initialized. This is needed because reflection code is |
373 // called very early in the initialization process (before |
374 // called very early in the initialization process (before |
374 // command-line arguments have been parsed and therefore |
375 // command-line arguments have been parsed and therefore |
375 // these user-settable properties installed.) We assume that |
376 // these user-settable properties installed.) We assume that |