JDK-8222750 : missing break value -> NPE in ArgumentAttr$SwitchExpressionType.overloadCheck
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 12,13
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2019-04-18
  • Updated: 2019-06-12
  • Resolved: 2019-06-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 13
13Resolved
Related Reports
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
When a switch expression is used as a method argument, and one of its cases has a missing "break" value, the compiler throws an NPE instead of giving a sensible error message.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to compile the following source code with "javac --enable-preview -source 12"

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
"missing break value" error message on line 3
ACTUAL -
An exception has occurred in the compiler (12.0.1). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (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.ArgumentAttr$SwitchExpressionType.overloadCheck(ArgumentAttr.java:491)
	at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr$ArgumentType.complete(ArgumentAttr.java:364)
	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:338)
	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:324)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1058)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:885)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:773)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:894)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:616)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1561)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1731)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1800)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1774)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve$10.doLookup(Resolve.java:2652)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3291)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3541)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2649)
	at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2643)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3922)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3802)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2189)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2191)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:715)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1860)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1519)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:756)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1307)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1111)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:872)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4884)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4775)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4704)
	at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4649)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1341)
	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)


---------- BEGIN SOURCE ----------
class Test {
	public static void main(String[] args) {
		System.out.println(switch(args.length) { case 0: break; });
	}
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
This bug should be fixed by the patch for: JDK-8223303
12-06-2019

This issue is reproducible in 13 ea b17 also. -sh-4.1$ /scratch/fairoz/JAVA/jdk13/jdk-13-ea+17/bin/javac --enable-preview --release 13 Test.java Note: Test.java uses preview language features. Note: Recompile with -Xlint:preview for details. An exception has occurred in the compiler (13-ea). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://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.NullPointerException at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr$SwitchExpressionType.overloadCheck(ArgumentAttr.java:491) at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr$ArgumentType.complete(ArgumentAttr.java:364) at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:338) at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:324) at jdk.compiler/com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1058) at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:885) at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:773) at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:894) at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:616) at jdk.compiler/com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1561) at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1731) at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1800) at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1774) at jdk.compiler/com.sun.tools.javac.comp.Resolve$10.doLookup(Resolve.java:2652) at jdk.compiler/com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3291) at jdk.compiler/com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3541) at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2649) at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2643) at jdk.compiler/com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3924) at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3804) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2189) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664) at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2193) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:715) at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1862) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1519) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:756) at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1309) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737) at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1113) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:872) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4886) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4777) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4706) at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4651) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1346) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:972) at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:318) at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176) at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57) at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43) printing javac parameters to: /scratch/fairoz/JI/tools/9060289/javac.20190418_230205.args
19-04-2019