unexpected type <nulltype> for dummy switch on null

Jan Lahoda jan.lahoda at oracle.com
Mon Jul 19 19:13:57 UTC 2021


Please see:

https://bugs.openjdk.java.net/browse/JDK-8269113


Thanks for the report,

     Jan


On 19. 07. 21 20:06, Brian Goetz wrote:
> To be clear, the correct behavior would be to throw an NPE.  If the 
> code were slightly different:
>
>     case null, default: ...
>
> then the correct behavior would be to print a blank line.
>
> On 7/19/2021 1:00 PM, Anna Kozlova wrote:
>> Hi folks,
>> I got an exception when compile dummy code with latest available build 31
>> void f() {
>>      switch (null) {
>>          case default:
>>              System.out.println(); }
>> }
>>
>> jjava: java.lang.AssertionError: unexpected type: <nulltype>
>> java: at 
>> jdk.compiler/com.sun.tools.javac.tree.TreeMaker.Type(TreeMaker.java:860)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.tree.TreeMaker.VarDef(TreeMaker.java:882)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.comp.TransPatterns.handleSwitch(TransPatterns.java:350)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.comp.TransPatterns.visitSwitch(TransPatterns.java:267)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitch.accept(JCTree.java:1294)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.comp.TransPatterns.visitBlock(TransPatterns.java:642)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1091)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitMethodDef(TreeTranslator.java:150)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.comp.TransPatterns.visitMethodDef(TransPatterns.java:589)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:921)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitClassDef(TreeTranslator.java:139)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.comp.TransPatterns.visitClassDef(TransPatterns.java:669)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:819)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.comp.TransPatterns.translateTopLevelClass(TransPatterns.java:698)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1535)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1408)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
>> java: at 
>> jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
>> java: at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:238)
>>
>> Anna
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210719/c3ff8446/attachment-0001.htm>


More information about the compiler-dev mailing list