8014643: Parser regression in JDK 8 when compiling super.x
authormcimadamore
Fri, 24 May 2013 15:26:57 +0100
changeset 17803 d73ddda4575f
parent 17802 83c53847fc7e
child 17804 6bed8a263318
8014643: Parser regression in JDK 8 when compiling super.x Summary: Fixed latent bug in JavacParser.analyzeParens() Reviewed-by: jjg, vromero
langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
langtools/test/tools/javac/parser/8014643/T8014643.java
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Wed May 22 13:34:03 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri May 24 15:26:57 2013 +0100
@@ -1535,11 +1535,18 @@
         outer: for (int lookahead = 0 ; ; lookahead++) {
             TokenKind tk = S.token(lookahead).kind;
             switch (tk) {
-                case EXTENDS: case SUPER: case COMMA:
+                case COMMA:
                     type = true;
-                case QUES: case DOT: case AMP:
+                case EXTENDS: case SUPER: case DOT: case AMP:
                     //skip
                     break;
+                case QUES:
+                    if (peekToken(lookahead, EXTENDS) ||
+                            peekToken(lookahead, SUPER)) {
+                        //wildcards
+                        type = true;
+                    }
+                    break;
                 case BYTE: case SHORT: case INT: case LONG: case FLOAT:
                 case DOUBLE: case BOOLEAN: case CHAR:
                     if (peekToken(lookahead, RPAREN)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/parser/8014643/T8014643.java	Fri May 24 15:26:57 2013 +0100
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2013, 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 8014643
+ * @summary Parser regression in JDK 8 when compiling super.x
+ * @compile T8014643.java
+ */
+class T8014643 {
+
+    static class A {
+        int b = 1;
+    }
+
+    static class B extends A {
+        int b = 12;
+
+        int m() { return (super.b); }
+    }
+}