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).

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

Commit messages:
 - Update copyright year to 2026
 - Implement mulitlayer hash code calculation.
 - 8352794: Broken `equals` and `hashCode` implementation of `PoolEntry` and 
`BootstrapMethodEntry` implementations

Changes: https://git.openjdk.org/jdk/pull/31255/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=31255&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8352794
  Stats: 242 lines in 6 files changed: 223 ins; 0 del; 19 mod
  Patch: https://git.openjdk.org/jdk/pull/31255.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/31255/head:pull/31255

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

Reply via email to