735 *
736 * <blockquote>
737 * {@code new Integer(Integer.parseInt(s))}
738 * </blockquote>
739 *
740 * @param s the string to be parsed.
741 * @return an {@code Integer} object holding the value
742 * represented by the string argument.
743 * @exception NumberFormatException if the string cannot be parsed
744 * as an integer.
745 */
746 public static Integer valueOf(String s) throws NumberFormatException {
747 return Integer.valueOf(parseInt(s, 10));
748 }
749
750 /**
751 * Cache to support the object identity semantics of autoboxing for values between
752 * -128 and 127 (inclusive) as required by JLS.
753 *
754 * The cache is initialized on first usage. The size of the cache
755 * may be controlled by the -XX:AutoBoxCacheMax=<size> option.
756 * During VM initialization, java.lang.Integer.IntegerCache.high property
757 * may be set and saved in the private system properties in the
758 * sun.misc.VM class.
759 */
760
761 private static class IntegerCache {
762 static final int low = -128;
763 static final int high;
764 static final Integer cache[];
765
766 static {
767 // high value may be configured by property
768 int h = 127;
769 String integerCacheHighPropValue =
770 sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
771 if (integerCacheHighPropValue != null) {
772 int i = parseInt(integerCacheHighPropValue);
773 i = Math.max(i, 127);
774 // Maximum array size is Integer.MAX_VALUE
775 h = Math.min(i, Integer.MAX_VALUE - (-low));
|
735 *
736 * <blockquote>
737 * {@code new Integer(Integer.parseInt(s))}
738 * </blockquote>
739 *
740 * @param s the string to be parsed.
741 * @return an {@code Integer} object holding the value
742 * represented by the string argument.
743 * @exception NumberFormatException if the string cannot be parsed
744 * as an integer.
745 */
746 public static Integer valueOf(String s) throws NumberFormatException {
747 return Integer.valueOf(parseInt(s, 10));
748 }
749
750 /**
751 * Cache to support the object identity semantics of autoboxing for values between
752 * -128 and 127 (inclusive) as required by JLS.
753 *
754 * The cache is initialized on first usage. The size of the cache
755 * may be controlled by the {@code -XX:AutoBoxCacheMax=<size>} option.
756 * During VM initialization, java.lang.Integer.IntegerCache.high property
757 * may be set and saved in the private system properties in the
758 * sun.misc.VM class.
759 */
760
761 private static class IntegerCache {
762 static final int low = -128;
763 static final int high;
764 static final Integer cache[];
765
766 static {
767 // high value may be configured by property
768 int h = 127;
769 String integerCacheHighPropValue =
770 sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
771 if (integerCacheHighPropValue != null) {
772 int i = parseInt(integerCacheHighPropValue);
773 i = Math.max(i, 127);
774 // Maximum array size is Integer.MAX_VALUE
775 h = Math.min(i, Integer.MAX_VALUE - (-low));
|