-
Bug
-
Resolution: Fixed
-
P3
-
6u45
-
b01
-
windows_xp
-
Verified
FULL PRODUCT VERSION :
javac -version
javac 1.6.0_25
java -version
java version " 1.7.0 "
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
ver - 5.1.2600 Service Pack 2 Build 2600
ver- 6.1.7601 Service Pack 1 Build 7601
A DESCRIPTION OF THE PROBLEM :
If a blank final class variable in a class is not initialized and the constructor of that class is not allowed to complete by making it to throw an Exception, before it could be completed, the program compiles successfully.
Although, it is mentioned in JLS (JLS8.3.1.2) that :
It is a compile-time error if a blank final class variable is not definitely assigned by a static initializer of the class in which it is declared.
REGRESSION. Last worked in version 6u45
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Declare a blank final static field in a class.
2. Make the constructor of that class to throw an Exception.
3. Compile the class file on command prompt .
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation should be unsuccessful. It should show an error : variable i might not have been initialized
ACTUAL -
Compilation is successful.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main
{
private final static int i ;
public Main()throws InstantiationException
{
throw new InstantiationException( " Can't instantiate " );
}
}
---------- END SOURCE ----------
SUPPORT :
YES
javac -version
javac 1.6.0_25
java -version
java version " 1.7.0 "
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
ver - 5.1.2600 Service Pack 2 Build 2600
ver- 6.1.7601 Service Pack 1 Build 7601
A DESCRIPTION OF THE PROBLEM :
If a blank final class variable in a class is not initialized and the constructor of that class is not allowed to complete by making it to throw an Exception, before it could be completed, the program compiles successfully.
Although, it is mentioned in JLS (JLS8.3.1.2) that :
It is a compile-time error if a blank final class variable is not definitely assigned by a static initializer of the class in which it is declared.
REGRESSION. Last worked in version 6u45
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Declare a blank final static field in a class.
2. Make the constructor of that class to throw an Exception.
3. Compile the class file on command prompt .
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation should be unsuccessful. It should show an error : variable i might not have been initialized
ACTUAL -
Compilation is successful.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main
{
private final static int i ;
public Main()throws InstantiationException
{
throw new InstantiationException( " Can't instantiate " );
}
}
---------- END SOURCE ----------
SUPPORT :
YES
- relates to
-
JDK-8030214 fix for JDK-8020216 breaks the build
-
- Closed
-
-
JDK-8030218 javac, compile time error isn't shown when final static field is not assigned, follow-up
-
- Closed
-