6967002: JDK7 b99 javac compilation error (java.lang.AssertionError)

Bug in JavacParser related to parsing of type annotations in varargs position

Reviewed-by: jjg
This commit is contained in:
Mahmood Ali 2010-07-15 16:31:02 +01:00 committed by Maurizio Cimadamore
parent a1e7efde4a
commit aa93fd7701
3 changed files with 49 additions and 2 deletions

View File

@ -1151,8 +1151,12 @@ public class JavacParser implements Parser {
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;

View File

@ -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..., ?);
}
}

View File

@ -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