--- old/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java 2013-08-20 10:41:50.000000000 -0700 +++ new/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java 2013-08-20 10:41:50.000000000 -0700 @@ -363,6 +363,7 @@ throw new Abort(); } source = Source.instance(context); + Target target = Target.instance(context); attr = Attr.instance(context); chk = Check.instance(context); gen = Gen.instance(context); @@ -403,6 +404,8 @@ } } + checkForObsoleteOptions(target); + verboseCompilePolicy = options.isSet("verboseCompilePolicy"); if (attrParseOnly) @@ -432,6 +435,26 @@ log.setDiagnosticFormatter(RichDiagnosticFormatter.instance(context)); } + private void checkForObsoleteOptions(Target target) { + // Unless lint checking on options is disabled, check for + // obsolete source and target options. + boolean obsoleteOptionFound = false; + if (options.isUnset(XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option)) { + if (source.compareTo(Source.JDK1_5) <= 0) { + log.warning(LintCategory.OPTIONS, "option.obsolete.source", source.name); + obsoleteOptionFound = true; + } + + if (target.compareTo(Target.JDK1_5) <= 0) { + log.warning(LintCategory.OPTIONS, "option.obsolete.target", source.name); + obsoleteOptionFound =true; + } + + if (obsoleteOptionFound) + log.warning(LintCategory.OPTIONS, "option.obsolete.suppression"); + } + } + /* Switches: */ --- old/src/share/classes/com/sun/tools/javac/resources/compiler.properties 2013-08-20 10:41:50.000000000 -0700 +++ new/src/share/classes/com/sun/tools/javac/resources/compiler.properties 2013-08-20 10:41:50.000000000 -0700 @@ -1440,6 +1440,17 @@ compiler.warn.source.no.bootclasspath=\ bootstrap class path not set in conjunction with -source {0} +# 0: string +compiler.warn.option.obsolete.source=\ + source value {0} is obsolete and will be removed in a future release + +# 0: string +compiler.warn.option.obsolete.target=\ + target value {0} is obsolete and will be removed in a future release + +compiler.warn.option.obsolete.suppression=\ + To suppress warnings about obsolete options, use -Xlint:-options. + # 0: name, 1: number, 2: number, 3: number, 4: number compiler.warn.future.attr=\ {0} attribute introduced in version {1}.{2} class files is ignored in version {3}.{4} class files --- old/src/share/classes/com/sun/tools/javadoc/Start.java 2013-08-20 10:41:50.000000000 -0700 +++ new/src/share/classes/com/sun/tools/javadoc/Start.java 2013-08-20 10:41:50.000000000 -0700 @@ -269,6 +269,8 @@ setDocletInvoker(docletClass, fileManager, argv); compOpts = Options.instance(context); + // Make sure no obsolete source/target messages are reported + compOpts.put("-Xlint:-options", "-Xlint:-options"); // Parse arguments for (int i = 0 ; i < argv.length ; i++) { --- /dev/null 2013-08-18 22:25:03.523921149 -0700 +++ new/test/tools/javac/diags/examples/ObsoleteSourceAndTarget.java 2013-08-20 10:41:51.000000000 -0700 @@ -0,0 +1,32 @@ +/* + * 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.option.obsolete.source +// key: compiler.warn.option.obsolete.target +// key: compiler.warn.option.obsolete.suppression +// key: compiler.warn.source.no.bootclasspath +// options: -source 1.5 -target 1.5 + +class ObsoleteSourceAndTarget { + public static void foo() {;} +}