JDK-8129589 : Javac fails with assertion error when lambda types are not specified
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u40,8u45
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2015-06-18
  • Updated: 2017-03-23
  • Resolved: 2015-10-30
Related Reports
Duplicate :  
Duplicate :  
Description
FULL PRODUCT VERSION :
Reproduced on

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

openjdk version "1.8.0_45-internal"
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7600]

A DESCRIPTION OF THE PROBLEM :
When compiling the supplied source file, Javac fails with assertion error

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the supplied CompilationBug.java file

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation
ACTUAL -
Compiler crashes with AssertionError

ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.8.0_40). 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: attribution shouldn't be happening here
	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.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:591)
	at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:479)
	at com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:177)
	at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:567)
	at com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:604)
	at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3797)
	at com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3584)
	at com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3491)
	at com.sun.tools.javac.comp.Attr.checkMethodId(Attr.java:3470)
	at com.sun.tools.javac.comp.Attr.checkId(Attr.java:3457)
	at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3339)
	at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1806)
	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:386)
	at com.sun.tools.javac.comp.DeferredAttr$2.complete(DeferredAttr.java:279)
	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:1003)
	at com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:829)
	at com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:734)
	at com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:838)
	at com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:162)
	at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:567)
	at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1441)
	at com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1628)
	at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1699)
	at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1672)
	at com.sun.tools.javac.comp.Resolve$9.doLookup(Resolve.java:2425)
	at com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3084)
	at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3335)
	at com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2422)
	at com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2416)
	at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3364)
	at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3246)
	at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1806)
	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.visitReturn(Attr.java:1667)
	at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1384)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
	at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:651)
	at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1105)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
	at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:994)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
	at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4330)
	at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4240)
	at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4169)
	at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4144)
	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 ----------
import java.util.Optional;
import java.util.stream.Stream;

public class CompilationBug {
    static class Box<A> {
        A a;
        
        Box(A obj) {
            this.a = obj;
        }

        static <A> Optional<A> asOptional(Box<A> box) {
            return box == null ? Optional.empty() : Optional.of(box.a);  
        }
    }

    public static <T> Optional<T> test(Stream<T> source) {
		return Box.asOptional(source.reduce(null,
				(Box<T> acc, T t) -> acc == null ? new Box<>(t) : acc, 
				(acc1, acc2) -> acc1));
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Specify arguments types in line#20:

(Box<T> acc1, Box<T> acc2) -> acc1));

This way it compiles fine


Comments
Closing this as duplicate of JDK-8069399.
30-10-2015

Closing this as duplicate of JDK-8069399 with fix confirmed in JDK 9 ea build. Confirmation from the submitter: ================================================================================ On 6/24/2015 11:51 AM, ....... wrote: > Hello! > > Yes, it seems that this issue is already resolved for Java 9 EA. > > With best regards, > .............. ================================================================================
24-06-2015

This seems a duplicate of JDK-8068399 with fix in JDK 9. ========================================================================================= 1. Run the attached test case (CompilationBug.java) in Windows 7 and Linux. 2. Checked this with JDK 8u45, 8u60 ea b19, and 9 ea b69. 8u40: FAIL 8u45: FAIL 8u60 ea b19: PASS 9 ea b69: PASS 3. Output with JDK 8u45: $ javac CompilationBug.java An exception has occurred in the compiler (1.8.0_45). 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: attribution shouldn't be happening here 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.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:591) at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:479) at com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:177) at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:567) at com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:604) --------------------------------- --------------------------------- 4. Conclusion: The issue is reproducible as stated by the submitter with JDK 8u40 and 8u45, but it seems resolved in JDK 8u60 and 9 ea. Sent an email to the submitter for confirmation with JDK 8u60 ea and 9 ea latest builds. **************************************************************** On 6/23/2015 8:34 PM, .......... wrote: > Hi ......, > > The bug submitted by you is likely resolved with JDK 8u60 ea and 9 ea. Can you check this with latest builds from: > https://jdk8.java.net/download > https://jdk9.java.net/download > > Request you to confirm back with the status. > > Thank You, > .......... ****************************************************************** =================================================================================================
23-06-2015