Details
Description
FULL PRODUCT VERSION :
java version " 1.8.0-ea "
Java(TM) SE Runtime Environment (build 1.8.0-ea-lambda-nightly-h4816-20130617-b95-b00)
Java HotSpot(TM) Client VM (build 25.0-b34, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Attempting to compile the following (erroneous) Java program throws a NullPointerException in the RichDiagnosticFormatter:
public class Test
{
public static void main(String[] args)
{
Runnable add = (int x) -> (int y) -> x + y;
}
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a file called Test.java containing the following program:
public class Test
{
public static void main(String[] args)
{
Runnable add = (int x) -> (int y) -> x + y;
}
}
2) Run " javac Test.java " .
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect a compiler error saying (in some manner) that the program is erroneous.
ACTUAL -
A NullPointerException is thrown in the RichDiagnosticFormatter.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
at com.sun.tools.javac.util.RichDiagnosticFormatter$ClassNameSimplifier.simplify(RichDiagnosticFormatter.java:299)
at com.sun.tools.javac.util.RichDiagnosticFormatter$RichPrinter.visitClassSymbol(RichDiagnosticFormatter.java:401)
at com.sun.tools.javac.util.RichDiagnosticFormatter$RichPrinter.visitClassSymbol(RichDiagnosticFormatter.java:327)
at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:963)
at com.sun.tools.javac.code.Printer.visit(Printer.java:149)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:196)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:161)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:179)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:161)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:179)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:161)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMeta(BasicDiagnosticFormatter.java:184)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatDiagnostic(BasicDiagnosticFormatter.java:100)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.format(AbstractDiagnosticFormatter.java:117)
at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:113)
at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:68)
at com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:622)
at com.sun.tools.javac.util.Log$DefaultDiagnosticHandler.report(Log.java:600)
at com.sun.tools.javac.util.Log$DeferredDiagnosticHandler.reportDeferredDiagnostics(Log.java:161)
at com.sun.tools.javac.util.Log$DeferredDiagnosticHandler.reportDeferredDiagnostics(Log.java:153)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2402)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1609)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:598)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:616)
at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1081)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:846)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:598)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:643)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:659)
at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1131)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:903)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:598)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:643)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1018)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:772)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:598)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:643)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4229)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4137)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4072)
at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4046)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1224)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:877)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:836)
at com.sun.tools.javac.main.Main.compile(Main.java:517)
at com.sun.tools.javac.main.Main.compile(Main.java:376)
at com.sun.tools.javac.main.Main.compile(Main.java:365)
at com.sun.tools.javac.main.Main.compile(Main.java:356)
at com.sun.tools.javac.Main.compile(Main.java:77)
at com.sun.tools.javac.Main.main(Main.java:62)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test
{
public static void main(String[] args)
{
Runnable add = (int x) -> (int y) -> x + y;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't write daft code in the first place, I suppose :)
java version " 1.8.0-ea "
Java(TM) SE Runtime Environment (build 1.8.0-ea-lambda-nightly-h4816-20130617-b95-b00)
Java HotSpot(TM) Client VM (build 25.0-b34, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Attempting to compile the following (erroneous) Java program throws a NullPointerException in the RichDiagnosticFormatter:
public class Test
{
public static void main(String[] args)
{
Runnable add = (int x) -> (int y) -> x + y;
}
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a file called Test.java containing the following program:
public class Test
{
public static void main(String[] args)
{
Runnable add = (int x) -> (int y) -> x + y;
}
}
2) Run " javac Test.java " .
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect a compiler error saying (in some manner) that the program is erroneous.
ACTUAL -
A NullPointerException is thrown in the RichDiagnosticFormatter.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
at com.sun.tools.javac.util.RichDiagnosticFormatter$ClassNameSimplifier.simplify(RichDiagnosticFormatter.java:299)
at com.sun.tools.javac.util.RichDiagnosticFormatter$RichPrinter.visitClassSymbol(RichDiagnosticFormatter.java:401)
at com.sun.tools.javac.util.RichDiagnosticFormatter$RichPrinter.visitClassSymbol(RichDiagnosticFormatter.java:327)
at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:963)
at com.sun.tools.javac.code.Printer.visit(Printer.java:149)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:196)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:161)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:179)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:161)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:179)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:161)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMeta(BasicDiagnosticFormatter.java:184)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatDiagnostic(BasicDiagnosticFormatter.java:100)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.format(AbstractDiagnosticFormatter.java:117)
at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:113)
at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:68)
at com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:622)
at com.sun.tools.javac.util.Log$DefaultDiagnosticHandler.report(Log.java:600)
at com.sun.tools.javac.util.Log$DeferredDiagnosticHandler.reportDeferredDiagnostics(Log.java:161)
at com.sun.tools.javac.util.Log$DeferredDiagnosticHandler.reportDeferredDiagnostics(Log.java:153)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2402)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1609)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:598)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:616)
at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1081)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:846)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:598)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:643)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:659)
at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1131)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:903)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:598)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:643)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1018)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:772)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:598)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:643)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4229)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4137)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4072)
at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4046)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1224)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:877)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:836)
at com.sun.tools.javac.main.Main.compile(Main.java:517)
at com.sun.tools.javac.main.Main.compile(Main.java:376)
at com.sun.tools.javac.main.Main.compile(Main.java:365)
at com.sun.tools.javac.main.Main.compile(Main.java:356)
at com.sun.tools.javac.Main.compile(Main.java:77)
at com.sun.tools.javac.Main.main(Main.java:62)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test
{
public static void main(String[] args)
{
Runnable add = (int x) -> (int y) -> x + y;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't write daft code in the first place, I suppose :)