equal
deleted
inserted
replaced
995 */ |
995 */ |
996 |
996 |
997 private static class IntegerCache { |
997 private static class IntegerCache { |
998 static final int low = -128; |
998 static final int low = -128; |
999 static final int high; |
999 static final int high; |
1000 static final Integer cache[]; |
1000 static final Integer[] cache; |
|
1001 static Integer[] archivedCache; |
1001 |
1002 |
1002 static { |
1003 static { |
1003 // high value may be configured by property |
1004 // high value may be configured by property |
1004 int h = 127; |
1005 int h = 127; |
1005 String integerCacheHighPropValue = |
1006 String integerCacheHighPropValue = |
1014 // If the property cannot be parsed into an int, ignore it. |
1015 // If the property cannot be parsed into an int, ignore it. |
1015 } |
1016 } |
1016 } |
1017 } |
1017 high = h; |
1018 high = h; |
1018 |
1019 |
1019 cache = new Integer[(high - low) + 1]; |
1020 // Load IntegerCache.archivedCache from archive, if possible |
1020 int j = low; |
1021 VM.initializeFromArchive(IntegerCache.class); |
1021 for(int k = 0; k < cache.length; k++) |
1022 int size = (high - low) + 1; |
1022 cache[k] = new Integer(j++); |
1023 |
1023 |
1024 // Use the archived cache if it exists and is large enough |
|
1025 if (archivedCache == null || size > archivedCache.length) { |
|
1026 Integer[] c = new Integer[size]; |
|
1027 int j = low; |
|
1028 for(int k = 0; k < c.length; k++) |
|
1029 c[k] = new Integer(j++); |
|
1030 archivedCache = c; |
|
1031 } |
|
1032 cache = archivedCache; |
1024 // range [-128, 127] must be interned (JLS7 5.1.7) |
1033 // range [-128, 127] must be interned (JLS7 5.1.7) |
1025 assert IntegerCache.high >= 127; |
1034 assert IntegerCache.high >= 127; |
1026 } |
1035 } |
1027 |
1036 |
1028 private IntegerCache() {} |
1037 private IntegerCache() {} |