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

javac crash on int j = (i)++;

    XMLWordPrintable

Details

    • hopper
    • generic
    • solaris_7
    • Verified

    Description


      You may be interested to note another argument for the Spec Report
      recommendations in 15.8.5 in disallowing parenthesized expressions to
      represent variables (the way it was in the first edition JLS). Try
      compiling this code with Sun's 1.4-beta2 compiler:

      class Foo {
        private int i;
        class Inner {
          Inner() {
            int j = (i)++;
          }
        }
      }

      An exception has occurred in the compiler (1.4.0-beta2). Please file a
      bug at the Java Developer Connection
      (http://java.sun.com/cgi-bin/bugreport.cgi) after checking the Bug
      Parade for duplicates. Include your program and the following diagnostic
      in your report. Thank you.
      java.lang.InternalError: store unsupported:
      com.sun.tools.javac.v8.comp.Items$StackItem@ef9f1d
              at com.sun.tools.javac.v8.comp.Items$Item.store(Items.java:203)
      ...

      This code compiled successfully under javac 1.3, although it was
      rejected by 1.1 according to the rules of the first edition JLS. It
      looks as though the checks for a parenthesized expression representing a
      variable were changed in 1.4 in such a manner to once again cause a
      compiler failure. Meanwhile, following the recommendation of the Spec
      Report, and eliding the (), produces an example which will successfully
      compile in all JDK versions from 1.1 on, including 1.4. This argues
      once again that the special casing needed to support parenthesized
      expressions as variables is not worth the effort, since the compilation
      is unambiguous without the ().

      Attachments

        Activity

          People

            gafter Neal Gafter
            gafter Neal Gafter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: