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
Post a Comment