invtarexctest.java
来自「kaffe Java 解释器语言,源码,Java的子集系统,开放源代码」· Java 代码 · 共 32 行
JAVA
32 行
import java.lang.reflect.*;public class InvTarExcTest{ public static void f() throws Exception { throw new Exception("throwing inner exception"); } public static void main(String av[]) { try { Class c = Class.forName("InvTarExcTest"); Method m = c.getMethod("f", new Class[0]); m.invoke(null, null); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); System.out.println("Caught itexception: " + e.getMessage()); // e.printStackTrace(System.out); System.out.println("Target is: " + t.getMessage()); // t.printStackTrace(System.out); } catch (Throwable t) { System.out.println("Caught throwable: " + t); t.printStackTrace(System.out); System.out.println("This should not happen."); } }}/* Expected Output:Caught itexception: nullTarget is: throwing inner exception*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?