JDK-8148028 : java.lang.NullpointerException at ....javac.jvm.Code.emitop0(Code.java:559)
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u66
  • Priority: P4
  • Status: Closed
  • Resolution: Incomplete
  • OS: linux
  • CPU: x86_64
  • Submitted: 2016-01-10
  • Updated: 2016-01-22
  • Resolved: 2016-01-22
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux freguntu 3.19.0-43-generic #49-Ubuntu SMP Sun Dec 27 19:43:07 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
Home PC

A DESCRIPTION OF THE PROBLEM :
An exception has occurred in the compiler (1.8.0_66). Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) after checking the database for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.NullPointerException
	at com.sun.tools.javac.jvm.Code.emitop0(Code.java:559)
	at com.sun.tools.javac.jvm.Items$SelfItem.load(Items.java:367)
	at com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:965)
	at com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1839)
	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
	at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:946)
	at com.sun.tools.javac.jvm.Gen.visitParens(Gen.java:1974)
	at com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1661)
	at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:946)
	at com.sun.tools.javac.jvm.Gen.visitTypeCast(Gen.java:2261)
	at com.sun.tools.javac.tree.JCTree$JCTypeCast.accept(JCTree.java:1814)
	at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:946)
	at com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:965)
	at com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1839)
	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
	at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:946)
	at com.sun.tools.javac.jvm.Gen.visitAssign(Gen.java:1979)
	at com.sun.tools.javac.tree.JCTree$JCAssign.accept(JCTree.java:1686)
	at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:946)
	at com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1776)
	at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1296)
	at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:736)
	at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:771)
	at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:757)
	at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:808)
	at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1156)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
	at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:736)
	at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:771)
	at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:1030)
	at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:993)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
	at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:736)
	at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2451)
	at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:745)
	at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1572)
	at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1536)
	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)


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
compiled program
ACTUAL -
Nullpointerexception

ERROR MESSAGES/STACK TRACES THAT OCCUR :
see above

REPRODUCIBILITY :
This bug can be reproduced occasionally.

---------- BEGIN SOURCE ----------
This is, unfortunately, impossible.
The compiler is used to compile a generated program, which consists of 1000 of lines of code, with dependencies to other already compiled code, with 10000 of lines.

Without hints from the compiler what it was doing at the point where it crashed, I cannot even dream of isolating the problem.

However, the following may help: The program that produces the code generates local classes inside of methods. Each local class used to have a single method. Now the code generator was changed in such a way that it generates more than one method per local class, and this caused the javac to crash on some files.

The local classes can also occur inside lambdas, I'm not sure if this makes a difference.
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Generate single method per local class. This, apparently helps.


Comments
Forwarding for dev team review... Below information may help... == The program that produces the code generates local classes inside of methods. Each local class used to have a single method. Now the code generator was changed in such a way that it generates more than one method per local class, and this caused the javac to crash on some files. ==
22-01-2016

try with the option -XDverboseCompilePolicy That should print out which source the compiler is compiling when the crash occurs. Reopen when the source is identified (and please attach the problematic source/s).
22-01-2016