javac 11.0.6 NullPointerException when a type param refers to missing type
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Mon Mar 23 12:52:04 UTC 2020
Hi Vitaly,
this is indeed an issue - although I seem to be able to reproduce even
with 8 (tested with both u40 and u211):
An exception has occurred in the compiler (1.8.0_40-ea). Please file a
bug at the Java Developer Connection
(http://java.sun.com/webapps/bugreport) after checking the Bug Parade
for duplicates. Include your program and the following diagnostic in
your report. Thank you.
java.lang.NullPointerException
at com.sun.tools.javac.comp.TransTypes.visitSelect(TransTypes.java:826)
at
com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
at
com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:490)
at com.sun.tools.javac.comp.TransTypes.visitApply(TransTypes.java:666)
at
com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
at
com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:490)
at com.sun.tools.javac.comp.TransTypes.visitExec(TransTypes.java:644)
at
com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1296)
at
com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
at
com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
at
com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:162)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
at
com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:490)
at
com.sun.tools.javac.comp.TransTypes.visitMethodDef(TransTypes.java:525)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
at
com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
at
com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
at
com.sun.tools.javac.tree.TreeTranslator.visitClassDef(TreeTranslator.java:134)
at
com.sun.tools.javac.comp.TransTypes.translateClass(TransTypes.java:1007)
at
com.sun.tools.javac.comp.TransTypes.visitClassDef(TransTypes.java:511)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
at
com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:490)
at
com.sun.tools.javac.comp.TransTypes.translateTopLevelClass(TransTypes.java:1035)
at
com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1486)
at
com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1356)
at
com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.main.Main.compile(Main.java:381)
at com.sun.tools.javac.main.Main.compile(Main.java:370)
at com.sun.tools.javac.main.Main.compile(Main.java:361)
at com.sun.tools.javac.Main.compile(Main.java:56)
at com.sun.tools.javac.Main.main(Main.java:42)
I've filed a new issue - but this I've not marked it as a regression,
because it doesn't seem one, unless I'm missing something.
https://bugs.openjdk.java.net/browse/JDK-8241441
Thanks
Maurizio
On 18/03/2020 23:47, Vitaly Davidovich wrote:
> Hi all,
>
> I'd like to report a bug against javac 11.0.6 (and possibly later, but
> I don't readily have access to newer versions).
>
> To reproduce:
>
> Create the following 3 source files:
>
> ////// A.java
>
> public class A<T extends B<T>> {
>
> public void foo() {}
>
> }
>
> ////// B.java
>
> public class B<T> {}
>
> ////// C.java
>
> public class C {
>
> public static void crashJavaC(A a) {
>
> a.foo(null);
>
> }
>
> }
>
>
> $ javac A.java B.java
>
> $ rm B.java B.class
>
> $ javac C.java
>
> An exception has occurred in the compiler (11.0.6). Please file a bug
> against the Java compiler via the Java bug reporting page
> (http://bugreport.java.com <http://bugreport.java.com/>) after
> checking the Bug Database (http://bugs.java.com
> <http://bugs.java.com/>) for duplicates. Include your program and the
> following diagnostic in your report. Thank you.
>
> java.lang.NullPointerException
>
> at
> jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitSelect(TransTypes.java:811)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2114)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
>
> at
> jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:454)
>
> at
> jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitApply(TransTypes.java:622)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
>
> at
> jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:454)
>
> at
> jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitExec(TransTypes.java:599)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:167)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
>
> at
> jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:454)
>
> at
> jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitMethodDef(TransTypes.java:489)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitClassDef(TreeTranslator.java:139)
>
> at
> jdk.compiler/com.sun.tools.javac.comp.TransTypes.translateClass(TransTypes.java:918)
>
> at
> jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitClassDef(TransTypes.java:475)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:774)
>
> at
> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
>
> at
> jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:454)
>
> at
> jdk.compiler/com.sun.tools.javac.comp.TransTypes.translateTopLevelClass(TransTypes.java:942)
>
> at
> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1553)
>
> at
> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1432)
>
> at
> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
>
> at
> jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
>
> at
> jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
>
> at
> jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
>
> at
> jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
>
>
> If B.java *is* present, we get the expected compilation error:
>
> $ javac C.java
>
> C.java:3: error: method foo in class A<T> cannot be applied to given
> types;
>
> a.foo(null);
>
> ^
>
> required: no arguments
>
> found: <null>
>
> reason: actual and formal argument lists differ in length
>
> where T is a type-variable:
>
> T extends B<T> declared in class A
>
> 1 error
>
>
> The repro is (purposely) contrived. The real case came up when build
> infrastructure prevented the source path of B.java from being observed
> when building C.java.
>
>
> I assume javac shouldn't crash with an NPE, and should instead provide
> a compilation error pointing out that B symbol is not found (or similar).
>
>
> Let me know if you have any questions.
>
>
> Thanks!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20200323/2d187c17/attachment-0001.htm>
More information about the compiler-dev
mailing list