United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6478991 C1 NullCheckEliminator yields incorrect exceptions
JDK-6478991 : C1 NullCheckEliminator yields incorrect exceptions

Details
Type:
Bug
Submit Date:
2006-10-05
Status:
Closed
Updated Date:
2013-04-24
Project Name:
JDK
Resolved Date:
2011-09-30
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
hs22 (b01)

Related Reports
Backport:
Backport:

Sub Tasks

Description
Bug report from Christian Wimmer of the C1 collaborative research project:

While analyzing the NullCheckEliminator for the object inlining work, I
found a possible problem where necessary explicit null checks are
eliminated. The attached java class illustrates the problem: An explicit
null check is folded into a later field load, but between the two
instructions there is a class cast that fails. Therefore, the class cast
exception is thrown before the null check is performed. I think that the
order of the exceptions must be preserved, so this behavior is not allowed.

The null check eliminator contains a NEEDS_CLEANUP-comment that states
exactly this, so you possibly already know about this.


Example: If you run the attached class in the interpreter using

  java -Xint NullCheckTest
  
a NullPointerException is thrown. When the method is compiled using

  java -Xcomp -XX:CompileOnly=NullCheckTest.test NullCheckTest
  
a ClassCastException is thrown.

                                    

Comments
EVALUATION

6478991: C1 NullCheckEliminator yields incorrect exceptions
Reviewed-by: iveresov

checkcast can trap so don't allow explicit null checks to be folded into
instructions that follow it.  Tested with new test case.
                                     
2011-03-28
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/15559220ce79
                                     
2011-07-06
EVALUATION

6478991: C1 NullCheckEliminator yields incorrect exceptions
Reviewed-by: twisti, iveresov

checkcast can trap so don't allow explicit null checks to be folded into
instructions that follow it. Tested with new test case.
                                     
2011-07-07
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/15559220ce79
                                     
2011-07-07
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/15559220ce79
                                     
2011-07-08



Hardware and Software, Engineered to Work Together