JDK-8343019 : Primitive caches must use boxed instances from the archive
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 11.0.6,17,21,23,24
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2024-10-24
  • Updated: 2025-03-31
  • Resolved: 2024-10-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21 JDK 24
21.0.8Fixed 24 b23Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
This is forked from JDK-8342642 and filed as a general issue for archived boxed Integer cache when it's recreated at runtime. In short, current code drops the entire primitive cache when the CDS archived version of the cache is too short. This poses a problem with code that uses CDS archived cache instances, since the boxed equality would break when comparing the CDS-archived value and the Integer cached value recreated at runtime.

https://github.com/openjdk/jdk/pull/21672#issuecomment-2434359711 discusses a possible fix for the Integer cache. JDK-8342642 has additional details.

Comments
[jdk21u-fix-request] Approval Request from Satyen Subramaniam for backport. Reasoning: Current code drops the entire primitive cache when the CDS archived version of the cache is too short. By backporting this fix, we can anticipate and address cases using CDS archived cache instances, where the boxed equality would break when comparing the CDS-archived value and the Integer cached value recreated at runtime. Risk: Low. Tip change was merged in October of 2024 without any issues. This change adds a test to confirm the intended behavior. Testing: * GHA Sanity Checks * Tier 1 and 2 tests locally
15-03-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk21u-dev/pull/1497 Date: 2025-03-15 05:09:16 +0000
15-03-2025

Changeset: 7c36fa7e Branch: master Author: Aleksey Shipilev <shade@openjdk.org> Date: 2024-10-31 20:18:25 +0000 URL: https://git.openjdk.org/jdk/commit/7c36fa7e175c01dd994cd8f1ef9fd942dbddbce0
31-10-2024

Other primitive box caches, such as Byte and Short caches are ok since the cache size don't change. The 'archivedCache.length != size' check can be removed: ``` static { final int size = -(-128) + 127 + 1; // Load and use the archived cache if it exists CDS.initializeFromArchive(ByteCache.class); if (archivedCache == null || archivedCache.length != size) { ... ```
28-10-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/21737 Date: 2024-10-28 10:16:40 +0000
28-10-2024