Tue, 20 Aug 2013 12:15:19 -0700
8011043: Warn about use of 1.5 and earlier source and target values
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Tue Aug 20 17:21:47 2013 +0200 1.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Tue Aug 20 12:15:19 2013 -0700 1.3 @@ -363,6 +363,7 @@ 1.4 throw new Abort(); 1.5 } 1.6 source = Source.instance(context); 1.7 + Target target = Target.instance(context); 1.8 attr = Attr.instance(context); 1.9 chk = Check.instance(context); 1.10 gen = Gen.instance(context); 1.11 @@ -403,6 +404,8 @@ 1.12 } 1.13 } 1.14 1.15 + checkForObsoleteOptions(target); 1.16 + 1.17 verboseCompilePolicy = options.isSet("verboseCompilePolicy"); 1.18 1.19 if (attrParseOnly) 1.20 @@ -432,6 +435,26 @@ 1.21 log.setDiagnosticFormatter(RichDiagnosticFormatter.instance(context)); 1.22 } 1.23 1.24 + private void checkForObsoleteOptions(Target target) { 1.25 + // Unless lint checking on options is disabled, check for 1.26 + // obsolete source and target options. 1.27 + boolean obsoleteOptionFound = false; 1.28 + if (options.isUnset(XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option)) { 1.29 + if (source.compareTo(Source.JDK1_5) <= 0) { 1.30 + log.warning(LintCategory.OPTIONS, "option.obsolete.source", source.name); 1.31 + obsoleteOptionFound = true; 1.32 + } 1.33 + 1.34 + if (target.compareTo(Target.JDK1_5) <= 0) { 1.35 + log.warning(LintCategory.OPTIONS, "option.obsolete.target", source.name); 1.36 + obsoleteOptionFound = true; 1.37 + } 1.38 + 1.39 + if (obsoleteOptionFound) 1.40 + log.warning(LintCategory.OPTIONS, "option.obsolete.suppression"); 1.41 + } 1.42 + } 1.43 + 1.44 /* Switches: 1.45 */ 1.46
2.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Aug 20 17:21:47 2013 +0200 2.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Aug 20 12:15:19 2013 -0700 2.3 @@ -1440,6 +1440,17 @@ 2.4 compiler.warn.source.no.bootclasspath=\ 2.5 bootstrap class path not set in conjunction with -source {0} 2.6 2.7 +# 0: string 2.8 +compiler.warn.option.obsolete.source=\ 2.9 + source value {0} is obsolete and will be removed in a future release 2.10 + 2.11 +# 0: string 2.12 +compiler.warn.option.obsolete.target=\ 2.13 + target value {0} is obsolete and will be removed in a future release 2.14 + 2.15 +compiler.warn.option.obsolete.suppression=\ 2.16 + To suppress warnings about obsolete options, use -Xlint:-options. 2.17 + 2.18 # 0: name, 1: number, 2: number, 3: number, 4: number 2.19 compiler.warn.future.attr=\ 2.20 {0} attribute introduced in version {1}.{2} class files is ignored in version {3}.{4} class files
3.1 --- a/src/share/classes/com/sun/tools/javadoc/Start.java Tue Aug 20 17:21:47 2013 +0200 3.2 +++ b/src/share/classes/com/sun/tools/javadoc/Start.java Tue Aug 20 12:15:19 2013 -0700 3.3 @@ -269,6 +269,8 @@ 3.4 setDocletInvoker(docletClass, fileManager, argv); 3.5 3.6 compOpts = Options.instance(context); 3.7 + // Make sure no obsolete source/target messages are reported 3.8 + compOpts.put("-Xlint:-options", "-Xlint:-options"); 3.9 3.10 // Parse arguments 3.11 for (int i = 0 ; i < argv.length ; i++) {
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/test/tools/javac/diags/examples/ObsoleteSourceAndTarget.java Tue Aug 20 12:15:19 2013 -0700 4.3 @@ -0,0 +1,32 @@ 4.4 +/* 4.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. 4.11 + * 4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.15 + * version 2 for more details (a copy is included in the LICENSE file that 4.16 + * accompanied this code). 4.17 + * 4.18 + * You should have received a copy of the GNU General Public License version 4.19 + * 2 along with this work; if not, write to the Free Software Foundation, 4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.21 + * 4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4.23 + * or visit www.oracle.com if you need additional information or have any 4.24 + * questions. 4.25 + */ 4.26 + 4.27 +// key: compiler.warn.option.obsolete.source 4.28 +// key: compiler.warn.option.obsolete.target 4.29 +// key: compiler.warn.option.obsolete.suppression 4.30 +// key: compiler.warn.source.no.bootclasspath 4.31 +// options: -source 1.5 -target 1.5 4.32 + 4.33 +class ObsoleteSourceAndTarget { 4.34 + public static void foo() {;} 4.35 +}