JDK-8073221 : NullPointerException during compilation
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u31
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2015-02-12
  • Updated: 2015-10-29
  • Resolved: 2015-10-29
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
The compiler throws an NPE instead of reporting a compiler error

REGRESSION.  Last worked in version 7u67

ADDITIONAL REGRESSION INFORMATION: 
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the attached java file with javac

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Example.java:4: error: unexpected type
        static <A extends String[]> void f(A x) { }
                                ^
  required: class
  found:    String[]
1 error
ACTUAL -
An exception has occurred in the compiler (1.8.0_31). 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.lub(Types.java:3562)
        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:1136)
        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.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 ----------
class Example {
	{ f(g(null)); }

	static <A extends String[]> void f(A x) { }

	static <S> S g(S s) { return s; }
}
---------- END SOURCE ----------


Comments
Closing this as duplicate of JDK-8057800 and fixed in JDK 8u40 b15 and JDK 9 b 37.
18-02-2015

Thanks for pointing towards this. Rechecked and could confirm that this is not reproducible with JDK 9 ea (b49, and b50) as well.
18-02-2015

You seem to have a discrepancy between javac version and java version - i.e. java says 1.9.0 while javac says 1.8.0_25 (this is what your stack trace says, at least).
17-02-2015

Not sure, but I could still see this with the latest JDK 9ea build 50: ------------------------------------------------------------------------------------------------------------------------------------------------------- >java -version java version "1.9.0-ea" Java(TM) SE Runtime Environment (build 1.9.0-ea-b50) Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b50, mixed mode) >javac Example.java An exception has occurred in the compiler (1.8.0_25). Please file a bug at the J ava Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnosti c in your report. Thank you. java.lang.NullPointerException at com.sun.tools.javac.code.Types.lub(Types.java:3562) at com.sun.tools.javac.code.Types.lub(Types.java:3520) at com.sun.tools.javac.comp.Infer.getParameterizedSupers(Infer.java:624) -------------------------------------------------------------------------------------------------------------------------------------------------
17-02-2015

I cannot reproduce with latest JDK 9. This is a duplicate of JDK-8057800.
16-02-2015

This issue is reproducible with JDK 8u31 and JDK 9 ea build 49. However, with JDK 7u76 and 8u40 ea b23 the test compiles fine as expected.
16-02-2015