Mercurial > hg > openjdk > aarch64-port > langtools
changeset 1890:7b756b307e12
8017618: NullPointerException in RichDiagnosticFormatter for bad input program
Summary: RDF crashes when diagnostic contains type 'void'
Reviewed-by: jjg, vromero
author | mcimadamore |
---|---|
date | Fri, 05 Jul 2013 11:00:19 +0100 |
parents | 79c3146e417b |
children | 70b37cdb19d5 |
files | src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java test/tools/javac/lambda/BadNestedLambda.java test/tools/javac/lambda/BadNestedLambda.out |
diffstat | 3 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Thu Jul 04 10:41:08 2013 +0100 +++ b/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/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/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