Bug 45433

Summary: Bug7 (and counting ;-): hundretAssignmentsToFinalVariable()
Product: [Eclipse Project] JDT Reporter: markusle <mle>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: mle
Version: 3.0   
Target Milestone: 2.1.3   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Compile fine using Eclipse compiler. It should report an error none

Description markusle CLA 2003-10-23 07:39:02 EDT
/**
 * 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
Comment 1 Olivier Thomann CLA 2003-10-23 08:25:00 EDT
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.
Comment 2 Olivier Thomann CLA 2003-10-23 08:25:30 EDT
Created attachment 6529 [details]
Compile fine using Eclipse compiler. It should report an error
Comment 3 Philipe Mulet CLA 2003-10-23 09:25:05 EDT
Good find. Flow analysis was checking loop assignment before merging init 
information from continue branch.

Fixed in latest. Regression test added: InitializationTest#test170
Comment 4 David Audel CLA 2003-11-20 10:39:44 EST
Verified.
Comment 5 Philipe Mulet CLA 2003-11-25 07:00:05 EST
Backported to 2.1.x stream
Comment 6 Frederic Fusier CLA 2004-03-01 13:40:35 EST
Verified for 2.1.3 with build M200402251535.