8343019: Primitive caches must use boxed instances from the archive

Reviewed-by: jiangli, vlivanov, iklam
This commit is contained in:
Aleksey Shipilev 2024-10-31 20:18:25 +00:00
parent ae82cc1ba1
commit 7c36fa7e17
8 changed files with 100 additions and 33 deletions

View file

@ -244,7 +244,7 @@ public final class Short extends Number implements Comparable<Short>, Constable
// Load and use the archived cache if it exists
CDS.initializeFromArchive(ShortCache.class);
if (archivedCache == null || archivedCache.length != size) {
if (archivedCache == null) {
Short[] c = new Short[size];
short value = -128;
for(int i = 0; i < size; i++) {
@ -253,6 +253,7 @@ public final class Short extends Number implements Comparable<Short>, Constable
archivedCache = c;
}
cache = archivedCache;
assert cache.length == size;
}
}