Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6353724

REGRESSION: Mustang b58+ create incorrectly sized arrays

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 6
    • 6
    • hotspot
    • b58
    • 6
    • b63
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.6.0-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b61)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b61, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Debian GNU/Linux x86-32

      A DESCRIPTION OF THE PROBLEM :
      public class t {
          public static void main(String[] args) {
              int[] newArray=new int[1073741824];
              newArray[1073741823]=12345;
              System.out.println("Size of newArray is "+newArray.length+
                                 " [it should be 1073741824]");
              System.out.println(newArray[1073741823]);
          }
      }

      With Mustang b59 and b61 (the only two tested) this is the output:
      $ /usr/lib/j2sdk6.0-sun/bin/javac t.java && /usr/lib/j2sdk6.0-sun/bin/java t
      Size of newArray is 12345 [it should be 1073741824]
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1073741823
              at t.main(t.java:7)

      Java 5.0:
      $ /usr/lib/j2sdk1.5-sun/bin/javac t.java && /usr/lib/j2sdk1.5-sun/bin/java t
      Exception in thread "main" java.lang.OutOfMemoryError: Requested array size exceeds VM limit


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      If there is not enough memory/address space to create an array a java.lang.OutOfMemoryError should be thrown.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class t {
          public static void main(String[] args) {
              int[] newArray=new int[1073741824];
              newArray[1073741823]=12345;
              System.out.println("Size of newArray is "+newArray.length+
                                 " [it should be 1073741824]");
              System.out.println(newArray[1073741823]);
          }
      }
      ---------- END SOURCE ----------

      Release Regression From : 5.0u4
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

            kamg Keith Mcguigan (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: