FULL PRODUCT VERSION :
Java 8 update 144
ADDITIONAL OS VERSION INFORMATION :
Windows 7
Windows 10
A DESCRIPTION OF THE PROBLEM :
The bug is inconsistent - usually takes 3-8 launches before bug occurs.
The bug only occurs when using the -XX+UseG1GC vm argument.
The bug doen't occur when using both -XX:+UseG1GC and -Xcomp
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Launch the program in the "Source code" section until the bug reveals itself.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
"This should not print" should not print to the console, since cellSize_m is final and initially set to 20 via parameter value, not the value 0. If it does print, "Incrementing cellSize_m" should print 1 to reflect consistency with a final primitive variable across scopes.
ACTUAL -
"This should not print" prints to the console, while "Incrementing cellSize_m" shows the value 21
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
class BugDemo {
public static void main(String[] args) {
fillArray(20);
}
public static void fillArray(double cellSize) {
final double cellSize_m = cellSize;
Integer[] hemispheres = new Integer[565504];
for (int i = 0; i < 565504; i++) {
hemispheres[i] = i;
if (cellSize_m == 0) {
System.out.println("This should not print. [Iteration: " + i + "] [cellSize_m: " + cellSize_m+"]);
}
}
System.out.println("Incrementing cellSize_m: " + (cellSize_m + 1));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Ensure methods are compiled on first execution via the -Xcomp vm argument.
SUPPORT :
YES
Java 8 update 144
ADDITIONAL OS VERSION INFORMATION :
Windows 7
Windows 10
A DESCRIPTION OF THE PROBLEM :
The bug is inconsistent - usually takes 3-8 launches before bug occurs.
The bug only occurs when using the -XX+UseG1GC vm argument.
The bug doen't occur when using both -XX:+UseG1GC and -Xcomp
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Launch the program in the "Source code" section until the bug reveals itself.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
"This should not print" should not print to the console, since cellSize_m is final and initially set to 20 via parameter value, not the value 0. If it does print, "Incrementing cellSize_m" should print 1 to reflect consistency with a final primitive variable across scopes.
ACTUAL -
"This should not print" prints to the console, while "Incrementing cellSize_m" shows the value 21
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
class BugDemo {
public static void main(String[] args) {
fillArray(20);
}
public static void fillArray(double cellSize) {
final double cellSize_m = cellSize;
Integer[] hemispheres = new Integer[565504];
for (int i = 0; i < 565504; i++) {
hemispheres[i] = i;
if (cellSize_m == 0) {
System.out.println("This should not print. [Iteration: " + i + "] [cellSize_m: " + cellSize_m+"]);
}
}
System.out.println("Incrementing cellSize_m: " + (cellSize_m + 1));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Ensure methods are compiled on first execution via the -Xcomp vm argument.
SUPPORT :
YES
- duplicates
-
JDK-8186112 Using G1 Garbage Collector causes in use variable to be cleared
-
- Closed
-