8017618: NullPointerException in RichDiagnosticFormatter for bad input program
Summary: RDF crashes when diagnostic contains type 'void'
Reviewed-by: jjg, vromero
--- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Thu Jul 04 10:41:08 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Fri Jul 05 11:00:19 2013 +0100
@@ -303,8 +303,9 @@
conflicts.contains(s))) {
List<Name> l = List.nil();
Symbol s2 = s;
- while (s2.type.getEnclosingType().hasTag(CLASS)
- && s2.owner.kind == Kinds.TYP) {
+ while (s2.type.hasTag(CLASS) &&
+ s2.type.getEnclosingType().hasTag(CLASS) &&
+ s2.owner.kind == Kinds.TYP) {
l = l.prepend(s2.getSimpleName());
s2 = s2.owner;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadNestedLambda.java Fri Jul 05 11:00:19 2013 +0100
@@ -0,0 +1,11 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8017618
+ * @summary NullPointerException in RichDiagnosticFormatter for bad input program
+ * @compile/fail/ref=BadNestedLambda.out -XDrawDiagnostics BadNestedLambda.java
+ */
+class BadNestedLambda {
+ void test() {
+ Runnable add = (int x) -> (int y) -> x + y;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadNestedLambda.out Fri Jul 05 11:00:19 2013 +0100
@@ -0,0 +1,3 @@
+BadNestedLambda.java:9:35: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.not.a.functional.intf: void))
+BadNestedLambda.java:9:24: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda)
+2 errors