Name: laC46010 Date: 07/21/97
All JDK versions from 1.1_Final thru 1.2C fail to pass
test icls10709, generated from template icls10791.
The test reveals that there's a way for a blank final variable
to be assigned twice within a switch statement. Nevertheless, Inner
Classes In Java 1.1 specification states:
"A blank final is final variable declaration (of any kind)
which lacks an initializer. A blank final must be assigned an
initial value, exactly once, before it is used."
Example "Test.java" (see source code below) shows this failure:
> /export/ld14/java/dest/jdk1.2/solaris/bin/javac -d . Test.java
> /export/ld14/java/dest/jdk1.2/solaris/bin/java -verify Test
i=777
i=153
>
--------------------Test.java----------------------
public class Test {
public static void main(String[] argv) {
final int i;
switch (3) {
case 3:
i = 777;
System.out.println("i="+i);
// no break; fall through!
case 7:
i = 153;
System.out.println("i="+i);
}
}
}
--------------------------------------------------------------------------------
======================================================================
- duplicates
-
JDK-4030396 Definite un-assignment check fails on fall-through from switch case.
- Closed