Community
Participate
Working Groups
1) Comment out lines 671-672-673 in org.eclipse.jdt.internal.compiler.ast.TypeDeclaration. 2) Compile this code: [public class X { { if (true) throw new NullPointerException(); } }] 3) You get: public X(); 0 aload_0 [this] 1 invokespecial java.lang.Object() [8] 4 new java.lang.NullPointerException [10] 7 dup 8 invokespecial java.lang.NullPointerException() [12] 11 athrow 12 return The return bytecode is unreachable.
Problem is actually more general than the extra #return instruction. e.g. public class X { { if (true) throw new NullPointerException(); } X() { System.out.println(); } } The #println() statement could also be optimized out.
Need to optimize codegen for statements, but not for explicit constructor call which is always emitted. e.g. class Y { Y(Object o) { System.out.print(o); } } public class X extends Y { { if (true) throw new NullPointerException(); } X() { super(new Object() { public String toString() { return "SUCCESS:"; } }); System.out.println(); } public static void main(String[] args) { try { new X(); } catch(NullPointerException e) { System.out.println("caught:NPE"); } } }
Created attachment 48948 [details] Proposed patch
Released patch for 3.3M2.
Added FlowAnalysisTest#test028-033
Needs to be backported to 3.2.1 in order to fix test case in comment 1.
Fixed. Released for 3.2.1 Released for 3.3 M2 Olivier - pls release a stackmap regression test for test case in comment 1
Added org.eclipse.jdt.core.tests.compiler.regression.StackMapAttributeTest#test021 in HEAD and 3.2 maintenance stream.
Verified for 3.2.1 using build M20060908-1655
Verified for 3.3 M2 using build I20060918-0010.