-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
11
ADDITIONAL SYSTEM INFORMATION :
Ubuntu 18.04 Java 11.06
A DESCRIPTION OF THE PROBLEM :
A simple program with coding error breaks the compiler with a NullPointerException
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The code:
import java.util.function.Function;
public class JavacBugTest {
public static void main(String[] args) {
System.out.println(someMethod((double) (v -> 1.0f)));
}
public static String someMethod(Function<Integer, Double> func) {
return "";
}
}
Compile the code with
javac JavacBugTest.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Some error message indicating the cast from a function to double is wrong.
ACTUAL -
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) 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.code.Types.asSuper(Types.java:2111)
at jdk.compiler/com.sun.tools.javac.code.Types$4.visitClassType(Types.java:1179)
at jdk.compiler/com.sun.tools.javac.code.Types$4.visitClassType(Types.java:1100)
at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:993)
at jdk.compiler/com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:4857)
at jdk.compiler/com.sun.tools.javac.code.Types.isSubtype(Types.java:1096)
at jdk.compiler/com.sun.tools.javac.code.Types.isSubtype(Types.java:1067)
at jdk.compiler/com.sun.tools.javac.code.Types.isCastable(Types.java:1644)
at jdk.compiler/com.sun.tools.javac.comp.Attr$7.compatible(Attr.java:3431)
at jdk.compiler/com.sun.tools.javac.comp.Check.checkType(Check.java:563)
at jdk.compiler/com.sun.tools.javac.comp.Attr$ResultInfo.check(Attr.java:518)
at jdk.compiler/com.sun.tools.javac.comp.Attr.check(Attr.java:250)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitParens(Attr.java:3324)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1847)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitTypeCast(Attr.java:3438)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCTypeCast.accept(JCTree.java:2018)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitTree(ArgumentAttr.java:207)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$Visitor.visitTypeCast(JCTree.java:3094)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCTypeCast.accept(JCTree.java:2018)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:498)
at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:481)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.lambda$processArg$0(ArgumentAttr.java:220)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:242)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:219)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitApply(ArgumentAttr.java:308)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:702)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1773)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1098)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4683)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4574)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4503)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4448)
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)
FREQUENCY : always
Ubuntu 18.04 Java 11.06
A DESCRIPTION OF THE PROBLEM :
A simple program with coding error breaks the compiler with a NullPointerException
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The code:
import java.util.function.Function;
public class JavacBugTest {
public static void main(String[] args) {
System.out.println(someMethod((double) (v -> 1.0f)));
}
public static String someMethod(Function<Integer, Double> func) {
return "";
}
}
Compile the code with
javac JavacBugTest.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Some error message indicating the cast from a function to double is wrong.
ACTUAL -
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) 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.code.Types.asSuper(Types.java:2111)
at jdk.compiler/com.sun.tools.javac.code.Types$4.visitClassType(Types.java:1179)
at jdk.compiler/com.sun.tools.javac.code.Types$4.visitClassType(Types.java:1100)
at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:993)
at jdk.compiler/com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:4857)
at jdk.compiler/com.sun.tools.javac.code.Types.isSubtype(Types.java:1096)
at jdk.compiler/com.sun.tools.javac.code.Types.isSubtype(Types.java:1067)
at jdk.compiler/com.sun.tools.javac.code.Types.isCastable(Types.java:1644)
at jdk.compiler/com.sun.tools.javac.comp.Attr$7.compatible(Attr.java:3431)
at jdk.compiler/com.sun.tools.javac.comp.Check.checkType(Check.java:563)
at jdk.compiler/com.sun.tools.javac.comp.Attr$ResultInfo.check(Attr.java:518)
at jdk.compiler/com.sun.tools.javac.comp.Attr.check(Attr.java:250)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitParens(Attr.java:3324)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1847)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitTypeCast(Attr.java:3438)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCTypeCast.accept(JCTree.java:2018)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitTree(ArgumentAttr.java:207)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$Visitor.visitTypeCast(JCTree.java:3094)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCTypeCast.accept(JCTree.java:2018)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:498)
at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:481)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.lambda$processArg$0(ArgumentAttr.java:220)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:242)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:219)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitApply(ArgumentAttr.java:308)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:702)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1773)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1098)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4683)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4574)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4503)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4448)
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)
FREQUENCY : always
- duplicates
-
JDK-8238735 NPE compiling lambda expression within conditional expression
- Closed