system.reflection - understanding Invocation Target Exception wrapping in Java -


m method , want invoke on specific instance through reflection. following code show how did invokation:

try {     m.invoke(classinstance);                 } catch (oopassertionerror e) {  } catch (exception e) {     system.out(e.getcause().getclass().getname()); } 

now instance suppose throw following class when invoke specific method tried invoke earlier, m in previous code:

public class oopassertionerror extends assertionerror { } 

i thought program catch oopassertionerror catch exception instead . , prints following line : "package.oopassertionerror".

why happening ?

invocationtargetexception wraps method's exceptions, written in javadoc.

see what cause java.lang.reflect.invocationtargetexception? more details.

good luck in reflections! ;)


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -