Community
Participate
Working Groups
When using the compiler without the -g option, only lines and source attributes are generated. This can result in VerifyError. For example, running the following class with a JDK6 VM: java -XX:-FailOverToOldVerifier -Xverify:all X will fail with: Exception in thread "main" java.lang.VerifyError: Stack map does not match the one at exception handler 9 in method X.main([Ljava/lang/String;)V at offset 0 Test case: public class X { public static void main(String[] args) { String errorMessage; try { foo(); errorMessage = "No exception thrown"; } catch (Exception e) { e.printStackTrace(); errorMessage = "Exception thrown"; } System.out.println(errorMessage); } public static void foo() { throw new NullPointerException(); } }
Created attachment 50102 [details] Proposed fix
Created attachment 50105 [details] Proposed fix for 3.2 maintenance branch
Created attachment 50106 [details] Proposed fix for head
Created attachment 50107 [details] Regression tests for 3.2 maintenance branch
Created attachment 50108 [details] Regression tests for head
For performance reason, instead of: if (((this.generateAttributes & ClassFileConstants.ATTR_VARS) == 0) && ((this.generateAttributes & ClassFileConstants.ATTR_STACK_MAP) == 0)) you should write: if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS|ClassFileConstants.ATTR_STACK_MAP)) == 0)
For 3.2maintenance, pls hold on the fix until I ping the rest of PMC (need escalation at this stage).
Other than perf comment 6, the proposed patch looks good to me.
pmc approved fixing it for 3.2.1
Released for 3.2.1. Released for 3.3M2. Regression test added in org.eclipse.jdt.core.tests.compiler.regression.StackMapAttributeTest#test022.
Verified for 3.2.1 using ecj.jar built from M20060915-1045
Verified for 3.3 M2 using build I20060918-0010. I used Eclipse itself, with all optional generation boxes unchecked in the compiler preferences (yields the expected error with 3.2).