Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4065952

within a switch statement, blank final variable can be assigned twice

XMLWordPrintable

    • sparc
    • solaris_2.5.1



      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);
      }
      }
      }
      --------------------------------------------------------------------------------

      ======================================================================

            dstoutamsunw David Stoutamire (Inactive)
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: