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

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

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta
    • CPU:
      sparc
    • OS:
      solaris_2.5.1
    • Verification:
      Verified

      Description



      Name: laC46010 Date: 07/22/97



      All JDK versions from 1.1_Final thru 1.2C fail to pass
      test icls11608, generated from template icls11691.

      The test reveals that there's a way for a blank final variable
      to be assigned twice within a for 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
      a=1
      a=2
      a=3
      a=4
      >

      Note, that there is very similar (most likely the same) bug
      with ID 4030396, which concerns switch statement.

      --------------------Test.java----------------------
      public class Test {
          public static void main(String[] argv) {
           int k=0;
      for (final int a;;) {
      k++;
      a=k;
      System.out.println("a="+a);
      if (k>3)
      return;
      }
          }
      }
      --------------------------------------------------------------------------------

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

        Attachments

          Activity

            People

            Assignee:
            wmaddoxsunw William Maddox (Inactive)
            Reporter:
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: