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

JVM does not flag constant class entries ending in '/'

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 19
    • hotspot
    • None
    • behavioral
    • minimal
    • Hide
      This change will throw ClassFormatError exceptions when loading pre-JDK-1.5 class files whose names end in '/', when previously no exceptions were thrown. The compatibility risk is low because it is unlikely many such classes exist. These classes cannot be created using Javac, or other bytecode emitters such as Jasm, and Jcod. Also, these classes would fail to load when updated to a newer class file version.
      Show
      This change will throw ClassFormatError exceptions when loading pre-JDK-1.5 class files whose names end in '/', when previously no exceptions were thrown. The compatibility risk is low because it is unlikely many such classes exist. These classes cannot be created using Javac, or other bytecode emitters such as Jasm, and Jcod. Also, these classes would fail to load when updated to a newer class file version.
    • Other

      Summary

      The JVM should throw a ClassFormatError exception when loading a class whose class file major version is < 49 (JDK-1.5) and the class's name ends in a '/', as is currently done for newer class files.

      Problem

      The JVM currently allows loading of old class files whose names end in '/'. This violates section 4.2.1 of the JVM Specification.

      Solution

      Modify the JVM to throw a ClassFormatError exception when trying to load an old class file whose name ends in '/'. Note that the JVM already throws a ClassFormatError exception when trying to load a newer class file whose class name ends in a '/'.

      The pull request containing the proposed code change is here: https://github.com/openjdk/jdk/pull/6678

      Specification

      JVM Specification 4.2.1 Binary Class and Interface Names

      Class and interface names that appear in class file structures are always represented in a fully qualified form known as binary names (JLS §13.1). Such names are always represented as CONSTANT_Utf8_info structures (§4.4.7) and thus may be drawn, where not further constrained, from the entire Unicode codespace. Class and interface names are referenced from those CONSTANT_NameAndType_info structures (§4.4.6) which have such names as part of their descriptor (§4.3), and from all CONSTANT_Class_info structures (§4.4.1).

      For historical reasons, the syntax of binary names that appear in class file structures differs from the syntax of binary names documented in JLS §13.1. In this internal form, the ASCII periods (.) that normally separate the identifiers which make up the binary name are replaced by ASCII forward slashes (/). The identifiers themselves must be unqualified names (§4.2.2).

            hseigel Harold Seigel (Inactive)
            hseigel Harold Seigel (Inactive)
            Lois Foltan
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: