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

No error on reference to anonymous class binary name

    XMLWordPrintable

    Details

      Description

      // C.java, compiled first
      public class C {
          Object o = new Object() {};
      }

      // Test.java, compiled second
      public class Test {
          C$1 var;
      }

      This compiles without error, even though there exists no in-scope class with name "C$1" (see JLS 6.5.5.1).

      JDK-8023945 noticed that I can extend the class, but it shouldn't even be possible to name the class.

      Related cases behave as expected:
      - If I introduce a member class D, an error occurs for C$D.
      - If I use a qualified name -- "p.C$1" -- an error occurs.
      - If I use a qualified name and *then* use an unqualified name ("p.C$1 var1; C$1 var2;"), I get two errors -- something stateful is going on

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dlsmith Dan Smith
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: