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

4.7.9.1: Clarify relationship of Identifiers to class names

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P5
    • None
    • 8
    • specification
    • None
    • vm

    Description

      ClassTypeSignatures are essentially sequences of dot-delimited "Identifiers", with some optional type arguments thrown in. However, the correspondence between Identifiers and class names is unclear.

      There is this: "the terminal symbol Identifier is used to denote the name of a type ... as generated by the Java compiler"

      But the compiler-generated name of an inner class may be considered "Outer$Inner" or "Outer.Inner", depending on context.

      Longstanding behavior is as follows:
      - Inner classes of parameterized class types are encoded with, e.g., 'LOuter<TT;>.Inner;'
      - Inner classes of non-generic classes are encoded with, e.g., 'LOuter$Inner;'
      - Inner classes of raw class types are encoded with, e.g., 'LOuter$Inner;'
      - Inner classes multiple levels deep may mix delimiters, e.g. 'LA$B<TT;>.C.D;'

      JVMS 4.7.9 limits its rules about correctness to syntax; but, to some extent, it endorses the semantic checks performed by java.lang.reflect. In the Oracle JDK, this includes that every class mentioned before a '.' symbol has the correct number of type arguments. Hence, the GenericSignatureFormatError prompting JDK-8037934, which complains that, where Outer is generic, 'LOuter.Inner;' is not well-formed (the type arguments are missing).

      So, in general, both '$' and '.' may be used as delimiters, although type arguments must precede a '.' (or ';'), and raw types must precede a '$' (or '.'). It may be useful to simply state informally in 4.7.9.1 that it is acceptable to use '$' in the name of an inner class.

      Attachments

        Issue Links

          Activity

            People

              abuckley Alex Buckley
              dlsmith Dan Smith
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: