ADDITIONAL SYSTEM INFORMATION :
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
...
$ oracle-jdk-21.0.2/bin/java -version
java version "21.0.2" 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 21.0.2+13-LTS-58)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.2+13-LTS-58, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
When I run the program below with JDK 21, I notice different output results when I use the -Xint and -Xcomp options.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java -Xcomp Test > result_1
java -Xint Test > result_2
diff result_1 result_2
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no diff
ACTUAL -
[run] 1
4,20c4,20
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
---
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
---------- BEGIN SOURCE ----------
class Test {
int a = 400;
int[] e = new int[a];
void mainTest(String[] g) {
int i = 22738;
int b;
int h;
int[] c = new int[a];
for (b = 3; b < 273; b++) {
h = 1;
while (++h < 97) switch (b % 6 + 56) {
case 56:
c[1] = i;
case 57:
synchronized (new Test()) {}
}
}
int k = 0;
for (int j = 0; j < c.length; j++) k += c[j];
System.out.println(k);
}
public static void main(String[] f) {
Test d = new Test();
for (int i = 0; i < 20; i++) d.mainTest(f);
}
}
---------- END SOURCE ----------
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
...
$ oracle-jdk-21.0.2/bin/java -version
java version "21.0.2" 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 21.0.2+13-LTS-58)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.2+13-LTS-58, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
When I run the program below with JDK 21, I notice different output results when I use the -Xint and -Xcomp options.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java -Xcomp Test > result_1
java -Xint Test > result_2
diff result_1 result_2
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no diff
ACTUAL -
[run] 1
4,20c4,20
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
---
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
---------- BEGIN SOURCE ----------
class Test {
int a = 400;
int[] e = new int[a];
void mainTest(String[] g) {
int i = 22738;
int b;
int h;
int[] c = new int[a];
for (b = 3; b < 273; b++) {
h = 1;
while (++h < 97) switch (b % 6 + 56) {
case 56:
c[1] = i;
case 57:
synchronized (new Test()) {}
}
}
int k = 0;
for (int j = 0; j < c.length; j++) k += c[j];
System.out.println(k);
}
public static void main(String[] f) {
Test d = new Test();
for (int i = 0; i < 20; i++) d.mainTest(f);
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8327963 [Umbrella] Incorrect result of C2 compiled code since JDK-8237581
- Open