-
Bug
-
Resolution: Fixed
-
P3
-
8-repo-lambda
-
team
-
x86
-
linux
FULL PRODUCT VERSION :
openjdk version "1.8.0-ea"
OpenJDK Runtime Environment (build 1.8.0-ea-lambda-nightly-h219-20120726-b50-b00)
OpenJDK 64-Bit Server VM (build 24.0-b16, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux donbot 2.6.38-15-generic #64-Ubuntu SMP Fri Jul 6 18:51:28 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
I tried to use a lambda with a single argument that had a try/catch block inside of it. The code generated a compiler error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I run javac on my source.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should have cleanly compiled.
ACTUAL -
The compiler fails to compile and throws an AssertionError.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.8.0-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.AssertionError
at com.sun.tools.javac.util.Assert.error(Assert.java:126)
at com.sun.tools.javac.util.Assert.check(Assert.java:45)
at com.sun.tools.javac.code.Scope.leave(Scope.java:150)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2294)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1534)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.DeferredAttr$2.doAttr(DeferredAttr.java:188)
at com.sun.tools.javac.comp.DeferredAttr.attribDeferred(DeferredAttr.java:246)
at com.sun.tools.javac.comp.Resolve.checkRawArgumentsAcceptable(Resolve.java:698)
at com.sun.tools.javac.comp.Resolve.checkRawArgumentsAcceptable(Resolve.java:616)
at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:511)
at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1068)
at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:1497)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1455)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1418)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1398)
at com.sun.tools.javac.comp.Resolve.findConstructor(Resolve.java:2489)
at com.sun.tools.javac.comp.Resolve.resolveConstructor(Resolve.java:2117)
at com.sun.tools.javac.comp.Resolve.resolveConstructor(Resolve.java:2100)
at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:1956)
at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1444)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.DeferredAttr$2.doAttr(DeferredAttr.java:188)
at com.sun.tools.javac.comp.DeferredAttr.attribDeferred(DeferredAttr.java:246)
at com.sun.tools.javac.comp.Resolve.checkRawArgumentsAcceptable(Resolve.java:698)
at com.sun.tools.javac.comp.Resolve.checkRawArgumentsAcceptable(Resolve.java:616)
at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:511)
at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1068)
at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:1497)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1455)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1418)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1398)
at com.sun.tools.javac.comp.Resolve.findFun(Resolve.java:1521)
at com.sun.tools.javac.comp.Resolve.resolveMethod(Resolve.java:1958)
at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:2552)
at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1918)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1745)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1393)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:576)
at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1492)
at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1224)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:596)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:612)
at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1038)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:837)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:596)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:954)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:721)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:596)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:3762)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:3681)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:3615)
at com.sun.tools.javac.comp.Attr.attrib(Attr.java:3589)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1206)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:892)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:851)
at com.sun.tools.javac.main.Main.compile(Main.java:441)
at com.sun.tools.javac.main.Main.compile(Main.java:358)
at com.sun.tools.javac.main.Main.compile(Main.java:347)
at com.sun.tools.javac.main.Main.compile(Main.java:338)
at com.sun.tools.javac.Main.compile(Main.java:76)
at com.sun.tools.javac.Main.main(Main.java:61)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.functions.DoubleMapper;
public class Error {
public static void main(String[] args) {
failure(new Wrapper((x) -> {
try {
return Double.valueOf(args[0]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Unknown token " + args[0]);
}
}));
}
public static void failure(Wrapper wrapped) {
System.out.println("The result: " + wrapped.apply());
}
public static class Wrapper {
public final DoubleMapper<String> f;
public Wrapper(DoubleMapper<String> f) {
this.f = f;
}
public double apply() {
return f.map("123");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
If I extract the try/catch into a method, the compiler no longer has an issue. If I am able to change the code to use a lambda that doesn't require an argument (such as a Factory), it also compiles. If I don't use the try/catch inside the lambda, again, it compiles.
openjdk version "1.8.0-ea"
OpenJDK Runtime Environment (build 1.8.0-ea-lambda-nightly-h219-20120726-b50-b00)
OpenJDK 64-Bit Server VM (build 24.0-b16, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux donbot 2.6.38-15-generic #64-Ubuntu SMP Fri Jul 6 18:51:28 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
I tried to use a lambda with a single argument that had a try/catch block inside of it. The code generated a compiler error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I run javac on my source.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should have cleanly compiled.
ACTUAL -
The compiler fails to compile and throws an AssertionError.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.8.0-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.AssertionError
at com.sun.tools.javac.util.Assert.error(Assert.java:126)
at com.sun.tools.javac.util.Assert.check(Assert.java:45)
at com.sun.tools.javac.code.Scope.leave(Scope.java:150)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2294)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1534)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.DeferredAttr$2.doAttr(DeferredAttr.java:188)
at com.sun.tools.javac.comp.DeferredAttr.attribDeferred(DeferredAttr.java:246)
at com.sun.tools.javac.comp.Resolve.checkRawArgumentsAcceptable(Resolve.java:698)
at com.sun.tools.javac.comp.Resolve.checkRawArgumentsAcceptable(Resolve.java:616)
at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:511)
at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1068)
at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:1497)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1455)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1418)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1398)
at com.sun.tools.javac.comp.Resolve.findConstructor(Resolve.java:2489)
at com.sun.tools.javac.comp.Resolve.resolveConstructor(Resolve.java:2117)
at com.sun.tools.javac.comp.Resolve.resolveConstructor(Resolve.java:2100)
at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:1956)
at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1444)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.DeferredAttr$2.doAttr(DeferredAttr.java:188)
at com.sun.tools.javac.comp.DeferredAttr.attribDeferred(DeferredAttr.java:246)
at com.sun.tools.javac.comp.Resolve.checkRawArgumentsAcceptable(Resolve.java:698)
at com.sun.tools.javac.comp.Resolve.checkRawArgumentsAcceptable(Resolve.java:616)
at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:511)
at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1068)
at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:1497)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1455)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1418)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1398)
at com.sun.tools.javac.comp.Resolve.findFun(Resolve.java:1521)
at com.sun.tools.javac.comp.Resolve.resolveMethod(Resolve.java:1958)
at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:2552)
at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1918)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1745)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1393)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:576)
at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1492)
at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1224)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:596)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:612)
at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1038)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:837)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:596)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:954)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:721)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:553)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:596)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:3762)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:3681)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:3615)
at com.sun.tools.javac.comp.Attr.attrib(Attr.java:3589)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1206)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:892)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:851)
at com.sun.tools.javac.main.Main.compile(Main.java:441)
at com.sun.tools.javac.main.Main.compile(Main.java:358)
at com.sun.tools.javac.main.Main.compile(Main.java:347)
at com.sun.tools.javac.main.Main.compile(Main.java:338)
at com.sun.tools.javac.Main.compile(Main.java:76)
at com.sun.tools.javac.Main.main(Main.java:61)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.functions.DoubleMapper;
public class Error {
public static void main(String[] args) {
failure(new Wrapper((x) -> {
try {
return Double.valueOf(args[0]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Unknown token " + args[0]);
}
}));
}
public static void failure(Wrapper wrapped) {
System.out.println("The result: " + wrapped.apply());
}
public static class Wrapper {
public final DoubleMapper<String> f;
public Wrapper(DoubleMapper<String> f) {
this.f = f;
}
public double apply() {
return f.map("123");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
If I extract the try/catch into a method, the compiler no longer has an issue. If I am able to change the code to use a lambda that doesn't require an argument (such as a Factory), it also compiles. If I don't use the try/catch inside the lambda, again, it compiles.
- relates to
-
JDK-8145378 Java compiler chrashes when SBT is compiling a Play Framework Application
-
- Closed
-