JDK-8067849 : NPE in com.sun.tools.javac.comp.TransTypes.visitVarDef
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u20,8u25
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2014-12-17
  • Updated: 2015-02-09
  • Resolved: 2015-02-09
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 9
9Resolved
Related Reports
Duplicate :  
Relates :  
Description
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 :
Darwin lappy-of-trogdor.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
NullPointerException

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac Test.java

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Either compile or return an error.
ACTUAL -
Exception during compilation.

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.NullPointerException
	at com.sun.tools.javac.comp.TransTypes.visitVarDef(TransTypes.java:548)
	at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
	at com.sun.tools.javac.comp.TransTypes.visitLambda(TransTypes.java:588)
	at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:490)
	at com.sun.tools.javac.comp.TransTypes.translateArgs(TransTypes.java:213)
	at com.sun.tools.javac.comp.TransTypes.visitApply(TransTypes.java:682)
	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:490)
	at com.sun.tools.javac.comp.TransTypes.translateArgs(TransTypes.java:213)
	at com.sun.tools.javac.comp.TransTypes.visitApply(TransTypes.java:682)
	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:490)
	at com.sun.tools.javac.comp.TransTypes.visitReturn(TransTypes.java:649)
	at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1384)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
	at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:162)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:490)
	at com.sun.tools.javac.comp.TransTypes.visitMethodDef(TransTypes.java:525)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
	at com.sun.tools.javac.tree.TreeTranslator.visitClassDef(TreeTranslator.java:134)
	at com.sun.tools.javac.comp.TransTypes.translateClass(TransTypes.java:1007)
	at com.sun.tools.javac.comp.TransTypes.visitClassDef(TransTypes.java:511)
	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:490)
	at com.sun.tools.javac.comp.TransTypes.translateTopLevelClass(TransTypes.java:1035)
	at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1486)
	at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1356)
	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.stream.Collectors;
import java.util.stream.Stream;

public class Test {
    @Override public int hashCode() {
        return Stream.empty()
            .map(Object::hashCode)
            .collect(Collectors.reducing(0, (a, b) -> 59 * a + b));
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Avoid using a stream for this case.


Comments
Seems that part of the AST remained unattributed because the parameter is considered to be a stuck expression (and was not unstucked) - that appears to be similar to be basically the same as JDK-8044546.
09-02-2015

Seems that this was fixed by the fix of JDK-8044546. Investigation on what exactly happens may still be in order (+introducing a test if appropriate).
05-01-2015

Could reproduce this issue with JDK 8u20 and 8u25. JDK 8u40 and 9ea compiled fine.
18-12-2014