JDK-8006140 : Javac NPE compiling Lambda expression on initialization expression of static field in interface
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8,8-repo-lambda
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-01-12
  • Updated: 2013-06-06
  • Resolved: 2013-05-14
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
8 b91Fixed
Related Reports
Blocks :  
Duplicate :  
Duplicate :  
Relates :  
Description
Javac thows an exception compiling a lambda expression.  
Source code of a test example is attached, the interesting part is:

    public static final Comparator<ChronoLocalDate1> DATE_COMPARATOR3 =
            ( date1,  date2) -> 0;

java.lang.NullPointerException
	at com.sun.tools.javac.jvm.Code.emitop0(Code.java:538)
	at com.sun.tools.javac.jvm.Items$SelfItem.load(Items.java:367)
	at com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:912)
	at com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1746)
	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1391)
	at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:893)
	at com.sun.tools.javac.jvm.Gen.visitAssign(Gen.java:1844)
	at com.sun.tools.javac.tree.JCTree$JCAssign.accept(JCTree.java:1586)
	at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:893)
	at com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1694)
	at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1222)
	at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:683)
	at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:718)
	at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:704)
	at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:755)
	at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1090)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:835)
	at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:683)
	at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:718)
	at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:968)
	at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:941)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:723)
	at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:683)
	at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2310)
	at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:751)
	at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1545)
	at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1509)
	at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:907)
	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:866)
	at com.sun.tools.javac.main.Main.compile(Main.java:506)
	at com.sun.tools.javac.main.Main.compile(Main.java:365)
	at com.sun.tools.javac.main.Main.compile(Main.java:354)
	at com.sun.tools.javac.main.Main.compile(Main.java:345)
	at com.sun.tools.javac.Main.compile(Main.java:76)
	at com.sun.tools.javac.Main.main(Main.java:61)

The source compiles fine without the lambda expression.


It occurs in b67 and b72 of the JDK 8 EA builds and in recent private builds.
Comments
verified in jdk8 b92
06-06-2013

The following JCK Compiler tests still fail (from JDK-8006680): lang/INTF/intf018/intf01802m01/intf01802m01.html lang/INTF/intf018/intf01802m11/intf01802m11.html lang/INTF/intf018/intf01803m01/intf01803m01.html lang/INTF/intf018/intf01803m11/intf01803m11.html
25-04-2013

Simple test case: interface T40 { interface I { int m(); } public static final I fld = () -> 5; }
18-04-2013