Community
Participate
Working Groups
Build 20020125 When compiling the following test case, the compiler reports an incorrect error revealing an internal bug: package p2; public class X { int field = 0; { int i; int k; } X() { int j = 0; field = 1; if (field == 1) System.out.println("SUCCESS"); } public static void main(String[] arguments) { new X(); } } --- ---------- 1. ERROR in ...\p2\X.java (at line 3) public class X { ^ SANITY CHECK: Invalid attribute for local variable k ----------
This only occurs when asking local variable attributes, and this is due to the fact that the variables <i> and <k> ids are colliding with <j> (ok since in different scopes). However, when exiting the block scope(exitUserScope) for the initializer, unused variables are not removed from the visible variables list. Then later on in the constructor body (since initializers are inlined inside constructors), this interferes with normal visible variables debug attribute generation, since the unused ones have same indexes as legite ones. Fixed by ensuring the visible variables are properly flushed (even if unused).
Backporting it to 1.0 for jck1.3a compliance.