mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8343019: Primitive caches must use boxed instances from the archive
Reviewed-by: jiangli, vlivanov, iklam
This commit is contained in:
parent
ae82cc1ba1
commit
7c36fa7e17
8 changed files with 100 additions and 33 deletions
|
@ -117,7 +117,7 @@ public final class Byte extends Number implements Comparable<Byte>, Constable {
|
|||
|
||||
// Load and use the archived cache if it exists
|
||||
CDS.initializeFromArchive(ByteCache.class);
|
||||
if (archivedCache == null || archivedCache.length != size) {
|
||||
if (archivedCache == null) {
|
||||
Byte[] c = new Byte[size];
|
||||
byte value = (byte)-128;
|
||||
for(int i = 0; i < size; i++) {
|
||||
|
@ -126,6 +126,7 @@ public final class Byte extends Number implements Comparable<Byte>, Constable {
|
|||
archivedCache = c;
|
||||
}
|
||||
cache = archivedCache;
|
||||
assert cache.length == size;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8984,7 +8984,7 @@ class Character implements java.io.Serializable, Comparable<Character>, Constabl
|
|||
|
||||
// Load and use the archived cache if it exists
|
||||
CDS.initializeFromArchive(CharacterCache.class);
|
||||
if (archivedCache == null || archivedCache.length != size) {
|
||||
if (archivedCache == null) {
|
||||
Character[] c = new Character[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
c[i] = new Character((char) i);
|
||||
|
@ -8992,6 +8992,7 @@ class Character implements java.io.Serializable, Comparable<Character>, Constabl
|
|||
archivedCache = c;
|
||||
}
|
||||
cache = archivedCache;
|
||||
assert cache.length == size;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -960,7 +960,17 @@ public final class Integer extends Number
|
|||
if (archivedCache == null || size > archivedCache.length) {
|
||||
Integer[] c = new Integer[size];
|
||||
int j = low;
|
||||
for(int i = 0; i < c.length; i++) {
|
||||
// If archive has Integer cache, we must use all instances from it.
|
||||
// Otherwise, the identity checks between archived Integers and
|
||||
// runtime-cached Integers would fail.
|
||||
int archivedSize = (archivedCache == null) ? 0 : archivedCache.length;
|
||||
for (int i = 0; i < archivedSize; i++) {
|
||||
c[i] = archivedCache[i];
|
||||
assert j == archivedCache[i];
|
||||
j++;
|
||||
}
|
||||
// Fill the rest of the cache.
|
||||
for (int i = archivedSize; i < size; i++) {
|
||||
c[i] = new Integer(j++);
|
||||
}
|
||||
archivedCache = c;
|
||||
|
|
|
@ -962,7 +962,7 @@ public final class Long extends Number
|
|||
|
||||
// Load and use the archived cache if it exists
|
||||
CDS.initializeFromArchive(LongCache.class);
|
||||
if (archivedCache == null || archivedCache.length != size) {
|
||||
if (archivedCache == null) {
|
||||
Long[] c = new Long[size];
|
||||
long value = -128;
|
||||
for(int i = 0; i < size; i++) {
|
||||
|
@ -971,6 +971,7 @@ public final class Long extends Number
|
|||
archivedCache = c;
|
||||
}
|
||||
cache = archivedCache;
|
||||
assert cache.length == size;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue