Bug 47082 - [Compiler] Problem with final variable initialization
Summary: [Compiler] Problem with final variable initialization
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1.3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-20 09:27 EST by David Audel CLA
Modified: 2004-03-01 13:36 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Audel CLA 2003-11-20 09:27:58 EST
1) create the following class X.java
public class X {
  void foo1() {
    final int x;
    int i = 0
    for(;;) {
      x = i; // error
    }
  }
  void foo2() {
    final int x;
    int i = 0;
    while(true){
      x = i; // no error
      continue;
    }
  }
  void foo3() {
    final int x;
    int i = 0;
    while(true){
      x = i; // error
      //continue;
    }
  }
  void foo4() {
    final int x;
    int i = 0;
    do {
      x = i; // error
      continue;
    } while (true);
  }
}
2) compile.
foo1, foo3 and foo3 contain an error "The final variable x may already have 
been assigned"
Compiler should report an error in foo2.

Note: see bug 45433
Comment 1 Philipe Mulet CLA 2003-11-23 07:19:29 EST
Solved, while statement was missing merge of continue branch before diagnosing 
assignment in loops.
Comment 2 Philipe Mulet CLA 2003-11-25 07:00:09 EST
Backported to 2.1.x stream
Comment 3 David Audel CLA 2003-12-17 10:46:24 EST
Verified for 3.0M6
Comment 4 Frederic Fusier CLA 2004-03-01 13:36:33 EST
Verified for 2.1.3 with build M200402251535.