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.