I'm using Method.invoke() to call a function in a third party jar. Sometimes I get a java.lang.reflect.InvocationTargetException thrown. How can you figure out what the real exception was from this?
+4
A:
InvocationTargetException.getCause() it uses the normal exception chaining stuff introduced in 1.4
Francis Upton
2009-12-01 00:15:15
There's also getTargetException() but the javadoc indeed suggests to use getCause() that was introduced later.
ewernli
2009-12-01 07:52:00