Duplicate :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux A DESCRIPTION OF THE PROBLEM : Following code crashes compiler. It's kind of weird, and it's v. easy to find workaround - it suffices to introduce local variable or replace anonymous class with lambda expression - so it's not a real problem, but it used to work in 1.8.0_05 version REGRESSION. Last worked in version 8u5 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : javac Test.java EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - compiles ACTUAL - An exception has occurred in the compiler (1.8.0_25). 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: Value of x -1 ERROR MESSAGES/STACK TRACES THAT OCCUR : An exception has occurred in the compiler (1.8.0_25). 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: Value of x -1 at com.sun.tools.javac.util.Assert.error(Assert.java:133) at com.sun.tools.javac.util.Assert.check(Assert.java:94) at com.sun.tools.javac.util.Bits.incl(Bits.java:186) at com.sun.tools.javac.comp.Flow$AssignAnalyzer.checkInit(Flow.java:2510) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.checkInit(Flow.java:1586) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitIdent(Flow.java:2381) at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2011) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:398) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1376) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExpr(Flow.java:1627) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExprs(Flow.java:1639) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitApply(Flow.java:2236) at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:398) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1376) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExpr(Flow.java:1627) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitLambda(Flow.java:2261) at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:398) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1376) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExpr(Flow.java:1627) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExprs(Flow.java:1639) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitApply(Flow.java:2236) at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:398) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1376) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.analyzeTree(Flow.java:2423) at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.analyzeTree(Flow.java:2406) at com.sun.tools.javac.comp.Flow.analyzeLambdaThrownTypes(Flow.java:250) at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2423) at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607) at com.sun.tools.javac.comp.DeferredAttr$2.complete(DeferredAttr.java:284) at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:245) at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:232) at com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:993) at com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:826) at com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:731) at com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:835) at com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:162) at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:564) at com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:601) at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3809) at com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3615) at com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3522) at com.sun.tools.javac.comp.Attr.checkMethodId(Attr.java:3501) at com.sun.tools.javac.comp.Attr.checkId(Attr.java:3488) at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:3237) at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2011) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607) at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1843) at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607) at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:656) at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1611) at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1296) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:676) at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:692) at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1142) at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:676) at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1035) at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:676) at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4342) at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4252) at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4181) at com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:892) at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:676) at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:2162) at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1516) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607) at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:649) at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1093) at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:676) at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:692) at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1142) at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:676) at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1035) at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:676) at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4342) at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4252) at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4181) at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4156) at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1248) 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) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public class Test { public interface Throwing<Y extends Exception> { void canThrow() throws Y; } public static <Y extends Exception> void wrap(Throwing<Y> action) { } public static void invoke(String a) { Runnable r = new Runnable() { @Override public void run() { wrap(() -> System.out.println(a)); } }; } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : 1. make Runnable in Test inner class instead of anonymous 2. introduce local variable in run method 3. replace inner class with lambda expression 4. remove parametricity from wrap method (eg. public static void wrap(Throwing<RuntimeException>
|