-
Bug
-
Resolution: Fixed
-
P3
-
hs24, hs25
-
windows_7
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8021926 | 8 | Vladimir Kozlov | P3 | Resolved | Fixed | b101 |
JDK-8021715 | 7u60 | Vladimir Kozlov | P3 | Resolved | Fixed | b01 |
JDK-8021500 | 7u51 | Vladimir Kozlov | P3 | Resolved | Fixed | b01 |
JDK-8021452 | 7u45 | Vladimir Kozlov | P3 | Closed | Fixed | b05 |
JDK-8021061 | 7u40 | Vladimir Kozlov | P3 | Closed | Fixed | b35 |
JDK-8020482 | hs25 | Vladimir Kozlov | P3 | Resolved | Fixed | b43 |
JDK-8020560 | hs24 | Vladimir Kozlov | P3 | Closed | Fixed | b54 |
java version " 1.7.0_25 "
Java(TM) SE Runtime Environment (build 1.7.0_25_b16)
Java Hotspot(TM) 64-bit Server VM (build 23.25-b01, mixed mode)
FULL OS VERSION :
Windows 7 64-bit
EXTRA RELEVANT SYSTEM CONFIGURATION :
No additional configuration needed
A DESCRIPTION OF THE PROBLEM :
The attached sample program calls a method 10'000 times without changing any border conditions. As soon as the method gets compiled, the result of that method returns null instead of a instance.
Please note that the attached sample was stripped down a lot and multiple coding standards were violated to make the sample code as small as possible.
THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No
THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try
REGRESSION. Last worked in version 6u45
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) compile the sample java program
2) run it with the java interpreter -> run through
3) run it with the jit enabled -> returned method value is null and it throws an exception
EXPECTED VERSUS ACTUAL BEHAVIOR :
I would expect that the program never throws an excpetion
ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error messages
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.ArrayList;
import java.util.List;
public class TestJITError {
public static class NamedObject {
public int id;
public String name;
public NamedObject(int id, String name) {
this.id = id;
this.name = name;
}
}
public static class NamedObjectList {
public List<NamedObject> namedObjectList = new ArrayList<NamedObject>();
public NamedObject getBest(int id) {
NamedObject bestObject = null;
for (NamedObject o : namedObjectList) {
bestObject = id==o.id ? getBetter(bestObject, o) : bestObject;
}
return bestObject != null ? bestObject : null;
}
private static NamedObject getBetter(NamedObject p1, NamedObject p2) {
return p1 == null ? p2 : (p2 == null) ? p1 : p2.name.compareTo(p1.name)>=0 ? p2 : p1;
}
}
public static void main(String[] args) {
// setup
NamedObjectList b = new NamedObjectList();
for (int i = 0; i < 10000; i++) {
b.namedObjectList.add(new NamedObject(1, " 2012-12-31 " ));
}
b.namedObjectList.add(new NamedObject(2, " 2013-12-31 " ));
// execution
for (int i = 0; i < 100000; i++) {
NamedObject x = b.getBest(2);
// test
if (x == null) {
throw new RuntimeException( " x should never be null here!! (i= " + i + " ) " );
}
}
System.out.println( " finished " );
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Refactoring of the java code will make it behave correctly.
- backported by
-
JDK-8020482 Different execution plan when using JIT vs interpreter
- Resolved
-
JDK-8021500 Different execution plan when using JIT vs interpreter
- Resolved
-
JDK-8021715 Different execution plan when using JIT vs interpreter
- Resolved
-
JDK-8021926 Different execution plan when using JIT vs interpreter
- Resolved
-
JDK-8020560 Different execution plan when using JIT vs interpreter
- Closed
-
JDK-8021061 Different execution plan when using JIT vs interpreter
- Closed
-
JDK-8021452 Different execution plan when using JIT vs interpreter
- Closed