From 66bcedaa7ad24f00035d7965df537a21b67c9599 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 18 Jun 2013 11:36:39 -0700 Subject: [PATCH] 8015395: NumberFormatException during startup if JDK-internal property java.lang.Integer.IntegerCache.high set to bad value Fall back to default if a bad value is passed for this property. Reviewed-by: mduigou --- jdk/src/share/classes/java/lang/Integer.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/java/lang/Integer.java b/jdk/src/share/classes/java/lang/Integer.java index e5de967a069..4a08f4740ec 100644 --- a/jdk/src/share/classes/java/lang/Integer.java +++ b/jdk/src/share/classes/java/lang/Integer.java @@ -788,10 +788,14 @@ public final class Integer extends Number implements Comparable { 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;