JDK-8280480 : VM accepts an illegal method descriptor referred by CONSTANT_InvokeDynamic_info. name_and_type_index
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 18,19
  • Priority: P1
  • Status: Resolved
  • Resolution: Not an Issue
  • Submitted: 2022-01-21
  • Updated: 2022-01-24
  • Resolved: 2022-01-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18Resolved
Related Reports
Relates :  
Description
JCK 11 test classfmt/cpl/cplidc005/cplidc00501m018/cplidc00501m018.html was written for JEP 309. 
It's used to test the following assertions:
Chapter 4.4.10
name_and_type_index
  In a CONSTANT_Dynamic_info structure, the indicated descriptor must be a field descriptor (4.3.2).[jvms-4.4.10-200-C.1]
 In a CONSTANT_InvokeDynamic_info structure, the indicated descriptor must be a method descriptor (4.3.3).[jvms-4.4.10-200-C.2]

The test case cplidc00501m018 is negative and uses the method descriptor "<init>":"(Ljava/lang/String;)Z" to get 
java.lang.ClassFormatError: Method "<init>" in class <NAME> has illegal signature "(Ljava/lang/String;)Z"

The test was correct for versions JDK 11-17, now it fails with JDK 18, 19 because no exceptions are thrown.
Comments
Closing as Not An Issue because there is no JVM Spec requirement concerning CONSTANT_InvokeDynamic_info and methods named <init>. The failing JCK test contains the following constant pool entries: #8 = NameAndType #3:#7 // "<init>":(Ljava/lang/String;)Z #9 = InvokeDynamic #0:#8 // #0:"<init>":(Ljava/lang/String;)Z Unlike for CONSTANT_MethodRef_info, the JVM Spec has no requirements concerning methods named <init> in CONSTANT_NameAndType_info's referenced by CONSTANT_InvokeDynamic_info entries. See https://docs.oracle.com/javase/specs/jvms/se17/html/jvms-4.html#jvms-4.4.10 (For CONSTANT_MethodRef_info, the JVM Spec has the following requirement in section https://docs.oracle.com/javase/specs/jvms/se17/html/jvms-4.html#jvms-4.4.2 If the name of the method in a CONSTANT_Methodref_info structure begins with a '<' ('\u003c'), then the name must be the special name <init>, representing an instance initialization method (ยง2.9.1). The return type of such a method must be void.) The JVM Spec has this requirement for CONSTANT_InvokeDynamic_info entries: In a CONSTANT_InvokeDynamic_info structure, the indicated descriptor must be a method descriptor (4.3.3).[jvms-4.4.10-200-C.2] However, there is nothing in JVM Spec section https://docs.oracle.com/javase/specs/jvms/se17/html/jvms-4.html#jvms-4.3.3 concerning methods named <init> or their signatures.
24-01-2022

Likely caused by JDK-8268720. The interpretation applied in JDK-8268720 indicates that the test is not valid. " For example, the NameAndType constant <init>:()D is legal, per the specification, and should not cause a ClassFormatError unless and until it is referenced by a Methodref constant." But why has it taken so long for this issue to be raised?
24-01-2022

Preliminary ILW (may be updated during next Triage meeting, or when new info becomes available): I: HIGH (TCK failure) L: HIGH (happens always - looks like it - need to be confirmed; if this is an intermittent issue we may lower the likelihood score) W: M - do not use method with illegal signature ILW = HHM = P1
21-01-2022