mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8213033: Archive remaining primitive box caches
Reviewed-by: jiangli, alanb
This commit is contained in:
parent
4a235517f9
commit
4b45441ae9
9 changed files with 117 additions and 50 deletions
|
@ -31,6 +31,7 @@ import java.util.HashMap;
|
|||
import java.util.Locale;
|
||||
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
/**
|
||||
* The {@code Character} class wraps a value of the primitive
|
||||
|
@ -7914,11 +7915,22 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
|||
private static class CharacterCache {
|
||||
private CharacterCache(){}
|
||||
|
||||
static final Character cache[] = new Character[127 + 1];
|
||||
static final Character[] cache;
|
||||
static Character[] archivedCache;
|
||||
|
||||
static {
|
||||
for (int i = 0; i < cache.length; i++)
|
||||
cache[i] = new Character((char)i);
|
||||
int size = 127 + 1;
|
||||
|
||||
// Load and use the archived cache if it exists
|
||||
VM.initializeFromArchive(CharacterCache.class);
|
||||
if (archivedCache == null || archivedCache.length != size) {
|
||||
Character[] c = new Character[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
c[i] = new Character((char) i);
|
||||
}
|
||||
archivedCache = c;
|
||||
}
|
||||
cache = archivedCache;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue