Integrated: 8364987: javac fails with an exception when looking for diamond creation
Jan Lahoda
jlahoda at openjdk.org
Mon Aug 11 10:32:15 UTC 2025
On Thu, 7 Aug 2025 11:23:22 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> Consider code like:
>
> $ cat /tmp/Test.java
> public class Test {
> void t() {
> L<Object> l = new L<Test>();
> }
> static class L<T> {}
> }
>
>
> Note the code is invalid - `L<Test>` is not assignable to `L<Object>`. The type of `L<Test>` is erroneous in the AST. This may crash with an exception when searching for diamond rewrites:
>
> $ javac -XDfind=diamond -XDshould-stop.at=FLOW -XDdev /tmp/Test.java
> /tmp/Test.java:3: error: incompatible types: L<Test> cannot be converted to L<Object>
> L<Object> l = new L<Test>();
> ^
> 1 error
> An exception has occurred in the compiler (25-internal). 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: L<Object> l = new L<Test>():java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Type.isPartial()" because "s" is null
> jdk.compiler/com.sun.tools.javac.code.Types$5.visitClassType(Types.java:1399)
> jdk.compiler/com.sun.tools.javac.code.Types$5.visitClassType(Types.java:1351)
> jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:1052)
> jdk.compiler/com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:4936)
> jdk.compiler/com.sun.tools.javac.code.Types.isSameType(Types.java:1343)
> jdk.compiler/com.sun.tools.javac.comp.Analyzer$DiamondInitializer.process(Analyzer.java:268)
> 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:1412)
> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1380)
> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:968)
> jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
> jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
> jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
> jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)
> at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:162)
> at jdk....
This pull request has now been integrated.
Changeset: 8b5bb013
Author: Jan Lahoda <jlahoda at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/8b5bb013557478c9ceb49f94f22600d5901f4eee
Stats: 41 lines in 2 files changed: 39 ins; 0 del; 2 mod
8364987: javac fails with an exception when looking for diamond creation
Reviewed-by: vromero
-------------
PR: https://git.openjdk.org/jdk/pull/26675
More information about the compiler-dev
mailing list