540 // (the stack depth is wrong for the Constructor's
541 // security check to work)
542 java.security.AccessController.doPrivileged(
543 new java.security.PrivilegedAction<>() {
544 public Void run() {
545 c.setAccessible(true);
546 return null;
547 }
548 });
549 cachedConstructor = c;
550 } catch (NoSuchMethodException e) {
551 throw (InstantiationException)
552 new InstantiationException(getName()).initCause(e);
553 }
554 }
555 Constructor<T> tmpConstructor = cachedConstructor;
556 // Security check (same as in java.lang.reflect.Constructor)
557 Class<?> caller = Reflection.getCallerClass();
558 if (newInstanceCallerCache != caller) {
559 int modifiers = tmpConstructor.getModifiers();
560 Reflection.ensureMemberAccess(caller, this, null, modifiers);
561 newInstanceCallerCache = caller;
562 }
563 // Run constructor
564 try {
565 return tmpConstructor.newInstance((Object[])null);
566 } catch (InvocationTargetException e) {
567 Unsafe.getUnsafe().throwException(e.getTargetException());
568 // Not reached
569 return null;
570 }
571 }
572 private transient volatile Constructor<T> cachedConstructor;
573 private transient volatile Class<?> newInstanceCallerCache;
574
575
576 /**
577 * Determines if the specified {@code Object} is assignment-compatible
578 * with the object represented by this {@code Class}. This method is
579 * the dynamic equivalent of the Java language {@code instanceof}
580 * operator. The method returns {@code true} if the specified
|
540 // (the stack depth is wrong for the Constructor's
541 // security check to work)
542 java.security.AccessController.doPrivileged(
543 new java.security.PrivilegedAction<>() {
544 public Void run() {
545 c.setAccessible(true);
546 return null;
547 }
548 });
549 cachedConstructor = c;
550 } catch (NoSuchMethodException e) {
551 throw (InstantiationException)
552 new InstantiationException(getName()).initCause(e);
553 }
554 }
555 Constructor<T> tmpConstructor = cachedConstructor;
556 // Security check (same as in java.lang.reflect.Constructor)
557 Class<?> caller = Reflection.getCallerClass();
558 if (newInstanceCallerCache != caller) {
559 int modifiers = tmpConstructor.getModifiers();
560 Reflection.ensureMemberAccess(caller, this, this, modifiers);
561 newInstanceCallerCache = caller;
562 }
563 // Run constructor
564 try {
565 return tmpConstructor.newInstance((Object[])null);
566 } catch (InvocationTargetException e) {
567 Unsafe.getUnsafe().throwException(e.getTargetException());
568 // Not reached
569 return null;
570 }
571 }
572 private transient volatile Constructor<T> cachedConstructor;
573 private transient volatile Class<?> newInstanceCallerCache;
574
575
576 /**
577 * Determines if the specified {@code Object} is assignment-compatible
578 * with the object represented by this {@code Class}. This method is
579 * the dynamic equivalent of the Java language {@code instanceof}
580 * operator. The method returns {@code true} if the specified
|