dimanche 13 décembre 2020

NoSuchMethodException not caught

I am trying to catch the NoSuchMethodException in the following code:

try {
    method = currentClass.getMethod(arg1,arg2);
    break;
} 
catch (NoSuchMethodException e) {
    System.out.println("hi");
}

It's not getting caught. I've tried catch (Throwable e) and catch (Exception e) and catch (NoSuchMethodError e) but none of them worked.

Even though When I run the code the console shows a NoSuchMethodException, but it's not getting caught.





Aucun commentaire:

Enregistrer un commentaire