RFR: 8342206: Convenience method to check if a constant pool entry matches nominal descriptors

Adam Sotona asotona at openjdk.org
Tue Feb 11 17:17:13 UTC 2025


On Tue, 11 Feb 2025 16:36:24 GMT, Chen Liang <liach at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/classfile/constantpool/Utf8Entry.java line 95:
>> 
>>> 93:      * @since 25
>>> 94:      */
>>> 95:     boolean equalsSymbol(ClassDesc desc);
>> 
>> Ambiguity of class internal name vs. descriptor serialization might be confusing:
>> 
>> classEntry.equalsSymbol(classDesc) != classEntry.name().equalsSymbol(classDesc)
>> 
>> I think it should be more highlighted to avoid mistakes.
>
> I think the best way to avoid these confusions is, in addition to specifying in the docs, renaming the methods on `Utf8Entry` to include the word "descriptor", like `equalsDescriptorString`, but I fear this method name might be too long.
> 
> If the `equalsDescriptorString` on `Utf8Entry` is too inconvenient, a remedy may be to add `matches(String, ClassDesc)` or `matches(String, MethodTypeDesc)` to NameAndTypeEntry and/or MemberRefEntry.

I think it is clearly OK to add the non-ambiguous methods, however this one probably should be brought to the mailing list for discussion. We already did some spins related to the ClassDesc serialization ambiguity in the API and there was never clear output. One of the option might be to exclude the ambiguous methods from this PR.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23548#discussion_r1951261649


More information about the core-libs-dev mailing list