RFR: 8342206: Convenience method to check if a ClassEntry matches a ClassDesc [v2]
Chen Liang
liach at openjdk.org
Wed Oct 16 16:24:12 UTC 2024
On Wed, 16 Oct 2024 05:58:08 GMT, Chen Liang <liach at openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java line 609:
>>
>>> 607: var mySym = this.sym;
>>> 608: if (mySym != null)
>>> 609: return mySym.equals(symbol);
>>
>> Note that `ClassEntry::asSymbol()` also caches array `ClassDesc`s in `ref1.typeSym` so that the symbol cache can be shared with `FieldRefEntry` and `ConstantDynamicEntry`.
>>
>> --------------------------------------------------------------------------------
>>
>> I suggest adding the following check:
>>
>> if (ref1.typeSym instanceof ClassDesc ref1Sym && ref1Sym.isArray()) {
>> return ref1Sym.equals(symbol);
>> }
>
> I think adding this on the sym present hot path might be too costly. A better way is to pull in the sym before `ref1.equalsString` and push the compatible symbol back to utf8 if we have `equals`.
Done.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21526#discussion_r1803436476
More information about the core-libs-dev
mailing list