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: Resolved
  • Resolution: Fixed
  • Submitted: 2024-10-24
  • Updated: 2024-11-11
  • 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 24
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
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