vendredi 14 septembre 2018

Java reflection nullpointerexception not being caught

I am using java reflection to invoke as such:

try {
    method.invoke(someObject);
  } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NullPointerException e) {
    //Do something
  }

someObject is not null, but within the method call it makes a call to something that results in a nullpointerexception.

However, the code still errors out with a null pointer exception with the stack trace pointing back that it was called by "method.invoke(someObject);".

Why doesn't the catch work? Is it something to do with reflection?





Aucun commentaire:

Enregistrer un commentaire