changeset 1240:c94c09f34701

7157165: Regression: code with disjunctive type crashes javac Summary: Bad recovery logic in parser code that checks for generic cast Reviewed-by: jjg
author mcimadamore
date Fri, 30 Mar 2012 19:19:50 +0100
parents 379bc17d9a26
children 01e7924ea479
files src/share/classes/com/sun/tools/javac/parser/JavacParser.java test/tools/javac/parser/7157165/T7157165.java test/tools/javac/parser/7157165/T7157165.out
diffstat 3 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Mar 30 19:19:09 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Mar 30 19:19:50 2012 +0100
@@ -983,12 +983,13 @@
                                 t = lambdaExpressionOrStatement(variableDeclaratorId(mods, t), pos);
                                 break;
                             }
-                        } else {
-                            Assert.check((mode & EXPR) != 0);
+                        } else if ((mode & EXPR) != 0) {
                             mode = EXPR;
                             JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
                             t = F.at(pos1).Binary(op, t, e);
                             t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
+                        } else {
+                            accept(GT);
                         }
                     } else if ((mode & TYPE) != 0 &&
                             (token.kind == IDENTIFIER || token.kind == ELLIPSIS)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/parser/7157165/T7157165.java	Fri Mar 30 19:19:50 2012 +0100
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7157165
+ *
+ * @summary Regression: code with disjunctive type crashes javac
+ * @compile/fail/ref=T7157165.out -XDrawDiagnostics T7157165.java
+ *
+ */
+
+class T7157165 {
+    Foo<? extends A|B> foo1 = null;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/parser/7157165/T7157165.out	Fri Mar 30 19:19:50 2012 +0100
@@ -0,0 +1,4 @@
+T7157165.java:11:20: compiler.err.expected: >
+T7157165.java:11:21: compiler.err.expected: ';'
+T7157165.java:11:22: compiler.err.illegal.start.of.type
+3 errors