-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.3.0
-
sparc
-
solaris_7
Name: laC46010 Date: 09/01/99
New javac (jdk1.3beta) incorrectly reports that a blank final variable might already
have been assigned. The test below conforms to "Blank finals and final local variables"
section of Inner Classes Specification that says:
"The definite assignment rules are extended to record variables
which are "definitely unassigned," and an assignment to a blank
final is prohibited unless the final is definitely unassigned
before the assignment statement. Subsequently, it is definitely
assigned, and, being a final, it cannot be re-assigned along
the same execution path."
The definite unassignment rules are not precisely discussed in specification,
but assignment in the first if-statement is never reached, so variable 'b'
is definitely unassigned when the second assignment arises.
Oldjavac compiles this test successfully.
See reduced JCK test source and logs below:
---------------------------------------------------------------dasg00209.java
public class dasg00209 {
public static void main(String args[]) {
final boolean b;
if (false && (b = false)) ;
if (true && (b = false)) ;
}
}
-----------------------------------------------------------------------------
Results of compilation:
$ java -version
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O-release, 1.3beta-O-release, interpreted mode)
$ javac -d . dasg00209.java
dasg00209.java:5: variable b might already have been assigned to
if (true && (b = false)) ;
^
1 error
$
$ oldjavac -d . dasg00209.java
$ echo $?
0
$
-----------------------------------------------------------------------------
======================================================================