RFR: 8309819: Clarify API note in Class::getName and MethodType::toMethodDescriptorString [v5]
Mandy Chung
mchung at openjdk.org
Fri Jun 16 19:23:09 UTC 2023
On Thu, 15 Jun 2023 02:38:08 GMT, Chen Liang <liach at openjdk.org> wrote:
>> The API specification for descriptorString not being a strict inverse of Class::forName and MethodType::fromDescriptorString are not entirely correct.
>>
>> 1. Class::descriptorString was never an inverse of Class::forName, which takes a binary name instead. Class::getName was a partial inverse instead.
>> 2. MethodType::toMethodDescriptorString ends with a meaningless sentence: "fromMethodDescriptorString, because the latter requires a suitable class loader argument.", and the "Note:" section can be replaced with an `@apiNote`.
>> 3. Both of these didn't mention hidden classes (or other non-nominally-describable classes) as a reason that prevents the inversion operation, in addition to distinct classloaders.
>>
>> A few user-defined anchor links are replaced with updated javadoc link tag format as well. The explicit html-style links in `@see` tags are unchanged in order to retain the non-code output.
>>
>> The rendered specifications:
>> https://cr.openjdk.org/~liach/8309819/04/java.base/java/lang/Class.html
>> https://cr.openjdk.org/~liach/8309819/04/java.base/java/lang/invoke/MethodType.html
>
> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
>
> Update the note for getName
The api note is primarily regarding about 1-N Class instances from a class name because of different class loader. For cases that are not a loadable class name or not a type descriptor, the spec of `Class::forName` and `MethodType::fromMethodDescriptorString` should specify clearly. If not, we should clarify those specs rather than explaining the negative cases in the api note.
I think these API specs can be improved especially `forName` doesn't talk about the name for array type which is a fully-qualified name. I'll create a PR for that and see if that helps the clarification.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14411#issuecomment-1595179872
More information about the core-libs-dev
mailing list