On Wed, 27 May 2026 14:56:10 GMT, Daisuke Yamazaki <[email protected]> wrote:

>> I fixed inconsistent `equals` / `hashCode` behaviour in `PoolEntry` and 
>> `BootstrapMethodEntry` objects created by different `ConstantPoolBuilder` 
>> instances.
>> 
>> Previously, some hash codes depended on constant pool indices of referenced 
>> entries.
>> Because of this, two entries with the same content could be equal but still 
>> have different hash codes if they came from different pools.
>> 
>> This patch splits hashing into two types:
>> 1. `public hashCode()`, now based only on content and consistent with 
>> `equals`(slower than the type 2)
>> 2. internal pool lookup hash, still based on indices for fast 
>> `SplitConstantPool` and bootstrap method table deduplication
>> 
>> This keeps fast local lookup performance while fixing the public `equals` / 
>> `hashCode` contract.
>> 
>> Added `PoolEntryHashCodeTest`, migrated from the original issue reproducer, 
>> which compares equivalent entries created by distinct `ConstantPoolBuilders` 
>> with different index layouts.
>> 
>> 
>> Running test 'jtreg:test/jdk/jdk/classfile/PoolEntryHashCodeTest.java'
>> Passed: jdk/classfile/PoolEntryHashCodeTest.java
>> Test results: passed: 1
>> 
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> 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

**LGTM**, but an **OpenJDK** committer will have to review this too.

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

Maybe having a package‑private supertype common to `AbstractPoolEntry` and 
`BootstrapMethodEntryImpl` which would provide an `abstract poolHash()` method 
could be useful.

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

Marked as reviewed by [email protected] (no known OpenJDK username).

PR Review: https://git.openjdk.org/jdk/pull/31255#pullrequestreview-4398393916

Reply via email to