RFR: 8349132: javac Analyzers should handle non-deferrable errors
Aggelos Biboudis
abimpoudis at openjdk.org
Mon Feb 3 10:40:46 UTC 2025
On Fri, 31 Jan 2025 12:44:32 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> Consider this test script:
>
> $ cat JDK8349132.sh
> mkdir -p JDK-8349132
> cd JDK-8349132
> cat >Utils.java <<EOF
> package test;
> public class Utils {
> public static void run(Task<Param> uat) {}
> }
> interface Task<T> {
> public void run(T t) throws Exception;
> }
> class Param {}
> EOF
> cat >Test.java <<EOF
> package test;
> public class Test {
> private static void test() {
> Utils.run(new Task<Param>() {
> @Override
> public void run(Param parameter) throws Exception {
> }
> });
> }
> }
> EOF
>
> javac -d out Utils.java
> rm out/test/Param.class
> javac -XDfind=diamond -XDshould-stop.at=FLOW -classpath out Test.java
>
>
> It fails with:
>
> $ bash JDK8349132.sh
> Test.java:4: error: cannot find symbol
> Utils.run(new Task<Param>() {
> ^
> symbol: class Param
> location: class Test
> Test.java:6: error: cannot find symbol
> public void run(Param parameter) throws Exception {
> ^
> symbol: class Param
> Test.java:4: error: cannot access Param
> Utils.run(new Task<Param>() {
> ^
> class file for test.Param not found
> 3 errors
> An exception has occurred in the compiler (21.0.5). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
> java.lang.AssertionError: Analyzer error when processing: Utils.run(new Task<Param>(){
>
> () {
> super();
> }
>
> @Override
> public void run(Param parameter) throws Exception {
> }
> });:java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Type.getTypeArguments()" because "com.sun.tools.javac.util.List.get(int).type" is null
> jdk.compiler/com.sun.tools.javac.comp.Analyzer$DiamondInitializer.process(Analyzer.java:258)
> jdk.compiler/com.sun.tools.javac.comp.Analyzer$DiamondInitializer.process(Analyzer.java:228)
> jdk.compiler/com.sun.tools.javac.comp.Analyzer.doAnalysis(Analyzer.java:577)
> jdk.compiler/com.sun.tools.javac.comp.Analyzer$2.flush(Analyzer.java:547)
> jdk.compiler/com.sun.tools.javac.comp.Analyzer.flush(Analyzer.java:591)
> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1425)
> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1393)
> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:976...
Looks good to me. And thanks for the great analysis.
I was wondering, the third error is not coming from the `DiamondInitializer` is seems. It must have been one of the subsequent, right?: `LambdaAnalyzer`, `RedundantTypeArgAnalyzer`, `RedundantLocalVarTypeAnalyzer`, `RedundantLocalVarTypeAnalyzerForEach`.
-------------
Marked as reviewed by abimpoudis (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/23387#pullrequestreview-2589523382
More information about the compiler-dev
mailing list