ADDITIONAL SYSTEM INFORMATION :
$ java --version
java 17.0.10 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.10+11-LTS-240, mixed mode, sharing)
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
UBUNTU_CODENAME=jammy
A DESCRIPTION OF THE PROBLEM :
Decription: We downloaded JDK 17 from [the official Oracle website](https://www.oracle.com/java/technologies/downloads/) and ran test code below, and discover that JDK 17 produces different results under default settings and when using the -Xcomp option. Further testing revealed that under default settings, JDK 17 might also produce incorrect results. Additionally, the same issue was observed with OpenJDK's JDK 17u.
ACTUAL -
$ pathToOracleJDK-17.0.10/bin/java -Xcomp Test
297439200
$ pathToOracleJDK-17.0.10/bin/java Test
313920000
# sometimes
$ pathToOracleJDK-17.0.10/bin/java Test
299750000
# jdk17u
$ pathToJDK17u/bin/java Test
301058000
$ pathToJDK17u/bin/java Test
300491200
$ pathToJDK17u/bin/java Test
313920000
$ pathToJDK17u/bin/java -Xcomp Test
297439200
---------- BEGIN SOURCE ----------
class Test {
int N = 400;
long[] b = new long[N];
long a;
void mainTest(String[] strArr1) {
for (int i0 = 0; i0 < N; ++i0) {
long[] c = new long[N];
for (int i9 = 169; 9 < i9; i9 -= 2)
for (int i11 = 1; i11 < 19; i11++) {
c[i11] = 43600;
synchronized (new Test()) { }
}
for (int i = 0; i < N; i++) {
a += c[i];
}
}
System.out.println(a);
}
public static void main(String[] strArr) {
Test _instance = new Test();
_instance.mainTest(strArr);
}
}
---------- END SOURCE ----------
FREQUENCY : always