提交 534e474f 编写于 作者: B bpb

8015395: NumberFormatException during startup if JDK-internal property...

8015395: NumberFormatException during startup if JDK-internal property java.lang.Integer.IntegerCache.high set to bad value
Summary: Fall back to default if a bad value is passed for this property.
Reviewed-by: mduigou
上级 179ae840
...@@ -788,10 +788,14 @@ public final class Integer extends Number implements Comparable<Integer> { ...@@ -788,10 +788,14 @@ public final class Integer extends Number implements Comparable<Integer> {
String integerCacheHighPropValue = String integerCacheHighPropValue =
sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high"); sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
if (integerCacheHighPropValue != null) { if (integerCacheHighPropValue != null) {
try {
int i = parseInt(integerCacheHighPropValue); int i = parseInt(integerCacheHighPropValue);
i = Math.max(i, 127); i = Math.max(i, 127);
// Maximum array size is Integer.MAX_VALUE // Maximum array size is Integer.MAX_VALUE
h = Math.min(i, Integer.MAX_VALUE - (-low) -1); h = Math.min(i, Integer.MAX_VALUE - (-low) -1);
} catch( NumberFormatException nfe) {
// If the property cannot be parsed into an int, ignore it.
}
} }
high = h; high = h;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册