7120266: javac fails to compile hotspot code

Parser changes for method references cause bad intercation with method call syntax

Reviewed-by: jjg
This commit is contained in:
Maurizio Cimadamore 2011-12-11 17:48:25 +00:00
parent d7cfaf1336
commit bf0106a903
3 changed files with 78 additions and 43 deletions

View File

@ -1143,49 +1143,49 @@ public class JavacParser implements Parser {
// typeArgs saved for next loop iteration. // typeArgs saved for next loop iteration.
t = toP(F.at(pos).Select(t, ident())); t = toP(F.at(pos).Select(t, ident()));
break; break;
case LT: // case LT:
if ((mode & (TYPE | NOPARAMS)) == 0) { // if ((mode & (TYPE | NOPARAMS)) == 0) {
//could be an unbound method reference whose qualifier // //could be an unbound method reference whose qualifier
//is a generic type i.e. A<S>#m // //is a generic type i.e. A<S>#m
mode = EXPR | TYPE; // mode = EXPR | TYPE;
JCTree.Tag op = JCTree.Tag.LT; // JCTree.Tag op = JCTree.Tag.LT;
int pos1 = token.pos; // int pos1 = token.pos;
nextToken(); // nextToken();
mode |= EXPR | TYPE | TYPEARG; // mode |= EXPR | TYPE | TYPEARG;
JCExpression t1 = term3(); // JCExpression t1 = term3();
if ((mode & TYPE) != 0 && // if ((mode & TYPE) != 0 &&
(token.kind == COMMA || token.kind == GT)) { // (token.kind == COMMA || token.kind == GT)) {
mode = TYPE; // mode = TYPE;
ListBuffer<JCExpression> args = new ListBuffer<JCExpression>(); // ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
args.append(t1); // args.append(t1);
while (token.kind == COMMA) { // while (token.kind == COMMA) {
nextToken(); // nextToken();
args.append(typeArgument()); // args.append(typeArgument());
} // }
accept(GT); // accept(GT);
t = toP(F.at(pos1).TypeApply(t, args.toList())); // t = toP(F.at(pos1).TypeApply(t, args.toList()));
checkGenerics(); // checkGenerics();
while (token.kind == DOT) { // while (token.kind == DOT) {
nextToken(); // nextToken();
mode = TYPE; // mode = TYPE;
t = toP(F.at(token.pos).Select(t, ident())); // t = toP(F.at(token.pos).Select(t, ident()));
t = typeArgumentsOpt(t); // t = typeArgumentsOpt(t);
} // }
if (token.kind != HASH) { // if (token.kind != HASH) {
//method reference expected here // //method reference expected here
t = illegal(); // t = illegal();
} // }
mode = EXPR; // mode = EXPR;
break; // break;
} else if ((mode & EXPR) != 0) { // } else if ((mode & EXPR) != 0) {
//rollback - it was a binary expression // //rollback - it was a binary expression
mode = EXPR; // mode = EXPR;
JCExpression e = term2Rest(t1, TreeInfo.shiftPrec); // JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
t = F.at(pos1).Binary(op, t, e); // t = F.at(pos1).Binary(op, t, e);
t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec))); // t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
} // }
} // }
break loop; // break loop;
default: default:
break loop; break loop;
} }

View File

@ -0,0 +1,34 @@
/*
* Copyright (c) 2011, 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 7120266
* @summary javac fails to compile hotspot code
* @compile T7120266.java
*/
class T7120266 {
void test(int i, int len) { that(i < len, "oopmap"); }
void that(boolean b, String s) { };
}

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @bug 7115052 * @bug 7115052
* @ignore 7120266
* @summary Add parser support for method references * @summary Add parser support for method references
*/ */