-
Bug
-
Resolution: Fixed
-
P4
-
5.0, 6u24
-
b134
-
x86
-
linux
-
Verified
FULL PRODUCT VERSION :
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 10.10
A DESCRIPTION OF THE PROBLEM :
Given example doesn't compile. Funnily, all parts of code are essential.
Minor changes allow it to compile:
1. Compiles if inner class is removed
2. Compiles if 'final' is removed from any single field of inner class
3. Compiles if any single field of inner class is removed
4. Compiles if any single field of inner class in initialized in field declaration and not in constructor
5. Compiles if inner class is removed completely
6. Compiles if "final" is removed from "item" variable
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile example code
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Code compiles
ACTUAL -
Code doesn't compile
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Main.java:8: variable bug might already have been assigned
bug = 0;
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main {
private static void foo() {
final int bug;
while ("a".equals("b")) {
final int item = 0;
}
bug = 0;
}
private static class Inner {
private final int a;
private final int b;
public Inner() {
this.a = 0;
this.b = 0;
}
}
}
---------- END SOURCE ----------
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 10.10
A DESCRIPTION OF THE PROBLEM :
Given example doesn't compile. Funnily, all parts of code are essential.
Minor changes allow it to compile:
1. Compiles if inner class is removed
2. Compiles if 'final' is removed from any single field of inner class
3. Compiles if any single field of inner class is removed
4. Compiles if any single field of inner class in initialized in field declaration and not in constructor
5. Compiles if inner class is removed completely
6. Compiles if "final" is removed from "item" variable
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile example code
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Code compiles
ACTUAL -
Code doesn't compile
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Main.java:8: variable bug might already have been assigned
bug = 0;
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main {
private static void foo() {
final int bug;
while ("a".equals("b")) {
final int item = 0;
}
bug = 0;
}
private static class Inner {
private final int a;
private final int b;
public Inner() {
this.a = 0;
this.b = 0;
}
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-6328007 final variable incorrectly reported as might been assigned to
- Closed
-
JDK-7040245 Strange final variables initialization errors
- Closed
- relates to
-
JDK-7003744 Compiler error concerning final variables
- Closed