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

JLS section 8.8.5.1 contains an example which does not conforms to javac of JDK6

XMLWordPrintable

    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_10-rc"
      Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)
      Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP

      A DESCRIPTION OF THE PROBLEM :
      This section:

      http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#229267

      Contains this example:

      class Top {
      int x;
      class Dummy {
      Dummy(Object o) {}
      }
      class Inside extends Dummy {
      Inside() {
      super(new Object() { int r = x; }); // error
      }
      Inside(final int y) {
      super(new Object() { int r = y; }); // correct
      }
      }
      }

      Notice the "//error" comment. But javac *does* compile this without any error.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Try to compile the above program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The compiler should emit an error, as hinted in JLS
      ACTUAL -
      No error - it compiles successfully.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Top {
      int x;
      class Dummy {
      Dummy(Object o) {}
      }
      class Inside extends Dummy {
      Inside() {
      super(new Object() { int r = x; }); // error
      }
      Inside(final int y) {
      super(new Object() { int r = y; }); // correct
      }
      }
      }
      ---------- END SOURCE ----------

            mcimadamore Maurizio Cimadamore
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: