提交 f66e3267 编写于 作者: D darcy

8011043: Warn about use of 1.5 and earlier source and target values

Reviewed-by: jjg
上级 70dfea74
......@@ -363,6 +363,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
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 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
}
}
checkForObsoleteOptions(target);
verboseCompilePolicy = options.isSet("verboseCompilePolicy");
if (attrParseOnly)
......@@ -432,6 +435,26 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
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:
*/
......
......@@ -1440,6 +1440,17 @@ compiler.warn.static.not.qualified.by.type=\
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
......
......@@ -269,6 +269,8 @@ public class Start extends ToolOption.Helper {
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++) {
......
/*
* 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() {;}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册