7157165: Regression: code with disjunctive type crashes javac
authormcimadamore
Fri, 30 Mar 2012 19:19:50 +0100
changeset 12337 a27eed20c9a3
parent 12336 6291eb84bea7
child 12338 417d785b6dac
7157165: Regression: code with disjunctive type crashes javac Summary: Bad recovery logic in parser code that checks for generic cast Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
langtools/test/tools/javac/parser/7157165/T7157165.java
langtools/test/tools/javac/parser/7157165/T7157165.out
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Mar 30 19:19:09 2012 +0100
+++ b/langtools/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/langtools/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/langtools/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