Class ProxyExceptionHandler
Each of the above classes is defined as a java dynamic proxy (java.lang.reflect.Proxy) and uses its own InvocationHandler to handle proxy logic and then invoke delegate method. However, if delegate method throws an exception, the InvocationHandler receives that exception wrapped in InvocationTargetException which is a checked exception.
Now, the JDK dynamic proxy spec says that: If a checked exception is thrown by this method [...] then an UndeclaredThrowableException [...] will be thrown by the method invocation on the proxy instance. This would not be a correct behaviour of proxy, as proxy needs to be fully transparent. That's why the proxy logic must catch InvoctionTargetException and unwrap it using this helper class.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ProxyExceptionHandler
public ProxyExceptionHandler()
-