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

Alan Bateman Alan.Bateman at oracle.com
Wed May 29 21:35:58 UTC 2013

On 29/05/2013 20:54, Brian Burkhalter wrote:
> So if an InternalError were to be used instead, the code would be like:
>                  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) {
>                      // Recast the exception to an InternalError with a sensible message.
>                      throw new InternalError(nfe.toString() +
>                              ": cannot parse value specified for java.lang.Integer.IntegerCache.high property");
>                  }
> But that avoids the real question here, which is whether VM startup should be prevented by the value supplied for an internal property not being able to be parsed.
> Brian
It would be good to do a few experiments with -XX:AutoBoxCacheMax=<size> 
to make sure that bad values dp startup to fail, I expect they should.

As regards setting the property directly (which was never the intention 
and is not supported) then the issue is that the property value is being 
parsed lazily. If you want to check it early then it requires parsing it 
in VM.saveAndRemoveProperties, that is the method that is called early 
in the initialization to stash away these properties.


More information about the core-libs-dev mailing list