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

Regression: invalid resolution of supertype for local class

XMLWordPrintable

    • b03
    • 7
    • b109
    • unknown
    • generic
    • Verified

      Hi,
         recently, we have recieved a report about an incorrectly compiled class (http://netbeans.org/bugzilla/show_bug.cgi?id=187452). Consider the following code:
      ---------------------------------------------------------
      public class p1 {

          public static void resolve() {
              class b {
                  int x = 1;
              }
              class c extends b {}

              System.out.println(new c().x);
          }

          static class b {}
      }
      ---------------------------------------------------------

      Using a recent JDK7 javac, there is a compilation error that "x" cannot be resolved on the line with "new c().x". This compilation error does not seem correct to me. JDK6 javac accepts that code. I tried to find out the cause, and it seems that this was introduced by a fix for bug 5060485.

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: