7165102: Only run assertion on Integer autoboxing cache size once
authorforax
Wed, 02 May 2012 20:01:59 +0100
changeset 12668 9a70f2230e3b
parent 12560 069c9358158b
child 12669 e86217580e18
7165102: Only run assertion on Integer autoboxing cache size once Reviewed-by: darcy, alanb
jdk/src/share/classes/java/lang/Integer.java
--- a/jdk/src/share/classes/java/lang/Integer.java	Wed May 02 14:50:46 2012 +0100
+++ b/jdk/src/share/classes/java/lang/Integer.java	Wed May 02 20:01:59 2012 +0100
@@ -780,6 +780,9 @@
             int j = low;
             for(int k = 0; k < cache.length; k++)
                 cache[k] = new Integer(j++);
+
+            // range [-128, 127] must be interned (JLS7 5.1.7)
+            assert IntegerCache.high >= 127;
         }
 
         private IntegerCache() {}
@@ -801,7 +804,6 @@
      * @since  1.5
      */
     public static Integer valueOf(int i) {
-        assert IntegerCache.high >= 127;
         if (i >= IntegerCache.low && i <= IntegerCache.high)
             return IntegerCache.cache[i + (-IntegerCache.low)];
         return new Integer(i);