Method.invoke 메서드에서 메서드가 호출 될 때 코드에서 예외를 catch 할 수없는 것 같습니다. 방법 자체에서 그것을 어떻게 잡을 수 있습니까?Java : Method.invoke 내에서 작성된 예외를 catch하는 방법은 무엇입니까?
void function() {
try {
// code that throws exception
}
catch(Exception e) {
// it never gets here!! It goes straight to the try catch near the invoke
}
}
try {
return method.invoke(callTarget, args);
}
catch(InvocationTargetException e) {
// exception thrown in code that throws exception get here!
}
고마워요!
일반적으로 말하는 예외는 Exception이라는 이름으로 끝나며 오류는 Error라는 이름으로 끝납니다. 오류와 예외는 같은 것이 아닙니다. –