JDK-8057800 : Method reference with generic type creates NPE when compiling
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u20
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2014-09-06
  • Updated: 2015-06-04
  • Resolved: 2014-10-23
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 8 JDK 9
8u40Fixed 9 b37Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux version 3.13.0-35-generic (buildd@panlong) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014

A DESCRIPTION OF THE PROBLEM :
The java compiler generates a NPE when trying to compile the given source.


ERROR MESSAGES/STACK TRACES THAT OCCUR :
$ javac Bug.java 
An exception has occurred in the compiler (1.8.0_20). 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.code.Types.intersect(Types.java:3381)
        at com.sun.tools.javac.code.Types.lub(Types.java:3600)
        at com.sun.tools.javac.code.Types.lub(Types.java:3520)
        at com.sun.tools.javac.comp.Infer.getParameterizedSupers(Infer.java:624)
        at com.sun.tools.javac.comp.Infer.access$200(Infer.java:64)
        at com.sun.tools.javac.comp.Infer$IncorporationStep$7.apply(Infer.java:785)
        at com.sun.tools.javac.comp.Infer.checkWithinBounds(Infer.java:551)
        at com.sun.tools.javac.comp.Infer$GraphSolver.solve(Infer.java:1576)
        at com.sun.tools.javac.comp.Infer$InferenceContext.solve(Infer.java:2198)
        at com.sun.tools.javac.comp.Infer$InferenceContext.solve(Infer.java:2190)
        at com.sun.tools.javac.comp.Infer$InferenceContext.solve(Infer.java:2205)
        at com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:186)
        at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:564)
        at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1431)
        at com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1618)
        at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1689)
        at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1662)
        at com.sun.tools.javac.comp.Resolve.findFun(Resolve.java:1822)
        at com.sun.tools.javac.comp.Resolve$8.doLookup(Resolve.java:2383)
        at com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3074)
        at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3325)
        at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3310)
        at com.sun.tools.javac.comp.Resolve.resolveMethod(Resolve.java:2379)
        at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:3170)
        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.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 Bug {
	public <T> void foo(java.util.Comparator<? super T> comparator) {
	}
	public <C extends Comparable<? super C>> void foo() {
		foo(C::compareTo);
	}
}
---------- END SOURCE ----------