mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 01:24:33 +02:00
8146632: Add descriptive error messages for removed non-product logging flags
Added table with removed non-product flags and error messages. Reviewed-by: dholmes, coleenp, hseigel
This commit is contained in:
parent
d444e55969
commit
dca64ad62d
3 changed files with 105 additions and 1 deletions
|
@ -417,6 +417,22 @@ static AliasedLoggingFlag const aliased_logging_flags[] = {
|
||||||
{ NULL, LogLevel::Off, false, LOG_TAGS(_NO_TAG) }
|
{ NULL, LogLevel::Off, false, LOG_TAGS(_NO_TAG) }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef PRODUCT
|
||||||
|
// These options are removed in jdk9. Remove this code for jdk10.
|
||||||
|
static AliasedFlag const removed_develop_logging_flags[] = {
|
||||||
|
{ "TraceClassInitialization", "-Xlog:classinit" },
|
||||||
|
{ "TraceClassLoaderData", "-Xlog:classloaderdata" },
|
||||||
|
{ "TraceDefaultMethods", "-Xlog:defaultmethods=debug" },
|
||||||
|
{ "TraceItables", "-Xlog:itables=debug" },
|
||||||
|
{ "TraceSafepoint", "-Xlog:safepoint=debug" },
|
||||||
|
{ "TraceStartupTime", "-Xlog:startuptime" },
|
||||||
|
{ "TraceVMOperation", "-Xlog:vmoperation=debug" },
|
||||||
|
{ "PrintVtables", "-Xlog:vtables=debug" },
|
||||||
|
{ "VerboseVerification", "-Xlog:verboseverification" },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
#endif //PRODUCT
|
||||||
|
|
||||||
// Return true if "v" is less than "other", where "other" may be "undefined".
|
// Return true if "v" is less than "other", where "other" may be "undefined".
|
||||||
static bool version_less_than(JDK_Version v, JDK_Version other) {
|
static bool version_less_than(JDK_Version v, JDK_Version other) {
|
||||||
assert(!v.is_undefined(), "must be defined");
|
assert(!v.is_undefined(), "must be defined");
|
||||||
|
@ -468,6 +484,18 @@ int Arguments::is_deprecated_flag(const char *flag_name, JDK_Version* version) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PRODUCT
|
||||||
|
const char* Arguments::removed_develop_logging_flag_name(const char* name){
|
||||||
|
for (size_t i = 0; removed_develop_logging_flags[i].alias_name != NULL; i++) {
|
||||||
|
const AliasedFlag& flag = removed_develop_logging_flags[i];
|
||||||
|
if (strcmp(flag.alias_name, name) == 0) {
|
||||||
|
return flag.real_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif // PRODUCT
|
||||||
|
|
||||||
const char* Arguments::real_flag_name(const char *flag_name) {
|
const char* Arguments::real_flag_name(const char *flag_name) {
|
||||||
for (size_t i = 0; aliased_jvm_flags[i].alias_name != NULL; i++) {
|
for (size_t i = 0; aliased_jvm_flags[i].alias_name != NULL; i++) {
|
||||||
const AliasedFlag& flag_status = aliased_jvm_flags[i];
|
const AliasedFlag& flag_status = aliased_jvm_flags[i];
|
||||||
|
@ -1187,13 +1215,22 @@ bool Arguments::process_argument(const char* arg,
|
||||||
char stripped_argname[BUFLEN+1];
|
char stripped_argname[BUFLEN+1];
|
||||||
strncpy(stripped_argname, argname, arg_len);
|
strncpy(stripped_argname, argname, arg_len);
|
||||||
stripped_argname[arg_len] = '\0'; // strncpy may not null terminate.
|
stripped_argname[arg_len] = '\0'; // strncpy may not null terminate.
|
||||||
|
|
||||||
if (is_obsolete_flag(stripped_argname, &since)) {
|
if (is_obsolete_flag(stripped_argname, &since)) {
|
||||||
char version[256];
|
char version[256];
|
||||||
since.to_string(version, sizeof(version));
|
since.to_string(version, sizeof(version));
|
||||||
warning("Ignoring option %s; support was removed in %s", stripped_argname, version);
|
warning("Ignoring option %s; support was removed in %s", stripped_argname, version);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#ifndef PRODUCT
|
||||||
|
else {
|
||||||
|
const char* replacement;
|
||||||
|
if ((replacement = removed_develop_logging_flag_name(stripped_argname)) != NULL){
|
||||||
|
jio_fprintf(defaultStream::error_stream(),
|
||||||
|
"%s has been removed. Please use %s instead.\n", stripped_argname, replacement);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif //PRODUCT
|
||||||
}
|
}
|
||||||
|
|
||||||
// For locked flags, report a custom error message if available.
|
// For locked flags, report a custom error message if available.
|
||||||
|
|
|
@ -453,6 +453,10 @@ class Arguments : AllStatic {
|
||||||
// the version number when the flag became obsolete.
|
// the version number when the flag became obsolete.
|
||||||
static bool is_obsolete_flag(const char* flag_name, JDK_Version* version);
|
static bool is_obsolete_flag(const char* flag_name, JDK_Version* version);
|
||||||
|
|
||||||
|
#ifndef PRODUCT
|
||||||
|
static const char* removed_develop_logging_flag_name(const char* name);
|
||||||
|
#endif // PRODUCT
|
||||||
|
|
||||||
// Returns 1 if the flag is deprecated (and not yet obsolete or expired).
|
// Returns 1 if the flag is deprecated (and not yet obsolete or expired).
|
||||||
// In this case the 'version' buffer is filled in with the version number when
|
// In this case the 'version' buffer is filled in with the version number when
|
||||||
// the flag became deprecated.
|
// the flag became deprecated.
|
||||||
|
|
63
hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java
Normal file
63
hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test RemovedDevelopFlagsTest
|
||||||
|
* @bug 8146632
|
||||||
|
* @library /testlibrary
|
||||||
|
* @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools
|
||||||
|
* @run driver RemovedDevelopFlagsTest
|
||||||
|
*/
|
||||||
|
import jdk.test.lib.*;
|
||||||
|
|
||||||
|
public class RemovedDevelopFlagsTest {
|
||||||
|
public static ProcessBuilder pb;
|
||||||
|
|
||||||
|
public static class RemovedDevelopFlagsTestMain {
|
||||||
|
public static void main(String... args) {
|
||||||
|
System.out.print("Hello!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void exec(String flag, String value) throws Exception {
|
||||||
|
pb = ProcessTools.createJavaProcessBuilder("-XX:+"+flag, RemovedDevelopFlagsTestMain.class.getName());
|
||||||
|
OutputAnalyzer o = new OutputAnalyzer(pb.start());
|
||||||
|
o.shouldContain(flag+" has been removed. Please use "+value+" instead.");
|
||||||
|
o.shouldHaveExitValue(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String... args) throws Exception {
|
||||||
|
if (Platform.isDebugBuild()){
|
||||||
|
exec("TraceClassInitialization", "-Xlog:classinit");
|
||||||
|
exec("TraceClassLoaderData", "-Xlog:classloaderdata");
|
||||||
|
exec("TraceDefaultMethods", "-Xlog:defaultmethods=debug");
|
||||||
|
exec("TraceItables", "-Xlog:itables=debug");
|
||||||
|
exec("TraceSafepoint", "-Xlog:safepoint=debug");
|
||||||
|
exec("TraceStartupTime", "-Xlog:startuptime");
|
||||||
|
exec("TraceVMOperation", "-Xlog:vmoperation=debug");
|
||||||
|
exec("PrintVtables", "-Xlog:vtables=debug");
|
||||||
|
exec("VerboseVerification", "-Xlog:verboseverification");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue