changeset 2190:e79d6425f1c4

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 24eaf41a3974
children 5ae66d372d57
files src/share/classes/com/sun/tools/javac/comp/Attr.java test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.java test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.out
diffstat 3 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Nov 14 12:32:57 2013 -0500
+++ b/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/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/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