RFR: 8278863: Add method ClassDesc::ofInternalName [v3]
Adam Sotona
asotona at openjdk.org
Mon Aug 22 07:12:13 UTC 2022
On Tue, 26 Jul 2022 19:57:38 GMT, ExE Boss <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/constant/ClassDesc.java line 85:
>>
>>> 83: * given the name of the class or interface in internal form,
>>> 84: * such as {@code "java/lang/String"}.
>>> 85: * (To create a descriptor for an array type, either use {@link #ofDescriptor(String)}
>>
>> It feels like this section could be expanded a bit (and parenthesis removed). E.g. as you point out in the comment, this method only supports reference types, so we should state so clearly. And then present alternatives (like you do now).
>
> Isn’t the internal name of an array type its descriptor though?
>
> So, I feel like this method should allow array descriptors.
First may I ask which parenthesis should be removed?
Mentioning "reference" is misleading when talking about Class internal name (JVMS 4.2.1 "Binary Class and Interface Names"). Word "reference" is mentioned in (JVMS 4.3.2. "Field Descriptors", Table 4.3-A. "Interpretation of field descriptors") and it also includes array types descriptors, so it might be rather mentioned in ClassDesc::ofDescriptor method doc.
This is also answer to the second comment - field descriptor of array type isn't an internal name according to my understanding of JVMS.
This method suppose to construct ClassDesc from class or interface internal name according to JVMS 4.2.1.
Construction of ClassDesc from field descriptor according to JVMS 4.3.2 is ClassDesc::ofDescriptor method responsibility.
-------------
PR: https://git.openjdk.org/jdk/pull/9201
More information about the core-libs-dev
mailing list