Community
Participate
Working Groups
I20080530-1730 On the following test case, javac raises an error while Eclipse does not: public class X { public static void main(String args[]) { final int i; for (; 0 < (i /* javac error here */ = 1); i = i + 1) { break; } } } javac does as we do (no error) for: public class X { public static void main(String args[]) { final int i; for (; 0 < (i = 1);) { break; } } }
My reading of JLS 3 $ 16.2.12 gives us right (note that, interestingly enough, it does not involve the incrementation part in the determination of definite unassignment before the condition part).
Added AssignmentTest#59 and 60.
This is discussed in http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4660984. Current status seems to be that the spec will change at some point in time. The discussion gives compelling reasons to consider it as a compiler bug though. Until javac and the spec align, we'll stick to our current position.
In reply to comment #1) > My reading of JLS 3 $ 16.2.12 gives us right (note that, interestingly enough, > it does not involve the incrementation part in the determination of definite > unassignment before the condition part). > Agreed with this point. Looking at the spec, I find it hard to say precisely how the 'Incrementation Part' influences the determination of definite [un]assignment, typically in this peculiar case... So, in doubt I would say verified for 3.4RC4 and we'll see the result of the discussion on Sun's bug...