RFR 8015395: NumberFormatException during startup if java.lang.Integer.IntegerCache.high set to bad value

Brian Burkhalter brian.burkhalter at oracle.com
Wed Jun 12 23:45:07 UTC 2013


As no consensus was achieved, I am following up on this thread from last month

http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-May/017493.html

The behavior with and without the initially suggested patch http://cr.openjdk.java.net/~bpb/8015395/ for a few examples is listed below. As may be seen, the change suppresses the exception for bad values of the java.lang.Integer.IntegerCache.high property passed on the command line (silently falls back to the default value), but appears not to affect the behavior of the AutoBoxCacheMax property for these same values.

There was more support expressed in the thread last month for throwing the NumberFormatExceotion rather than ignoring the bad value and falling back silently to the default. I tend to agree with that approach in general, but I think that the question here is really whether the same logic applies to a property such as java.lang.Integer.IntegerCache.high which is not publicly supported but rather intended to be used as an internal conduit.

Brian

--- WITH Patch ---

$ java -Xint -Djava.lang.Integer.IntegerCache.high=888888888888888888888888888 GoodbyeWorld
 Goodbye Cruel World! 

$ java -Xint -Djava.lang.Integer.IntegerCache.high=1024\-Xmx2g GoodbyeWorld
 Goodbye Cruel World! 

$ java -Xint -XX:AutoBoxCacheMax=888888888888888888888888888 GoodbyeWorld
 Goodbye Cruel World! 

$ java -Xint -XX:AutoBoxCacheMax=1024\-Xmx2g GoodbyeWorld
Improperly specified VM option 'AutoBoxCacheMax=1024-Xmx2g'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

--- WITHOUT Patch ---

$ java -Xint -Djava.lang.Integer.IntegerCache.high=888888888888888888888888888 GoodbyeWorld
Error occurred during initialization of VM
java.lang.ExceptionInInitializerError
	at java.lang.Integer.valueOf(Integer.java:826)
	at sun.misc.Signal.handle(Signal.java:169)
	at java.lang.Terminator.setup(Terminator.java:60)
	at java.lang.System.initializeSystemClass(System.java:1192)
Caused by: java.lang.NumberFormatException: For input string: "888888888888888888888888888"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:583)
	at java.lang.Integer.parseInt(Integer.java:615)
	at java.lang.Integer$IntegerCache.<clinit>(Integer.java:791)
	at java.lang.Integer.valueOf(Integer.java:826)
	at sun.misc.Signal.handle(Signal.java:169)
	at java.lang.Terminator.setup(Terminator.java:60)
	at java.lang.System.initializeSystemClass(System.java:1192)

$ java -Xint -Djava.lang.Integer.IntegerCache.high=1024\-Xmx2g GoodbyeWorld
Error occurred during initialization of VM
java.lang.ExceptionInInitializerError
	at java.lang.Integer.valueOf(Integer.java:826)
	at sun.misc.Signal.handle(Signal.java:169)
	at java.lang.Terminator.setup(Terminator.java:60)
	at java.lang.System.initializeSystemClass(System.java:1192)
Caused by: java.lang.NumberFormatException: For input string: "1024-Xmx2g"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.parseInt(Integer.java:615)
	at java.lang.Integer$IntegerCache.<clinit>(Integer.java:791)
	at java.lang.Integer.valueOf(Integer.java:826)
	at sun.misc.Signal.handle(Signal.java:169)
	at java.lang.Terminator.setup(Terminator.java:60)
	at java.lang.System.initializeSystemClass(System.java:1192)

$ java -Xint -XX:AutoBoxCacheMax=888888888888888888888888888 GoodbyeWorld
 Goodbye Cruel World!

$ java -Xint -XX:AutoBoxCacheMax=1024\-Xmx2g GoodbyeWorldImproperly specified VM option 'AutoBoxCacheMax=1024-Xmx2g'
Improperly specified VM option 'AutoBoxCacheMax=1024-Xmx2g'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.





More information about the core-libs-dev mailing list