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.
Note that 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 {@link java.lang.reflect.Constructor#newInstance(java.lang.Object) Constructor.newInstance} method avoids this problem by wrappingany exception thrown by the constructor in a (checked) {@link java.lang.reflect.InvocationTargetException}.
@return a newly allocated instance of the class represented by thisobject.
@exception IllegalAccessException if the class or its nullary constructor is not accessible.
@exception 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.
@exception ExceptionInInitializerError if the initializationprovoked by this method fails.
@exception SecurityException If a security manager, s, is present and any of the following conditions is met:
- invocation of {@link SecurityManager#checkMemberAccess s.checkMemberAccess(this, Member.PUBLIC)} denies creation of new instances of this class
- the caller's class loader is not the same as or an ancestor of the class loader for the current class and invocation of {@link SecurityManager#checkPackageAccess s.checkPackageAccess()} denies access to the package of this class