--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java 2017-10-11 09:55:31.161017403 -0700 +++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java 2017-10-11 09:55:30.693017386 -0700 @@ -122,6 +122,7 @@ values.add(LintCategory.OPENS); values.add(LintCategory.MODULE); values.add(LintCategory.REMOVAL); + values.add(LintCategory.FUTURE); } // Look for specific overrides @@ -285,6 +286,12 @@ UNCHECKED("unchecked"), /** + * Warn about source structures that may be illegal or + * questionable in future source versions. + */ + FUTURE("future"), + + /** * Warn about potentially unsafe vararg methods */ VARARGS("varargs"); --- old/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java 2017-10-11 09:55:31.905017429 -0700 +++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java 2017-10-11 09:55:31.525017416 -0700 @@ -92,6 +92,9 @@ /** The name table. */ private Names names; + /** The lint settings. */ + private Lint lint; + /** End position mappings container */ protected final AbstractEndPosTable endPosTable; @@ -186,6 +189,7 @@ this.keepLineMap = keepLineMap; this.errorTree = F.Erroneous(); endPosTable = newEndPosTable(keepEndPositions); + this.lint = fac.lint; } protected AbstractEndPosTable newEndPosTable(boolean keepEndPositions) { @@ -639,7 +643,10 @@ } } else if (token.kind == UNDERSCORE) { if (allowUnderscoreIdentifier) { - warning(token.pos, "underscore.as.identifier"); + if (lint.isEnabled(Lint.LintCategory.FUTURE) && + !lint.isSuppressed(Lint.LintCategory.FUTURE)) { + warning(token.pos, "underscore.as.identifier"); + } } else { error(token.pos, "underscore.as.identifier"); } --- old/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/ParserFactory.java 2017-10-11 09:55:32.845017463 -0700 +++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/ParserFactory.java 2017-10-11 09:55:32.445017449 -0700 @@ -28,6 +28,7 @@ import java.util.Locale; import com.sun.tools.javac.code.Source; +import com.sun.tools.javac.code.Lint; import com.sun.tools.javac.tree.DocTreeMaker; import com.sun.tools.javac.tree.TreeMaker; import com.sun.tools.javac.util.Context; @@ -65,6 +66,7 @@ final Options options; final ScannerFactory scannerFactory; final Locale locale; + final Lint lint; protected ParserFactory(Context context) { super(); @@ -78,6 +80,7 @@ this.options = Options.instance(context); this.scannerFactory = ScannerFactory.instance(context); this.locale = context.get(Locale.class); + this.lint = Lint.instance(context); } public JavacParser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) { --- /dev/null 2017-09-14 09:42:06.875661300 -0700 +++ new/test/langtools/tools/javac/warnings/future/FutureWarnings.8.out 2017-10-11 09:55:34.001017505 -0700 @@ -0,0 +1 @@ +FutureWarnings.java:11:27: compiler.warn.underscore.as.identifier --- /dev/null 2017-09-14 09:42:06.875661300 -0700 +++ new/test/langtools/tools/javac/warnings/future/FutureWarnings.java 2017-10-11 09:55:34.765017532 -0700 @@ -0,0 +1,24 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8189145 + * @compile/ref=FutureWarnings.0.out -source 8 -Xlint:-future,-options -XDrawDiagnostics FutureWarnings.java + * @compile/ref=FutureWarnings.0.out --release 8 -Xlint:-future -XDrawDiagnostics FutureWarnings.java + * @compile/ref=FutureWarnings.8.out --release 8 -XDrawDiagnostics FutureWarnings.java + */ + +// * @compile/ref=FutureWarnings.8.out -source 8 -Xlint:-options -XDrawDiagnostics FutureWarnings.java + + +public class FutureWarnings { + private static String _ = "underscore"; +} + +@SuppressWarnings("future") +class NoFutureWarnings { + private static String _ = "underscore"; +} + +class NoFutureWarningsEither { + @SuppressWarnings("future") + private static String _ = "underscore"; +}