8015395: NumberFormatException during startup if JDK-internal property java.lang.Integer.IntegerCache.high set to bad value
authorbpb
Tue, 18 Jun 2013 11:36:39 -0700
changeset 18278 4b4381313a3c
parent 18183 9749983601cf
child 18279 6a32863b0186
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
jdk/src/share/classes/java/lang/Integer.java
--- a/jdk/src/share/classes/java/lang/Integer.java	Tue Jun 18 17:19:49 2013 +0400
+++ b/jdk/src/share/classes/java/lang/Integer.java	Tue Jun 18 11:36:39 2013 -0700
@@ -788,10 +788,14 @@
             String integerCacheHighPropValue =
                 sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
             if (integerCacheHighPropValue != null) {
-                int i = parseInt(integerCacheHighPropValue);
-                i = Math.max(i, 127);
-                // Maximum array size is Integer.MAX_VALUE
-                h = Math.min(i, Integer.MAX_VALUE - (-low) -1);
+                try {
+                    int i = parseInt(integerCacheHighPropValue);
+                    i = Math.max(i, 127);
+                    // Maximum array size is Integer.MAX_VALUE
+                    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;