Community
Participate
Working Groups
I20080530-1730 On the following code, javac reports an error while Eclipse does not: public class X { public static void main(String args[]) { final int i; for (;true;) { if (true) { break; } else { i = 0; } } i = 1; // javac reports an error here } }
Following JL3 §16, i is definitely unassigned before the second assignment iff it is so after true when false and before the only break that branches to the for statement. I believe that both conditions hold true, giving us right and javac wrong. Closing as INVALID.
Added AssignmentTest#56 and 57.
Agreed that 'i' is definitely unassigned in this case reading the following rule in chapter JLS3 §16.2.12: . V is [un]assigned after a for statement iff both of the following are true: + Either a condition expression is not present or V is [un]assigned after the condition expression when false. + V is [un]assigned before every break statement for which the for statement is the break target.