8061549: Disallow _ as a one-character identifier
authorjlahoda
Mon, 08 Dec 2014 18:02:07 +0100
changeset 27991 8f4b68523da3
parent 27990 54ab8a7cccec
child 27992 83fb13ff472d
8061549: Disallow _ as a one-character identifier Summary: Underscore is no longer a one-charater identifier with -source 9 Reviewed-by: mcimadamore, jjg
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
langtools/test/com/sun/javadoc/testAnchorNames/TestAnchorNames.java
langtools/test/tools/javac/diags/examples/UnderscoreAsIdentifier.java
langtools/test/tools/javac/diags/examples/UnderscoreAsIdentifierError.java
langtools/test/tools/javac/diags/examples/UnderscoreAsIdentifierWarning.java
langtools/test/tools/javac/lambda/IdentifierTest.java
langtools/test/tools/javac/lambda/IdentifierTest.out
langtools/test/tools/javac/lambda/IdentifierTest8.out
langtools/test/tools/javac/lambda/IdentifierTest9.out
langtools/test/tools/javac/lambda/UnderscoreAsIdent.java
langtools/test/tools/javac/lambda/UnderscoreAsIdent8.out
langtools/test/tools/javac/lambda/UnderscoreAsIdent9.out
langtools/test/tools/javac/lambda/WarnUnderscoreAsIdent.java
langtools/test/tools/javac/lambda/WarnUnderscoreAsIdent.out
langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java
langtools/test/tools/javac/tree/TreePosRoundsTest.java
langtools/test/tools/javadoc/6964914/JavacWarning.java
langtools/test/tools/javadoc/6964914/Test.java
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Mon Dec 08 16:30:43 2014 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Mon Dec 08 18:02:07 2014 +0100
@@ -209,6 +209,9 @@
     public boolean allowPrivateSafeVarargs() {
         return compareTo(JDK1_9) >= 0;
     }
+    public boolean allowUnderscoreIdentifier() {
+        return compareTo(JDK1_8) <= 0;
+    }
     public static SourceVersion toSourceVersion(Source source) {
         switch(source) {
         case JDK1_2:
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Dec 08 16:30:43 2014 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Dec 08 18:02:07 2014 +0100
@@ -157,6 +157,7 @@
         this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast();
         this.allowTypeAnnotations = source.allowTypeAnnotations();
         this.allowAnnotationsAfterTypeParams = source.allowAnnotationsAfterTypeParams();
+        this.allowUnderscoreIdentifier = source.allowUnderscoreIdentifier();
         this.keepDocComments = keepDocComments;
         docComments = newDocCommentTable(keepDocComments, fac);
         this.keepLineMap = keepLineMap;
@@ -230,6 +231,10 @@
      */
     boolean allowAnnotationsAfterTypeParams;
 
+    /** Switch: should we allow '_' as an identifier?
+     */
+    boolean allowUnderscoreIdentifier;
+
     /** Switch: is "this" allowed as an identifier?
      * This is needed to parse receiver types.
      */
@@ -595,7 +600,11 @@
                 return names.error;
             }
         } else if (token.kind == UNDERSCORE) {
-            warning(token.pos, "underscore.as.identifier");
+            if (allowUnderscoreIdentifier) {
+                warning(token.pos, "underscore.as.identifier");
+            } else {
+                error(token.pos, "underscore.as.identifier");
+            }
             Name name = token.name();
             nextToken();
             return name;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Dec 08 16:30:43 2014 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Dec 08 18:02:07 2014 +0100
@@ -2276,8 +2276,10 @@
     (use -source 9 or higher to enable variables in try-with-resources)
 
 compiler.warn.underscore.as.identifier=\
-    ''_'' used as an identifier\n\
-    (use of ''_'' as an identifier might not be supported in releases after Java SE 8)
+    as of release 9, ''_'' is a keyword, and may not be used as an identifier
+
+compiler.err.underscore.as.identifier=\
+    as of release 9, ''_'' is a keyword, and may not be used as an identifier
 
 compiler.err.underscore.as.identifier.in.lambda=\
     ''_'' used as an identifier\n\
--- a/langtools/test/com/sun/javadoc/testAnchorNames/TestAnchorNames.java	Mon Dec 08 16:30:43 2014 +0000
+++ b/langtools/test/com/sun/javadoc/testAnchorNames/TestAnchorNames.java	Mon Dec 08 18:02:07 2014 +0100
@@ -46,6 +46,7 @@
     void test() {
         javadoc("-d", "out",
                 "-sourcepath", testSrc,
+                "-source", "8", //so that '_' can be used as an identifier
                 "-use",
                 "pkg1");
         checkExit(Exit.OK);
--- a/langtools/test/tools/javac/diags/examples/UnderscoreAsIdentifier.java	Mon Dec 08 16:30:43 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-// key: compiler.warn.underscore.as.identifier
-
-class UnderscoreAsIdentifier {
-    String _ = null;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/UnderscoreAsIdentifierError.java	Mon Dec 08 18:02:07 2014 +0100
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013, 2014, 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.
+ */
+
+// key: compiler.err.underscore.as.identifier
+
+class UnderscoreAsIdentifierError {
+    String _ = null;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/UnderscoreAsIdentifierWarning.java	Mon Dec 08 18:02:07 2014 +0100
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2013, 2014, 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.
+ */
+
+// key: compiler.warn.underscore.as.identifier
+// options: -source 8 -Xlint:-options
+
+class UnderscoreAsIdentifierWarning {
+    String _ = null;
+}
--- a/langtools/test/tools/javac/lambda/IdentifierTest.java	Mon Dec 08 16:30:43 2014 +0000
+++ b/langtools/test/tools/javac/lambda/IdentifierTest.java	Mon Dec 08 18:02:07 2014 +0100
@@ -1,9 +1,10 @@
 /*
  * @test   /nodynamiccopyright/
- * @bug    8007401 8007427
+ * @bug    8007401 8007427 8061549
  * @author sogoel
  * @summary Test generation of warnings when '_' is used an identifier
- * @compile/fail/ref=IdentifierTest.out -Werror -XDrawDiagnostics IdentifierTest.java
+ * @compile/fail/ref=IdentifierTest8.out -source 8 -Xlint:-options -Werror -XDrawDiagnostics IdentifierTest.java
+ * @compile/fail/ref=IdentifierTest9.out -XDrawDiagnostics IdentifierTest.java
  */
 
 import java.util.List;
--- a/langtools/test/tools/javac/lambda/IdentifierTest.out	Mon Dec 08 16:30:43 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-IdentifierTest.java:40:11: compiler.warn.underscore.as.identifier
-IdentifierTest.java:43:16: compiler.warn.underscore.as.identifier
-IdentifierTest.java:44:20: compiler.warn.underscore.as.identifier
-IdentifierTest.java:45:22: compiler.warn.underscore.as.identifier
-IdentifierTest.java:50:13: compiler.warn.underscore.as.identifier
-IdentifierTest.java:50:15: compiler.warn.underscore.as.identifier
-IdentifierTest.java:50:23: compiler.warn.underscore.as.identifier
-IdentifierTest.java:52:13: compiler.warn.underscore.as.identifier
-IdentifierTest.java:54:13: compiler.warn.underscore.as.identifier
-IdentifierTest.java:60:21: compiler.warn.underscore.as.identifier
-IdentifierTest.java:61:42: compiler.warn.underscore.as.identifier
-IdentifierTest.java:62:67: compiler.warn.underscore.as.identifier
-IdentifierTest.java:69:13: compiler.warn.underscore.as.identifier
-IdentifierTest.java:70:14: compiler.warn.underscore.as.identifier
-IdentifierTest.java:71:18: compiler.warn.underscore.as.identifier
-IdentifierTest.java:76:22: compiler.warn.underscore.as.identifier
-IdentifierTest.java:78:13: compiler.warn.underscore.as.identifier
-IdentifierTest.java:78:15: compiler.warn.underscore.as.identifier
-IdentifierTest.java:80:13: compiler.warn.underscore.as.identifier
-IdentifierTest.java:80:15: compiler.warn.underscore.as.identifier
-IdentifierTest.java:87:10: compiler.warn.underscore.as.identifier
-IdentifierTest.java:87:38: compiler.warn.underscore.as.identifier
-IdentifierTest.java:93:14: compiler.warn.underscore.as.identifier
-IdentifierTest.java:100:17: compiler.warn.underscore.as.identifier
-IdentifierTest.java:100:26: compiler.warn.underscore.as.identifier
-IdentifierTest.java:117:20: compiler.warn.underscore.as.identifier
-IdentifierTest.java:122:10: compiler.warn.underscore.as.identifier
-IdentifierTest.java:127:17: compiler.warn.underscore.as.identifier
-IdentifierTest.java:130:17: compiler.warn.underscore.as.identifier
-IdentifierTest.java:137:17: compiler.warn.underscore.as.identifier
-IdentifierTest.java:137:24: compiler.warn.underscore.as.identifier
-IdentifierTest.java:137:33: compiler.warn.underscore.as.identifier
-IdentifierTest.java:138:39: compiler.warn.underscore.as.identifier
-IdentifierTest.java:142:13: compiler.warn.underscore.as.identifier
-IdentifierTest.java:143:15: compiler.warn.underscore.as.identifier
-IdentifierTest.java:144:13: compiler.warn.underscore.as.identifier
-IdentifierTest.java:149:15: compiler.warn.underscore.as.identifier
-IdentifierTest.java:150:17: compiler.warn.underscore.as.identifier
-IdentifierTest.java:156:16: compiler.warn.underscore.as.identifier
-IdentifierTest.java:158:25: compiler.warn.underscore.as.identifier
-IdentifierTest.java:167:5: compiler.warn.underscore.as.identifier
-IdentifierTest.java:171:26: compiler.warn.underscore.as.identifier
-IdentifierTest.java:173:19: compiler.warn.underscore.as.identifier
-IdentifierTest.java:179:11: compiler.warn.underscore.as.identifier
-- compiler.err.warnings.and.werror
-1 error
-44 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/IdentifierTest8.out	Mon Dec 08 18:02:07 2014 +0100
@@ -0,0 +1,47 @@
+IdentifierTest.java:41:11: compiler.warn.underscore.as.identifier
+IdentifierTest.java:44:16: compiler.warn.underscore.as.identifier
+IdentifierTest.java:45:20: compiler.warn.underscore.as.identifier
+IdentifierTest.java:46:22: compiler.warn.underscore.as.identifier
+IdentifierTest.java:51:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:51:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:51:23: compiler.warn.underscore.as.identifier
+IdentifierTest.java:53:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:55:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:61:21: compiler.warn.underscore.as.identifier
+IdentifierTest.java:62:42: compiler.warn.underscore.as.identifier
+IdentifierTest.java:63:67: compiler.warn.underscore.as.identifier
+IdentifierTest.java:70:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:71:14: compiler.warn.underscore.as.identifier
+IdentifierTest.java:72:18: compiler.warn.underscore.as.identifier
+IdentifierTest.java:77:22: compiler.warn.underscore.as.identifier
+IdentifierTest.java:79:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:79:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:81:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:81:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:88:10: compiler.warn.underscore.as.identifier
+IdentifierTest.java:88:38: compiler.warn.underscore.as.identifier
+IdentifierTest.java:94:14: compiler.warn.underscore.as.identifier
+IdentifierTest.java:101:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:101:26: compiler.warn.underscore.as.identifier
+IdentifierTest.java:118:20: compiler.warn.underscore.as.identifier
+IdentifierTest.java:123:10: compiler.warn.underscore.as.identifier
+IdentifierTest.java:128:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:131:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:138:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:138:24: compiler.warn.underscore.as.identifier
+IdentifierTest.java:138:33: compiler.warn.underscore.as.identifier
+IdentifierTest.java:139:39: compiler.warn.underscore.as.identifier
+IdentifierTest.java:143:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:144:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:145:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:150:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:151:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:157:16: compiler.warn.underscore.as.identifier
+IdentifierTest.java:159:25: compiler.warn.underscore.as.identifier
+IdentifierTest.java:168:5: compiler.warn.underscore.as.identifier
+IdentifierTest.java:172:26: compiler.warn.underscore.as.identifier
+IdentifierTest.java:174:19: compiler.warn.underscore.as.identifier
+IdentifierTest.java:180:11: compiler.warn.underscore.as.identifier
+- compiler.err.warnings.and.werror
+1 error
+44 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/IdentifierTest9.out	Mon Dec 08 18:02:07 2014 +0100
@@ -0,0 +1,45 @@
+IdentifierTest.java:41:11: compiler.err.underscore.as.identifier
+IdentifierTest.java:44:16: compiler.err.underscore.as.identifier
+IdentifierTest.java:45:20: compiler.err.underscore.as.identifier
+IdentifierTest.java:46:22: compiler.err.underscore.as.identifier
+IdentifierTest.java:51:13: compiler.err.underscore.as.identifier
+IdentifierTest.java:51:15: compiler.err.underscore.as.identifier
+IdentifierTest.java:51:23: compiler.err.underscore.as.identifier
+IdentifierTest.java:53:13: compiler.err.underscore.as.identifier
+IdentifierTest.java:55:13: compiler.err.underscore.as.identifier
+IdentifierTest.java:61:21: compiler.err.underscore.as.identifier
+IdentifierTest.java:62:42: compiler.err.underscore.as.identifier
+IdentifierTest.java:63:67: compiler.err.underscore.as.identifier
+IdentifierTest.java:70:13: compiler.err.underscore.as.identifier
+IdentifierTest.java:71:14: compiler.err.underscore.as.identifier
+IdentifierTest.java:72:18: compiler.err.underscore.as.identifier
+IdentifierTest.java:77:22: compiler.err.underscore.as.identifier
+IdentifierTest.java:79:13: compiler.err.underscore.as.identifier
+IdentifierTest.java:79:15: compiler.err.underscore.as.identifier
+IdentifierTest.java:81:13: compiler.err.underscore.as.identifier
+IdentifierTest.java:81:15: compiler.err.underscore.as.identifier
+IdentifierTest.java:88:10: compiler.err.underscore.as.identifier
+IdentifierTest.java:88:38: compiler.err.underscore.as.identifier
+IdentifierTest.java:94:14: compiler.err.underscore.as.identifier
+IdentifierTest.java:101:17: compiler.err.underscore.as.identifier
+IdentifierTest.java:101:26: compiler.err.underscore.as.identifier
+IdentifierTest.java:118:20: compiler.err.underscore.as.identifier
+IdentifierTest.java:123:10: compiler.err.underscore.as.identifier
+IdentifierTest.java:128:17: compiler.err.underscore.as.identifier
+IdentifierTest.java:131:17: compiler.err.underscore.as.identifier
+IdentifierTest.java:138:17: compiler.err.underscore.as.identifier
+IdentifierTest.java:138:24: compiler.err.underscore.as.identifier
+IdentifierTest.java:138:33: compiler.err.underscore.as.identifier
+IdentifierTest.java:139:39: compiler.err.underscore.as.identifier
+IdentifierTest.java:143:13: compiler.err.underscore.as.identifier
+IdentifierTest.java:144:15: compiler.err.underscore.as.identifier
+IdentifierTest.java:145:13: compiler.err.underscore.as.identifier
+IdentifierTest.java:150:15: compiler.err.underscore.as.identifier
+IdentifierTest.java:151:17: compiler.err.underscore.as.identifier
+IdentifierTest.java:157:16: compiler.err.underscore.as.identifier
+IdentifierTest.java:159:25: compiler.err.underscore.as.identifier
+IdentifierTest.java:168:5: compiler.err.underscore.as.identifier
+IdentifierTest.java:172:26: compiler.err.underscore.as.identifier
+IdentifierTest.java:174:19: compiler.err.underscore.as.identifier
+IdentifierTest.java:180:11: compiler.err.underscore.as.identifier
+44 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/UnderscoreAsIdent.java	Mon Dec 08 18:02:07 2014 +0100
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2013, 2014, 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
+ * @summary Check usages of underscore as identifier generate warnings
+ * @compile/fail/ref=UnderscoreAsIdent8.out -source 8 -Xlint:-options -XDrawDiagnostics -Werror UnderscoreAsIdent.java
+ * @compile/fail/ref=UnderscoreAsIdent9.out -XDrawDiagnostics -Werror UnderscoreAsIdent.java
+ */
+package _._;
+
+import _._;
+
+class _ {
+    String _ = null;
+    void _(String _) { }
+    void testLocal() {
+        String _ = null;
+    }
+    void testFor() {
+        for (int _ = 0; _ < 10; _++);
+    }
+    void testTry() {
+        try { } catch (Throwable _) { }
+    }
+    void testLabel() {
+        _:
+        for (;;) {
+            break _;
+        }
+        _:
+        for (;;) {
+            continue _;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/UnderscoreAsIdent8.out	Mon Dec 08 18:02:07 2014 +0100
@@ -0,0 +1,20 @@
+UnderscoreAsIdent.java:30:9: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:30:11: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:32:8: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:32:10: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:34:7: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:35:12: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:36:10: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:36:19: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:38:16: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:41:18: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:41:25: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:41:33: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:44:34: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:47:9: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:49:19: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:51:9: compiler.warn.underscore.as.identifier
+UnderscoreAsIdent.java:53:22: compiler.warn.underscore.as.identifier
+- compiler.err.warnings.and.werror
+1 error
+17 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/UnderscoreAsIdent9.out	Mon Dec 08 18:02:07 2014 +0100
@@ -0,0 +1,18 @@
+UnderscoreAsIdent.java:30:9: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:30:11: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:32:8: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:32:10: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:34:7: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:35:12: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:36:10: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:36:19: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:38:16: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:41:18: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:41:25: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:41:33: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:44:34: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:47:9: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:49:19: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:51:9: compiler.err.underscore.as.identifier
+UnderscoreAsIdent.java:53:22: compiler.err.underscore.as.identifier
+17 errors
--- a/langtools/test/tools/javac/lambda/WarnUnderscoreAsIdent.java	Mon Dec 08 16:30:43 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * 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
- * @summary Check usages of underscore as identifier generate warnings
- * @compile/fail/ref=WarnUnderscoreAsIdent.out -XDrawDiagnostics -Werror WarnUnderscoreAsIdent.java
- */
-package _._;
-
-import _._;
-
-class _ {
-    String _ = null;
-    void _(String _) { }
-    void testLocal() {
-        String _ = null;
-    }
-    void testFor() {
-        for (int _ = 0; _ < 10; _++);
-    }
-    void testTry() {
-        try { } catch (Throwable _) { }
-    }
-    void testLabel() {
-        _:
-        for (;;) {
-            break _;
-        }
-        _:
-        for (;;) {
-            continue _;
-        }
-    }
-}
--- a/langtools/test/tools/javac/lambda/WarnUnderscoreAsIdent.out	Mon Dec 08 16:30:43 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-WarnUnderscoreAsIdent.java:29:9: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:29:11: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:31:8: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:31:10: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:33:7: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:34:12: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:35:10: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:35:19: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:37:16: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:40:18: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:40:25: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:40:33: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:43:34: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:46:9: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:48:19: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:50:9: compiler.warn.underscore.as.identifier
-WarnUnderscoreAsIdent.java:52:22: compiler.warn.underscore.as.identifier
-- compiler.err.warnings.and.werror
-1 error
-17 warnings
--- a/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java	Mon Dec 08 16:30:43 2014 +0000
+++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java	Mon Dec 08 18:02:07 2014 +0100
@@ -265,19 +265,19 @@
 
     class TestElementScanner extends ElementScanner<Void, Void> {
         @Override
-        public Void visitExecutable(ExecutableElement e, Void _) {
+        public Void visitExecutable(ExecutableElement e, Void p) {
             check(e);
-            return super.visitExecutable(e, _);
+            return super.visitExecutable(e, p);
         }
         @Override
-        public Void visitType(TypeElement e, Void _) {
+        public Void visitType(TypeElement e, Void p) {
             check(e);
-            return super.visitType(e, _);
+            return super.visitType(e, p);
         }
         @Override
-        public Void visitVariable(VariableElement e, Void _) {
+        public Void visitVariable(VariableElement e, Void p) {
             check(e);
-            return super.visitVariable(e, _);
+            return super.visitVariable(e, p);
         }
     }
 
--- a/langtools/test/tools/javac/tree/TreePosRoundsTest.java	Mon Dec 08 16:30:43 2014 +0000
+++ b/langtools/test/tools/javac/tree/TreePosRoundsTest.java	Mon Dec 08 18:02:07 2014 +0100
@@ -140,9 +140,9 @@
         }
 
         @Override
-        public Void visitVariable(VariableTree tree, Void _) {
+        public Void visitVariable(VariableTree tree, Void p) {
             check(getCurrentPath());
-            return super.visitVariable(tree, _);
+            return super.visitVariable(tree, p);
         }
 
         void check(TreePath tp) {
--- a/langtools/test/tools/javadoc/6964914/JavacWarning.java	Mon Dec 08 16:30:43 2014 +0000
+++ b/langtools/test/tools/javadoc/6964914/JavacWarning.java	Mon Dec 08 18:02:07 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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
@@ -22,5 +22,5 @@
  */
 
 public class JavacWarning {
-    String _ = null; // this will cause a warning.  It may be deprecated in JDK8
+    String _ = null; // this will cause a warning with -source 8 (this is an error as of -source 9)
 }
--- a/langtools/test/tools/javadoc/6964914/Test.java	Mon Dec 08 16:30:43 2014 +0000
+++ b/langtools/test/tools/javadoc/6964914/Test.java	Mon Dec 08 18:02:07 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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
@@ -46,6 +46,7 @@
         File testSrc = new File(System.getProperty("test.src"));
         String[] args = {
             "-Xdoclint:none",
+            "-source", "8",
             "-bootclasspath", System.getProperty("sun.boot.class.path"),
             "-classpath", ".",
             "-package",