On Wed, 27 May 2026 15:34:29 GMT, Chen Liang <[email protected]> wrote:
>> Daisuke Yamazaki has updated the pull request incrementally with three
>> additional commits since the last revision:
>>
>> - Include BSM entry in garbage prefill for constant pool hashing
>> - Fix hash code computation in BootstrapMethodEntry to use poolHash
>> - Correct incomplete comment
>
> src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java
> line 530:
>
>> 528: abstract static sealed class AbstractRefEntry<T extends PoolEntry>
>> extends AbstractPoolEntry {
>> 529: protected final T ref1;
>> 530: private @Stable int contentHash;
>
> I called the one in Utf8EntryImpl contentHash because it is a string hash
> instead of a directly usable hash for an entry. So we need a better name.
> I think we might use names like `constructionHash` and `fullHash` instead.
> And the cache field for the full hash might be stored in the root
> AbstractPoolEntry, which can declare like this:
> int constructionHash() {
> // Just return `hashCode()` by default?
> // The "hash" field should get a rename otherwise.
> assert hash != 0;
> return hash;
> }
>
> private @Stable int fullHash;
>
> public int hashCode() {
> int hash = fullHash;
> if (hash == 0) {
> return fullHash = computeFullHash();
> }
> return hash;
> }
>
> abstract int computeFullHash();
That said, the construction hash of a `ClassEntry` is specially chosen to be
`hash1(tag, descriptorStringHash)` instead of a hash of the UTF content - this
is to allow fast hashing from an `L;` descriptor to an existing `ClassEntry`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31255#discussion_r3311964333