JDK-6931296 : IndexOutOfBoundsException is not thrown for specific code in the -Xcomp mode since JDK b81
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs17
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2010-03-02
  • Updated: 2012-03-22
  • Resolved: 2010-03-02
Related Reports
Duplicate :  
Description
PASSED: JDK 6 b105, JDK 7 b80 (on all platforms)
FAILED: JDK 7 b81 (seems to on all platforms)

The following code has started failing since JDK 7 b81 (hs17 b08) when the "-Xcomp" option is specified.

==================
public class ArrayBoundTest {

    public static void main(String[] args) {
        byte bb[] = {  1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
        try {
            write(bb, -1, 4);
            System.out.println("BAD");
        } catch (IndexOutOfBoundsException e) {
            System.out.println("OK");
        }
    }

    static public void write(byte b[], int off, int len)
    {   
        for (int i = 0; i < len; ++ i)
            write(b[off + i]);
    }

    static  private void write(byte b) {
        
    }

}
===============

Here is the output from running the program above using different JDKs on jessika.russia.sun.com:

================
<ag153348@jessika> uname -a
SunOS jessika 5.10 Generic_137137-09 sun4v sparc SUNW,T5140

<ag153348@jessika> /set/java/re/jdk/7/promoted/ea/b81/binaries/solaris-sparc/bin/javac ArrayBoundTest.java
<ag153348@jessika> /set/java/re/jdk/7/promoted/ea/b81/binaries/solaris-sparc/bin/java -showversion -Xcomp -cp . ArrayBoundTestjava version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b81)
Java HotSpot(TM) Server VM (build 17.0-b08, compiled mode)

BAD
<ag153348@jessika> 

<ag153348@jessika> /set/java/re/jdk/7/promoted/ea/b81/binaries/solaris-sparc/bin/java -showversion  -cp . ArrayBoundTest
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b81)
Java HotSpot(TM) Server VM (build 17.0-b08, mixed mode)

OK

<ag153348@jessika> /set/java/re/jdk/7/promoted/ea/b80/binaries/solaris-sparc/bin/javac ArrayBoundTest.java 
<ag153348@jessika> /set/java/re/jdk/7/promoted/ea/b80/binaries/solaris-sparc/bin/java -showversion -Xcomp -cp . ArrayBoundTest
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b80)
Java HotSpot(TM) Server VM (build 17.0-b07, compiled mode)

OK
<ag153348@jessika> 

<ag153348@jessika> javac ArrayBoundTest.java 
<ag153348@jessika> java -cp . ArrayBoundTest
<ag153348@jessika> java -showversion -cp . ArrayBoundTest
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Server VM (build 1.6.0-b105, compiled mode)

OK

===========================