java.lang.reflect.InvocationTargetException
时间: 2023-10-27 22:52:24 浏览: 107
`java.lang.reflect.InvocationTargetException` is a checked exception that occurs when a method is invoked and an exception is thrown by the invoked method. It is a subclass of `java.lang.Exception` and is thrown by the `java.lang.reflect.Method.invoke()` method.
The `InvocationTargetException` wraps the original exception that was thrown by the invoked method. This exception can be accessed using the `getCause()` method. The `InvocationTargetException` can occur for various reasons, including:
- The invoked method throws a checked exception that is not declared in the method signature.
- The invoked method throws an unchecked exception.
- The invoked method throws an error.
In general, the `InvocationTargetException` is a wrapper exception that provides information about the original exception that was thrown by the invoked method. It is commonly used in reflective code, where methods are invoked dynamically at runtime.
阅读全文
相关推荐













