6967002: JDK7 b99 javac compilation error (java.lang.AssertionError)
authormcimadamore
Thu, 15 Jul 2010 16:31:02 +0100
changeset 6146 0b7532544a47
parent 6145 e52c4da245c9
child 6147 0074061d0efd
6967002: JDK7 b99 javac compilation error (java.lang.AssertionError) Summary: bug in JavacParser related to parsing of type annotations in varargs position Reviewed-by: jjg Contributed-by: mahmood@notnoop.com
langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
langtools/test/tools/javac/typeAnnotations/6967002/T6967002.java
langtools/test/tools/javac/typeAnnotations/6967002/T6967002.out
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Jul 13 19:20:48 2010 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Jul 15 16:31:02 2010 +0100
@@ -1151,8 +1151,12 @@
                     t = toP(F.at(pos).Select(t, ident()));
                     break;
                 case ELLIPSIS:
-                    assert this.permitTypeAnnotationsPushBack;
-                    typeAnnotationsPushedBack = annos;
+                    if (this.permitTypeAnnotationsPushBack) {
+                        this.typeAnnotationsPushedBack = annos;
+                    } else if (annos.nonEmpty()) {
+                        // Don't return here -- error recovery attempt
+                        illegal(annos.head.pos);
+                    }
                     break loop;
                 default:
                     break loop;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/6967002/T6967002.java	Thu Jul 15 16:31:02 2010 +0100
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6967002
+ * @summary JDK7 b99 javac compilation error (java.lang.AssertionError)
+ * @author Maurizio Cimadamore
+ * @compile/fail/ref=T6967002.out -XDrawDiagnostics T6967002.java
+ */
+class Test {
+   private static void m(byte[] octets) {
+      return m(octets..., ?);
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/6967002/T6967002.out	Thu Jul 15 16:31:02 2010 +0100
@@ -0,0 +1,8 @@
+T6967002.java:33:22: compiler.err.expected: ')'
+T6967002.java:33:25: compiler.err.illegal.start.of.expr
+T6967002.java:33:28: compiler.err.illegal.start.of.expr
+T6967002.java:33:29: compiler.err.illegal.start.of.expr
+T6967002.java:33:27: compiler.err.not.stmt
+T6967002.java:33:30: compiler.err.expected: ';'
+T6967002.java:35:2: compiler.err.premature.eof
+7 errors