A DESCRIPTION OF THE PROBLEM : Running one particular test suite of Eclipse (component JDT/UI) may throw lots of NullPointerExceptions in code that provably provides a valid, non-null value. While originally detected in JDK 23, the bug still exists in JDK 24. The same has already been submitted as https://bugs.openjdk.org/browse/JDK-8349660, which, however, stalled due to lack of information. Since recent development in Eclipse influenced the occurrence of the bug I prepared a stable git branch that reproduces the problem, see Steps to Reproduce. The following github issues discuss the problem: * https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1639 * https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3385 * https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/2142 The method where NPE occurs is https://github.com/eclipse-jdt/eclipse.jdt.core/blob/ee35373d90b32a90abcd9c2427b2319b22279407/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java#L272 During initial analysis I found that the method must be compiled twice for the bug to occur, but I lost any detailed logs from this analysis. REGRESSION : Last worked in version 21.0.6 This avoids the bug: * -XX:CompileCommand=exclude,org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer::getExtendedRange Also passing this helped: * -XX:+UnlockDiagnosticVMOptions -XX:-ReduceAllocationMerges ACTUAL - Many Errors are reported and several result files in org.eclipse.jdt.ui.tests/target/surefire-reports/ will show exceptions like this: <error message="Cannot invoke "org.eclipse.jdt.core.dom.rewrite.TargetSourceRangeComputer$SourceRange.getStartPosition()" because "range" is null" type="java.lang.NullPointerException"><![CDATA[java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.core.dom.rewrite.TargetSourceRangeComputer$SourceRange.getStartPosition()" because "range" is null at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.getExtendedEnd(ASTRewriteAnalyzer.java:264) ...
|