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.
|