| @@ -117,6 +117,14 @@ public final · 116 unmodified lines |
| 117 | java.lang.reflect.GenericDeclaration, | 117 | java.lang.reflect.GenericDeclaration, |
| 118 | java.lang.reflect.Type, | 118 | java.lang.reflect.Type, |
| 119 | java.lang.reflect.AnnotatedElement { | 119 | java.lang.reflect.AnnotatedElement { |
| | 120 | |
| | 121 | // [Inferno] < |
| | 122 | /** A field that is used by jvm to store internal data */ |
| | 123 | private transient Object classData; |
| | 124 | /** A field that is used by jvm to store internal data */ |
| | 125 | private transient Object arrayName; |
| | 126 | // [Inferno] > |
| | 127 | |
| 120 | private static final int ANNOTATION= 0x00002000; | 128 | private static final int ANNOTATION= 0x00002000; |
| 121 | private static final int ENUM = 0x00004000; | 129 | private static final int ENUM = 0x00004000; |
| 122 | private static final int SYNTHETIC = 0x00001000; | 130 | private static final int SYNTHETIC = 0x00001000; |
| @@ -254,16 +262,19 @@ public final · 131 unmodified lines |
| 254 | ClassLoader loader) | 262 | ClassLoader loader) |
| 255 | throws ClassNotFoundException | 263 | throws ClassNotFoundException |
| 256 | { | 264 | { |
| 257 | if (loader == null) { | 265 | // [Inferno] < |
| 258 | SecurityManager sm = System.getSecurityManager(); | 266 | //if (loader == null) { |
| 259 | if (sm != null) { | 267 | // SecurityManager sm = System.getSecurityManager(); |
| 260 | ClassLoader ccl = ClassLoader.getCallerClassLoader(); | 268 | // if (sm != null) { |
| 261 | if (ccl != null) { | 269 | // ClassLoader ccl = ClassLoader.getCallerClassLoader(); |
| 262 | sm.checkPermission( | 270 | // if (ccl != null) { |
| 263 | SecurityConstants.GET_CLASSLOADER_PERMISSION); | 271 | // sm.checkPermission( |
| 264 | } | 272 | // SecurityConstants.GET_CLASSLOADER_PERMISSION); |
| 265 | } | 273 | // } |
| 266 | } | 274 | // } |
| | 275 | //} |
| | 276 | // [Inferno] = |
| | 277 | // [Inferno] > |
| 267 | return forName0(name, initialize, loader); | 278 | return forName0(name, initialize, loader); |
| 268 | } | 279 | } |
| 269 | | 280 | |
| @@ -328,57 +339,61 @@ public final · 58 unmodified lines |
| 328 | return newInstance0(); | 339 | return newInstance0(); |
| 329 | } | 340 | } |
| 330 | | 341 | |
| 331 | private T newInstance0() | 342 | // [Inferno] < |
| 332 | throws InstantiationException, IllegalAccessException | 343 | //private T newInstance0() |
| 333 | { | 344 | // throws InstantiationException, IllegalAccessException |
| 334 | // NOTE: the following code may not be strictly correct under | 345 | //{ |
| 335 | // the current Java memory model. | 346 | // // NOTE: the following code may not be strictly correct under |
| 336 | | 347 | // // the current Java memory model. |
| 337 | // Constructor lookup | 348 | // |
| 338 | if (cachedConstructor == null) { | 349 | // // Constructor lookup |
| 339 | if (this == Class.class) { | 350 | // if (cachedConstructor == null) { |
| 340 | throw new IllegalAccessException( | 351 | // if (this == Class.class) { |
| 341 | "Can not call newInstance() on the Class for java.lang.Class" | 352 | // throw new IllegalAccessException( |
| 342 | ); | 353 | // "Can not call newInstance() on the Class for java.lang.Class" |
| 343 | } | 354 | // ); |
| 344 | try { | 355 | // } |
| 345 | Class<?>[] empty = {}; | 356 | // try { |
| 346 | final Constructor<T> c = getConstructor0(empty, Member.DECLARED); | 357 | // Class<?>[] empty = {}; |
| 347 | // Disable accessibility checks on the constructor | 358 | // final Constructor<T> c = getConstructor0(empty, Member.DECLARED); |
| 348 | // since we have to do the security check here anyway | 359 | // // Disable accessibility checks on the constructor |
| 349 | // (the stack depth is wrong for the Constructor's | 360 | // // since we have to do the security check here anyway |
| 350 | // security check to work) | 361 | // // (the stack depth is wrong for the Constructor's |
| 351 | java.security.AccessController.doPrivileged( | 362 | // // security check to work) |
| 352 | new java.security.PrivilegedAction<Void>() { | 363 | // java.security.AccessController.doPrivileged( |
| 353 | public Void run() { | 364 | // new java.security.PrivilegedAction<Void>() { |
| 354 | c.setAccessible(true); | 365 | // public Void run() { |
| 355 | return null; | 366 | // c.setAccessible(true); |
| 356 | } | 367 | // return null; |
| 357 | }); | 368 | // } |
| 358 | cachedConstructor = c; | 369 | // }); |
| 359 | } catch (NoSuchMethodException e) { | 370 | // cachedConstructor = c; |
| 360 | throw new InstantiationException(getName()); | 371 | // } catch (NoSuchMethodException e) { |
| 361 | } | 372 | // throw new InstantiationException(getName()); |
| 362 | } | 373 | // } |
| 363 | Constructor<T> tmpConstructor = cachedConstructor; | 374 | // } |
| 364 | // Security check (same as in java.lang.reflect.Constructor) | 375 | // Constructor<T> tmpConstructor = cachedConstructor; |
| 365 | int modifiers = tmpConstructor.getModifiers(); | 376 | // // Security check (same as in java.lang.reflect.Constructor) |
| 366 | if (!Reflection.quickCheckMemberAccess(this, modifiers)) { | 377 | // int modifiers = tmpConstructor.getModifiers(); |
| 367 | Class<?> caller = Reflection.getCallerClass(3); | 378 | // if (!Reflection.quickCheckMemberAccess(this, modifiers)) { |
| 368 | if (newInstanceCallerCache != caller) { | 379 | // Class<?> caller = Reflection.getCallerClass(3); |
| 369 | Reflection.ensureMemberAccess(caller, this, null, modifiers); | 380 | // if (newInstanceCallerCache != caller) { |
| 370 | newInstanceCallerCache = caller; | 381 | // Reflection.ensureMemberAccess(caller, this, null, modifiers); |
| 371 | } | 382 | // newInstanceCallerCache = caller; |
| 372 | } | 383 | // } |
| 373 | // Run constructor | 384 | // } |
| 374 | try { | 385 | // // Run constructor |
| 375 | return tmpConstructor.newInstance((Object[])null); | 386 | // try { |
| 376 | } catch (InvocationTargetException e) { | 387 | // return tmpConstructor.newInstance((Object[])null); |
| 377 | Unsafe.getUnsafe().throwException(e.getTargetException()); | 388 | // } catch (InvocationTargetException e) { |
| 378 | // Not reached | 389 | // Unsafe.getUnsafe().throwException(e.getTargetException()); |
| 379 | return null; | 390 | // // Not reached |
| 380 | } | 391 | // return null; |
| 381 | } | 392 | // } |
| | 393 | //} |
| | 394 | // [Inferno] = |
| | 395 | private native T newInstance0(); |
| | 396 | // [Inferno] > |
| 382 | private volatile transient Constructor<T> cachedConstructor; | 397 | private volatile transient Constructor<T> cachedConstructor; |
| 383 | private volatile transient Class<?> newInstanceCallerCache; | 398 | private volatile transient Class<?> newInstanceCallerCache; |
| 384 | | 399 | |