@CallerSensitive @Deprecated(since="9")
public T newInstance () throws InstantiationException, IllegalAccessException

Deprecated: This method propagates any exception thrown by the nullary constructor, including a checked exception. Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. The java.lang.reflect.Constructor.newInstance(java.lang.Object...) method avoids this problem by wrapping any exception thrown by the constructor in a (checked) java.lang.reflect.InvocationTargetException.

The call


 clazz.newInstance()
 
can be replaced by

 clazz.getDeclaredConstructor().newInstance()
 
The latter sequence of calls is inferred to be able to throw the additional exception types InvocationTargetException and NoSuchMethodException. Both of these exception types are subclasses of ReflectiveOperationException.

Creates a new instance of the class represented by this Class object. The class is instantiated as if by a new expression with an empty argument list. The class is initialized if it has not already been initialized.

Returns:  a newly allocated instance of the class represented by this object.

Exceptions:
IllegalAccessException    if the class or its nullary constructor is not accessible.
InstantiationException     if this Class represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason.
ExceptionInInitializerError    if the initialization provoked by this method fails.
SecurityException     If a security manager, s, is present and the caller's class loader is not the same as or an ancestor of the class loader for the current class and invocation of s.checkPackageAccess() denies access to the package of this class.