Integrated: 8349132: javac Analyzers should handle non-deferrable errors

Jan Lahoda jlahoda at openjdk.org
Thu Feb 6 07:37:18 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...

This pull request has now been integrated.

Changeset: 3cf04dec
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/3cf04dec493d28730d4462257f64ea636f58d7e5
Stats:     155 lines in 3 files changed: 151 ins; 1 del; 3 mod

8349132: javac Analyzers should handle non-deferrable errors

Reviewed-by: abimpoudis

-------------

PR: https://git.openjdk.org/jdk/pull/23387


More information about the compiler-dev mailing list