516 * if this {@code Class} represents an abstract class, 517 * an interface, an array class, a primitive type, or void; 518 * or if the class has no nullary constructor; 519 * or if the instantiation fails for some other reason. 520 * @throws ExceptionInInitializerError if the initialization 521 * provoked by this method fails. 522 * @throws SecurityException 523 * If a security manager, <i>s</i>, is present and 524 * the caller's class loader is not the same as or an 525 * ancestor of the class loader for the current class and 526 * invocation of {@link SecurityManager#checkPackageAccess 527 * s.checkPackageAccess()} denies access to the package 528 * of this class. 529 */ 530 @CallerSensitive 531 @Deprecated(since="9") 532 public T newInstance() 533 throws InstantiationException, IllegalAccessException 534 { 535 if (this.isValue()) { 536 throw new UnsupportedOperationException("newInstance on a value class " 537 + this.getName()); 538 } 539 540 SecurityManager sm = System.getSecurityManager(); 541 if (sm != null) { 542 checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), false); 543 } 544 545 // NOTE: the following code may not be strictly correct under 546 // the current Java memory model. 547 548 // Constructor lookup 549 if (cachedConstructor == null) { 550 if (this == Class.class) { 551 throw new IllegalAccessException( 552 "Can not call newInstance() on the Class for java.lang.Class" 553 ); 554 } 555 try { 556 Class<?>[] empty = {}; 557 final Constructor<T> c = getReflectionFactory().copyConstructor( | 516 * if this {@code Class} represents an abstract class, 517 * an interface, an array class, a primitive type, or void; 518 * or if the class has no nullary constructor; 519 * or if the instantiation fails for some other reason. 520 * @throws ExceptionInInitializerError if the initialization 521 * provoked by this method fails. 522 * @throws SecurityException 523 * If a security manager, <i>s</i>, is present and 524 * the caller's class loader is not the same as or an 525 * ancestor of the class loader for the current class and 526 * invocation of {@link SecurityManager#checkPackageAccess 527 * s.checkPackageAccess()} denies access to the package 528 * of this class. 529 */ 530 @CallerSensitive 531 @Deprecated(since="9") 532 public T newInstance() 533 throws InstantiationException, IllegalAccessException 534 { 535 if (this.isValue()) { 536 throw new IllegalAccessException( 537 "cannot create new instance of value class " + this.getName()); 538 } 539 540 SecurityManager sm = System.getSecurityManager(); 541 if (sm != null) { 542 checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), false); 543 } 544 545 // NOTE: the following code may not be strictly correct under 546 // the current Java memory model. 547 548 // Constructor lookup 549 if (cachedConstructor == null) { 550 if (this == Class.class) { 551 throw new IllegalAccessException( 552 "Can not call newInstance() on the Class for java.lang.Class" 553 ); 554 } 555 try { 556 Class<?>[] empty = {}; 557 final Constructor<T> c = getReflectionFactory().copyConstructor( |