mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-24 04:54:40 +02:00
7165102: Only run assertion on Integer autoboxing cache size once
Reviewed-by: darcy, alanb
This commit is contained in:
parent
43ef89d4a6
commit
05ffd97b08
1 changed files with 3 additions and 1 deletions
|
@ -780,6 +780,9 @@ public final class Integer extends Number implements Comparable<Integer> {
|
||||||
int j = low;
|
int j = low;
|
||||||
for(int k = 0; k < cache.length; k++)
|
for(int k = 0; k < cache.length; k++)
|
||||||
cache[k] = new Integer(j++);
|
cache[k] = new Integer(j++);
|
||||||
|
|
||||||
|
// range [-128, 127] must be interned (JLS7 5.1.7)
|
||||||
|
assert IntegerCache.high >= 127;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntegerCache() {}
|
private IntegerCache() {}
|
||||||
|
@ -801,7 +804,6 @@ public final class Integer extends Number implements Comparable<Integer> {
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public static Integer valueOf(int i) {
|
public static Integer valueOf(int i) {
|
||||||
assert IntegerCache.high >= 127;
|
|
||||||
if (i >= IntegerCache.low && i <= IntegerCache.high)
|
if (i >= IntegerCache.low && i <= IntegerCache.high)
|
||||||
return IntegerCache.cache[i + (-IntegerCache.low)];
|
return IntegerCache.cache[i + (-IntegerCache.low)];
|
||||||
return new Integer(i);
|
return new Integer(i);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue