8155948: Add message for CMS deprecation for Oracle builds
Reviewed-by: kbarrett, dholmes, coleenp, drwhite
--- a/hotspot/src/share/vm/runtime/arguments.cpp Mon Oct 17 18:40:10 2016 -0400
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Mon Oct 17 16:46:12 2016 -0700
@@ -351,14 +351,6 @@
* Deprecated options should be tested in VMDeprecatedOptions.java.
*/
-// Obsolete or deprecated -XX flag.
-typedef struct {
- const char* name;
- JDK_Version deprecated_in; // When the deprecation warning started (or "undefined").
- JDK_Version obsolete_in; // When the obsolete warning started (or "undefined").
- JDK_Version expired_in; // When the option expires (or "undefined").
-} SpecialFlag;
-
// The special_jvm_flags table declares options that are being deprecated and/or obsoleted. The
// "deprecated_in" or "obsolete_in" fields may be set to "undefined", but not both.
// When the JDK version reaches 'deprecated_in' limit, the JVM will process this flag on
@@ -498,7 +490,14 @@
}
}
+extern bool lookup_special_flag_ext(const char *flag_name, SpecialFlag& flag);
+
static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {
+ // Allow extensions to have priority
+ if (lookup_special_flag_ext(flag_name, flag)) {
+ return true;
+ }
+
for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
flag = special_jvm_flags[i];
@@ -1804,6 +1803,7 @@
if (os::is_server_class_machine()) {
if (should_auto_select_low_pause_collector()) {
FLAG_SET_ERGO_IF_DEFAULT(bool, UseConcMarkSweepGC, true);
+ FLAG_SET_ERGO_IF_DEFAULT(bool, UseParNewGC, true);
} else {
FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
}
@@ -2870,11 +2870,13 @@
if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true) != Flag::SUCCESS) {
return JNI_EINVAL;
}
+ handle_extra_cms_flags("-Xconcgc uses UseConcMarkSweepGC");
// -Xnoconcgc
} else if (match_option(option, "-Xnoconcgc")) {
if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false) != Flag::SUCCESS) {
return JNI_EINVAL;
}
+ handle_extra_cms_flags("-Xnoconcgc uses UseConcMarkSweepGC");
// -Xbatch
} else if (match_option(option, "-Xbatch")) {
if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) {
@@ -4157,6 +4159,15 @@
return true;
}
+void Arguments::handle_extra_cms_flags(const char* msg) {
+ SpecialFlag flag;
+ const char *flag_name = "UseConcMarkSweepGC";
+ if (lookup_special_flag(flag_name, flag)) {
+ handle_aliases_and_deprecation(flag_name, /* print warning */ true);
+ warning("%s", msg);
+ }
+}
+
// Parse entry point called from JNI_CreateJavaVM
jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
--- a/hotspot/src/share/vm/runtime/arguments.hpp Mon Oct 17 18:40:10 2016 -0400
+++ b/hotspot/src/share/vm/runtime/arguments.hpp Mon Oct 17 16:46:12 2016 -0700
@@ -41,6 +41,14 @@
typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args) ATTRIBUTE_PRINTF(2, 0);
}
+// Obsolete or deprecated -XX flag.
+struct SpecialFlag {
+ const char* name;
+ JDK_Version deprecated_in; // When the deprecation warning started (or "undefined").
+ JDK_Version obsolete_in; // When the obsolete warning started (or "undefined").
+ JDK_Version expired_in; // When the option expires (or "undefined").
+};
+
// PathString is used as:
// - the underlying value for a SystemProperty
// - the path portion of an --patch-module module/path pair
@@ -519,6 +527,8 @@
static bool handle_deprecated_print_gc_flags();
+ static void handle_extra_cms_flags(const char* msg);
+
static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
const JavaVMInitArgs *java_options_args,
const JavaVMInitArgs *cmd_line_args);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/runtime/arguments_ext.cpp Mon Oct 17 16:46:12 2016 -0700
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "runtime/arguments.hpp"
+
+bool lookup_special_flag_ext(const char *flag_name, SpecialFlag& flag) {
+ return false;
+}
--- a/hotspot/test/gc/startup_warnings/TestCMS.java Mon Oct 17 18:40:10 2016 -0400
+++ b/hotspot/test/gc/startup_warnings/TestCMS.java Mon Oct 17 16:46:12 2016 -0700
@@ -24,8 +24,8 @@
/*
* @test TestCMS
* @key gc
-* @bug 8006398
-* @summary Test that CMS does not print a warning message
+* @bug 8006398 8155948
+* @summary Test that CMS prints a warning message only for a commercial build
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
@@ -33,16 +33,27 @@
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
-
+import jdk.test.lib.BuildHelper;
public class TestCMS {
- public static void main(String args[]) throws Exception {
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseConcMarkSweepGC", "-version");
+ public static void runTest(String[] args) throws Exception {
+ boolean isCommercial = BuildHelper.isCommercialBuild();
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
- output.shouldNotContain("deprecated");
+ if (isCommercial) {
+ output.shouldContain("deprecated");
+ } else {
+ output.shouldNotContain("deprecated");
+ }
output.shouldNotContain("error");
output.shouldHaveExitValue(0);
}
+ public static void main(String args[]) throws Exception {
+ runTest(new String[] {"-XX:+UseConcMarkSweepGC", "-version"});
+ runTest(new String[] {"-Xconcgc", "-version"});
+ runTest(new String[] {"-Xnoconcgc", "-version"});
+ }
+
}