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

Inner class access to private constructor creates invalid inner class name

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.2.1
    • tools
    • generic
    • generic



      Name: et89391 Date: 08/04/99


      If you write could that has one class invoking a private
      constructor in another class, and this access should be legal
      because one class is declared in the other or they are both
      enclosed by another, javac generates a synthetic inner class
      to make this work.

      For example, when compiling the following code:

      public class PrivateConstructor {
              private PrivateConstructor() {}
              static class A {
                      PrivateConstructor f() {
                              return new PrivateConstructor();
                              }
                      }
              }

      javac generates the class PrivateConstructor$1. However, the
      generated innerclass attribute for PrivateConstructor$1 is:
            static PrivateConstructor$1( [index = 0], "1")

      My understanding of the Java Inner class specification is that
      the inner_name_index for this attribute should be 0, both
      because PrivateConstructor$1 is a (synthetic) anonymous class
      and because "1" is not a valid Java identifier.
      (Review ID: 56521)
      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: