Community
Participate
Working Groups
Using latest code, I got a SANITY CHECK error compiling the following code with debug attributes: public class X { public static void main(String[] args) { switch (args.length) { case 1 : if (true) break; int i = 1; case 0 : i = 2; System.out.print(i); } } } The result should be: 2 Using M3 or 2.0.2 leads to the same problem. So we always had this error, it is not something new. I think I successfully compiled it once, because I didn't generate the debug attributes.
javac 1.4.1 cannot compile this code successfully. It has a VerifyError at runtime. Exception in thread "main" java.lang.VerifyError: (class: X, method: main signature: ([Ljava/lang/String;)V) Accessing value from uninitialized register 0
Jikes 1.18 compiles it fine.
I think adding the local declaration to the list of visible locals before returning because the local is not reachable is ok, because this has no effect on the range of local initializations. It simply adds the local binding to the list of visible locals in the code stream and this is the list used to close the locals at the end of the switch statement. So I won't see the local when it is not initialized in the debugger it I do that.
Indeed, you're right. The variable should be added since it got allocated a position.
Fixed
Verified.