Constructor getGenericExceptionTypes() method in Java with Examples
The getGenericExceptionTypes() method of java.lang.reflect.Constructor class is used to return the exception types present on this constructor object as an array. The returned array of objects represent the exceptions declared to be thrown by this constructor object. If this constructor declares no exceptions in its throws clause then this method returns an array of length 0.
public Type getGenericExceptionTypes()
Parameters: This method accepts nothing.
Return: This method returns an array of Types that represent the exception types thrown by the underlying executable.
Exception: This method throws following exceptions:
- GenericSignatureFormatError: if the generic method signature does not conform to the format specified in The Java™ Virtual Machine Specification.
- TypeNotPresentException: if the underlying executable’s throws clause refers to a non-existent type declaration.
- MalformedParameterizedTypeException: if the underlying executable’s throws clause refers to a parameterized type that cannot be instantiated for any reason.
Below programs illustrate getGenericExceptionTypes() method:
GenericExceptions : class java.io.IOException class java.lang.ArithmeticException class java.lang.ClassCastException
No of Generic Exception thrown : 0