Community
Participate
Working Groups
/** * hundretAssignmentsToFinalVariable() * Javac reports: * "variable iCount might be assigned in loop" */ public static void hundretAssignmentsToFinalVariable( final boolean bStop, final String s // ) { final int iCount; for (int i = 0; true; i++) { iCount = i; if (i < 100) { continue; } else { break; } } System.out.println(iCount); } I hope you are not angry bcause of my (not so stupid) joke ath the end of https://bugs.eclipse.org/bugs/show_bug.cgi?id=45357 (I think this bug becmose assigned to: Philippe Mulet
Jikes 1.18 reports: Found 1 semantic error compiling "D:/temp/X.java": 13. iCount = i; ^----^ *** Semantic Error: The blank final variable "iCount" cannot be assigned within the body of a loop that may execute more than once. javac 1.4.2 reports: X.java:13: variable iCount might be assigned in loop iCount = i; ^ 1 error I will attach the test case.
Created attachment 6529 [details] Compile fine using Eclipse compiler. It should report an error
Good find. Flow analysis was checking loop assignment before merging init information from continue branch. Fixed in latest. Regression test added: InitializationTest#test170
Verified.
Backported to 2.1.x stream
Verified for 2.1.3 with build M200402251535.