This program:
class A {
public static void main(String argv[]) {
int size = 4000000;
int x[] = new int[size];
for (int i = 0; i < 1000; i++) {
for (int j = 0; j < size; j += 8192) {
int y = x[j];
}
}
}
}
Fails as follows:
mate:~> /usr/local/java/jdk1.4.0/solsparc/bin/java A
mate:~> /usr/local/java/jdk1.4.0/solsparc/bin/java -server A
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at A.main(A.java:9)
mate:~> /usr/local/java/jdk1.4.0/solsparc/bin/java -server -Xint A
mate:~> /usr/local/java/jdk1.4.0/solsparc/bin/java -d64 A
mate:~> /usr/local/java/jdk1.4.0/solsparc/bin/java -server -XX:+PrintCompilation A
1% A::main @ 18
(47 bytes)
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at A.main(A.java:9)
mate:~> /usr/local/java/jdk1.4.0/solsparc/bin/java -server -version
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
Java HotSpot(TM) Server VM (build 1.4.0-rc-b91, mixed mode)
It does not fail in 1.3.1 or 1.2.1.