JAVA 反射机制 抛出原异常

    xiaoxiao2026-04-05  8

    自定义异常类: public class CustomException extends Exception{   public CustomException(){}     public CustomException(String message){     super(message);   }     // public CustomException(param ..){...} } main(): try{   try{     Class<?> clazz = Class.forName(className);     Method method = Clazz.getDeclaredMethod(Param);     method.invoke();   }catch(InvocationTargetException ext){     try{       throw ext.getTargetException();     }catch(CustomException cusEx){       throw cusEx;     }catch(Throwable e){       // TODO         }   } }catch(CustomException ex){   // TODO }catch(Exception e){   // TODO }                                                                                     
    转载请注明原文地址: https://ju.6miu.com/read-1308515.html
    最新回复(0)