Summary
Add a static factory method constructing ClassDesc instance from class internal name.
Problem
There is an easy way to create a ClassDesc
from a binary name (ClassDesc::of
) or a field descriptor (ClassDesc::ofDescriptor
) but not from an internal name. But, the internal name is common in low-level bytecode-manipulation code.
Solution
Add java.lang.constant.ClassDesc::ofInternalName
method.
Specification
New method declaration in src/java.base/share/classes/java/lang/constant/ClassDesc.java
:
/**
* Returns a {@linkplain ClassDesc} for a class or interface type,
* given the name of the class or interface in internal form,
* such as {@code "java/lang/String"}.
*
* @apiNote
* To create a descriptor for an array type, either use {@link #ofDescriptor(String)}
* or {@link #arrayType()}; to create a descriptor for a primitive type, use
* {@link #ofDescriptor(String)} or use the predefined constants in
* {@link ConstantDescs}.
*
* @param name the fully qualified class name, in internal (slash-separated) form
* @return a {@linkplain ClassDesc} describing the desired class
* @throws NullPointerException if the argument is {@code null}
* @throws IllegalArgumentException if the name string is not in the
* correct format
* @jvms 4.2.1 Binary Class and Interface Names
* @see ClassDesc#of(String)
* @see ClassDesc#ofDescriptor(String)
*/
static ClassDesc ofInternalName(String name) {
- csr of
-
JDK-8278863 Add method ClassDesc::ofInternalName
-
- Resolved
-