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

Inner class access to private constructor creates invalid inner class name

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 1.2.1
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description



      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)
      ======================================================================

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: