On Fri, 22 May 2026 08:10:05 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).

This pull request has been closed without being integrated.

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

PR: https://git.openjdk.org/jdk/pull/31253

Reply via email to