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).
- csr of
-
JDK-8276241 JVM does not flag constant class entries ending in '/'
-
- Resolved
-
- links to
-
Review openjdk/jdk/6678