--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java 2018-01-09 10:08:35.587072428 -0800 +++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java 2018-01-09 10:08:35.243072412 -0800 @@ -3403,8 +3403,12 @@ Name typeName() { int pos = token.pos; Name name = ident(); - if (isRestrictedLocalVarTypeName(name)) { - reportSyntaxError(pos, "var.not.allowed", name); + if (name == names.var) { + if (Feature.LOCAL_VARIABLE_TYPE_INFERENCE.allowedInSource(source)) { + reportSyntaxError(pos, "var.not.allowed", name); + } else { + warning(pos, "var.not.allowed", name); + } } return name; } --- old/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties 2018-01-09 10:08:36.327072460 -0800 +++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties 2018-01-09 10:08:35.987072445 -0800 @@ -1204,6 +1204,9 @@ ''{0}'' not allowed here\n\ as of release 10, ''{0}'' is a restricted local variable type and cannot be used for type declarations +compiler.warn.var.not.allowed=\ + as of release 10, ''{0}'' is a restricted local variable type and cannot be used for type declarations + # 0: name (variable), 1: message segment compiler.err.cant.infer.local.var.type=\ cannot infer type for local variable {0}\n\ --- old/test/langtools/tools/javac/lvti/ParserTest.java 2018-01-09 10:08:37.035072491 -0800 +++ new/test/langtools/tools/javac/lvti/ParserTest.java 2018-01-09 10:08:36.663072475 -0800 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8177466 * @summary Add compiler support for local variable type-inference - * @compile -source 9 ParserTest.java + * @compile/ref=ParserTest9.out -XDrawDiagnostics --release 9 ParserTest.java * @compile/fail/ref=ParserTest.out -XDrawDiagnostics ParserTest.java */ --- /dev/null 2017-11-14 18:40:26.820374259 -0800 +++ new/test/langtools/tools/javac/diags/examples/FutureVarNotAllowed.java 2018-01-09 10:08:37.307072503 -0800 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2016, 2018, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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.var.not.allowed +// options: --release 9 + +class var { } --- /dev/null 2017-11-14 18:40:26.820374259 -0800 +++ new/test/langtools/tools/javac/lvti/ParserTest9.out 2018-01-09 10:08:37.947072531 -0800 @@ -0,0 +1,7 @@ +ParserTest.java:14:18: compiler.warn.var.not.allowed: var +ParserTest.java:16:22: compiler.warn.var.not.allowed: var +ParserTest.java:20:19: compiler.warn.var.not.allowed: var +ParserTest.java:24:14: compiler.warn.var.not.allowed: var +ParserTest.java:28:20: compiler.warn.var.not.allowed: var +ParserTest.java:36:18: compiler.warn.var.not.allowed: var +6 warnings