changeset 21716:fdb441b50289

8026963: type annotations code crashes for code with erroneous trees Reviewed-by: jjg, jlahoda
author vromero
date Thu, 14 Nov 2013 19:28:20 +0000
parents f4afc37a97a2
children 11ba59c9bbb5
files langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.java langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.out
diffstat 3 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Nov 14 12:32:57 2013 -0500
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Nov 14 19:28:20 2013 +0000
@@ -4602,9 +4602,8 @@
                         validateAnnotatedType(t, t.type);
                     }
                     repeat = false;
-                } else if (enclTr.getKind() == JCTree.Kind.PRIMITIVE_TYPE) {
-                    // This happens in test TargetTypeTest52.java
-                    // Is there anything to do?
+                } else if (enclTr.getKind() == JCTree.Kind.PRIMITIVE_TYPE ||
+                           enclTr.getKind() == JCTree.Kind.ERRONEOUS) {
                     repeat = false;
                 } else {
                     Assert.error("Unexpected tree: " + enclTr + " with kind: " + enclTr.getKind() +
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.java	Thu Nov 14 19:28:20 2013 +0000
@@ -0,0 +1,10 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8026963
+ * @summary type annotations code crashes for lambdas with void argument
+ * @compile/fail/ref=TypeAnnotationsCrashWithErroneousTreeTest.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW TypeAnnotationsCrashWithErroneousTreeTest.java
+ */
+
+public class TypeAnnotationsCrashWithErroneousTreeTest {
+    private void t(this) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.out	Thu Nov 14 19:28:20 2013 +0000
@@ -0,0 +1,2 @@
+TypeAnnotationsCrashWithErroneousTreeTest.java:9:20: compiler.err.illegal.start.of.type
+1 error