示例代码: public class TestOmitStackTraceInFastThrow {
public static void main(String[] args) { int counter = 0; while(true) { try { Object obj = null; /* * If we cause the exception every time(= without this "if" statement), the optimization does not happen somehow. * So, cause it conditionally. */ if(counter % 2 == 0) { obj = new Object(); } // Cause NullpointerException obj.getClass(); }catch(NullPointerException e) { e.printStackTrace(); } counter++; } } }