--- old/src/share/vm/runtime/arguments.cpp 2015-08-27 17:40:00.050671037 -0400 +++ new/src/share/vm/runtime/arguments.cpp 2015-08-27 17:39:59.910672788 -0400 @@ -235,111 +235,140 @@ /* * -XX argument processing: - * + * * -XX arguments are defined in several places, such as: * globals.hpp, globals_.hpp, globals_.hpp, _globals.hpp, or _globals.hpp. * -XX arguments are parsed in parse_argument(). * -XX argument bounds checking is done in check_vm_args_consistency(). - * + * * Over time -XX arguments may change. There are mechanisms to handle common cases: - * + * * ALIASED: An option that is simply another name for another option. This is often * part of the process of deprecating a flag, but not all aliases need * to be deprecated. - * - * Create an alias for an option by adding the old and new option names to the - * "aliased_jvm_flags" table. Delete the old variable from globals.hpp (etc),. - * + * + * Create an alias for an option by adding the old and new option names to the + * "aliased_jvm_flags" table. Delete the old variable from globals.hpp (etc). + * * DEPRECATED: An option that is supported, but a warning is printed to let the user know that * support may be removed in the future. Both regular and aliased options may be * deprecated. - * - * Add a deprecation warning for an option (or alias) by adding an entry in the - * "deprecated_jvm_flags" table. Often an option "deprecated" in one major release will - * be made "obsolete" in the next. In this case the entry should be removed from the - * "deprecated_jvm_flags" table and added to the "obsolete_jvm_flags" table (see below). + * + * Add a deprecation warning for an option (or alias) by adding an entry in the + * "special_jvm_flags" table and setting the "deprecated_in" field. + * Often an option "deprecated" in one major release will + * be made "obsolete" in the next. In this case the entry should also have it's + * "obsolete_in" field set. * * OBSOLETE: An option that has been removed (and deleted from globals.hpp), but is still accepted * on the command line. A warning is printed to let the user know that option might not * be accepted in the future. - * - * Add an obsolete warning for an option by adding an entry in the "obsolete_jvm_flags" - * table. - * + * + * Add an obsolete warning for an option by adding an entry in the "special_jvm_flags" + * table and setting the "obsolete_in" field. + * * EXPIRED: A deprecated or obsolete option that has an "accept_until" version less than or equal * to the current JDK version. The system will flatly refuse to admit the existence of - * the flag. This allows a flag to die automatically over JDK releases. - * + * the flag. This allows a flag to die automatically over JDK releases. + * * Note that manual cleanup of expired options should be done at major JDK version upgrades: - * - Expired options should be removed from the obsolete_jvm_flags, deprecated_jvm_flags, - * and aliased_jvm_flags tables. - * - Expired deprecated options should have their global variable definitions removed - * (in globals.hpp, etc). - * + * - Newly expired options should be removed from the special_jvm_flags and aliased_jvm_flags tables. + * - Newly obsolete or expired deprecated options should have their global variable + * definitions removed (from globals.hpp, etc) and related implementations removed. + * + * Recommended approach for removing options: + * + * To remove options commonly used by customers (e.g. product, commercial -XX options), use + * the 3-step model adding major release numbers to the deprecate, obsolete and expire columns. + * + * To remove internal options (e.g. diagnostic, experimental, develop options), use + * a 2-step model adding major release numbers to the obsolete and expire columns. + * + * To change the name of an option, use the alias table as well as a 2-step + * model adding major release numbers to the deprecate and expire columns. + * Think twice about aliasing commonly used customer options. + * + * There are times when it is appropriate to leave a future release number as undefined. + * * Tests: Aliases should be tested in VMAliasOptions.java. - * Deprecated options should be tested in VMDeprecatedOptions.java. + * Deprecated options should be tested in VMDeprecatedOptions.java. */ // Obsolete or deprecated -XX flag. typedef struct { const char* name; - JDK_Version warning_started_in; // When the warning started (obsolete or deprecated). - JDK_Version accept_until; // Which version to start denying the existence of the flag (if scheduled). + 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; -// When a flag is made obsolete, it can be added to this list in order to -// continue accepting this flag on the command-line, while issuing a warning -// and ignoring the value. Once the JDK version reaches the 'accept_until' -// limit, we flatly refuse to admit the existence of the flag. The 'accept_until' -// field can be set to undefined() if the expiration date has not yet been set. -// This table should be scrubbed of expired options on major JDK releases. -static SpecialFlag const obsolete_jvm_flags[] = { - { "UseOldInlining", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "SafepointPollOffset", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "UseBoundThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "DefaultThreadPriority", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "NoYieldsInMicrolock", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "BackEdgeThreshold", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "UseNewReflection", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "VerifyReflectionBytecodes", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "AutoShutdownNMT", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "NmethodSweepFraction", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "NmethodSweepCheckInterval", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "CodeCacheMinimumFreeSpace", JDK_Version::jdk(9), JDK_Version::jdk(10) }, +// 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 +// the command-line as usual, but will issue a warning. +// When the JDK version reaches 'obsolete_in' limit, the JVM will continue accepting this flag on +// the command-line, while issuing a warning and ignoring the flag value. +// Once the JDK version reaches 'expired_in' limit, the JVM will flatly refuse to admit the +// existence of the flag. +// +// MANUAL CLEANUP ON JDK VERSION UPDATES: +// This table ensures that the handling of options will update automatically when the JDK +// version is incremented, but the source code needs to be cleanup up manually: +// - As "deprecated" options age into "obsolete" or "expired" options, the associated "globals" +// variable should be removed, as well as users of the variable. +// - As "deprecated" options age into "obsolete" options, move the entry into the +// "Obsolete Flags" section of the table. +// - All expired options should be removed from the table. +static SpecialFlag const special_jvm_flags[] = { +#ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS + { "dep > obs", JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() }, + { "dep > exp ", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(8) }, + { "obs > exp ", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(8) }, + { "not deprecated or obsolete", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::undefined() }, + { "dup option", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() }, + { "dup option", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() }, + { "BytecodeVerificationRemote", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::undefined() }, +#endif + + // -------------- Deprecated Flags -------------- + // --- Non-alias flags - sorted by obsolete_in then expired_in: + { "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() }, + { "UseParNewGC", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) }, + + // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in: + { "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() }, + { "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() }, + { "CMSMarkStackSizeMax", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) }, + { "CMSMarkStackSize", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) }, + { "G1MarkStackSize", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) }, + { "ParallelMarkingThreads", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) }, + { "ParallelCMSThreads", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) }, + + // -------------- Obsolete Flags - sorted by expired_in -------------- + { "UseOldInlining", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "SafepointPollOffset", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "UseBoundThreads", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "DefaultThreadPriority", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "NoYieldsInMicrolock", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "BackEdgeThreshold", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "UseNewReflection", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "ReflectionWrapResolutionErrors",JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "VerifyReflectionBytecodes", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "AutoShutdownNMT", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "NmethodSweepFraction", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "NmethodSweepCheckInterval", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "CodeCacheMinimumFreeSpace", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, #ifndef ZERO - { "UseFastAccessorMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "UseFastEmptyMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "UseFastAccessorMethods", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "UseFastEmptyMethods", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, #endif // ZERO - { "UseCompilerSafepoints", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "AdaptiveSizePausePolicy", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "ParallelGCRetainPLAB", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "ThreadSafetyMargin", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "LazyBootClassLoader", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "StarvationMonitorInterval", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "PreInflateSpin", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { NULL, JDK_Version(0), JDK_Version(0) } -}; - -// When a flag is deprecated, it can be added to this list in order to issue a warning when the flag is used. -// Once the JDK version reaches the 'accept_until' limit, we flatly refuse to admit the existence of the flag. -// The 'accept_until' field can be set to undefined() if the expiration date has not yet been set. -// If a deprecated option should be treated as obsolete before it is expired, it needs to be removed -// from this table and added to the obsolete_jvm_flags table. -// This table should be scrubbed of expired options on major JDK releases. -static SpecialFlag const deprecated_jvm_flags[] = { - // deprecated non-alias flags: - { "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::undefined() }, - { "UseParNewGC", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - - // deprecated alias flags (see also aliased_jvm_flags): - { "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined() }, - { "CMSMarkStackSizeMax", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "CMSMarkStackSize", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "G1MarkStackSize", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "ParallelMarkingThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "ParallelCMSThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) }, - { "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined() }, + { "UseCompilerSafepoints", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "AdaptiveSizePausePolicy", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "ParallelGCRetainPLAB", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "ThreadSafetyMargin", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "LazyBootClassLoader", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "StarvationMonitorInterval", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "PreInflateSpin", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, { NULL, JDK_Version(0), JDK_Version(0) } }; @@ -360,35 +389,55 @@ { NULL, NULL} }; -// Returns 1 if the flag is special and jdk version is in the range specified. -// In this case the 'version' buffer is filled in with the version number when -// the flag became special. -// Returns -1 if the flag is special and has expired (should be ignored). -// Returns 0 if the flag is not special. -// Flag "flag_name" is a flag name stripped of '+', '-', and '='. -static int is_special_flag(const SpecialFlag special_table[], const char *flag_name, JDK_Version* version) { - assert(version != NULL, "Must provide a version buffer"); - for (size_t i = 0; special_table[i].name != NULL; i++) { - const SpecialFlag& flag_status = special_table[i]; - if ((strcmp(flag_status.name, flag_name) == 0)) { - if (flag_status.accept_until.is_undefined() || - JDK_Version::current().compare(flag_status.accept_until) == -1) { - *version = flag_status.warning_started_in; - return 1; - } else { - return -1; - } +// Return true if "v" is less than "other", where "other" may be "undefined". +static bool version_less_than(JDK_Version v, JDK_Version other) { + assert(!v.is_undefined(), "must be defined"); + if (!other.is_undefined() && v.compare(other) >= 0) { + return false; + } else { + return true; + } +} + +static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) { + 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]; + return true; } } - return 0; + return false; } bool Arguments::is_obsolete_flag(const char *flag_name, JDK_Version* version) { - return (is_special_flag(obsolete_jvm_flags, flag_name, version) == 1); + assert(version != NULL, "Must provide a version buffer"); + SpecialFlag flag; + if (lookup_special_flag(flag_name, flag)) { + if (!flag.obsolete_in.is_undefined()) { + if (version_less_than(JDK_Version::current(), flag.expired_in)) { + *version = flag.obsolete_in; + return true; + } + } + } + return false; } int Arguments::is_deprecated_flag(const char *flag_name, JDK_Version* version) { - return is_special_flag(deprecated_jvm_flags, flag_name, version); + assert(version != NULL, "Must provide a version buffer"); + SpecialFlag flag; + if (lookup_special_flag(flag_name, flag)) { + if (!flag.deprecated_in.is_undefined()) { + if (version_less_than(JDK_Version::current(), flag.obsolete_in) && + version_less_than(JDK_Version::current(), flag.expired_in)) { + *version = flag.deprecated_in; + return 1; + } else { + return -1; + } + } + } + return 0; } const char* Arguments::real_flag_name(const char *flag_name) { @@ -401,6 +450,72 @@ return flag_name; } +#ifndef PRODUCT +static bool lookup_special_flag(const char *flag_name, size_t skip_index) { + for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) { + if ((i != skip_index) && (strcmp(special_jvm_flags[i].name, flag_name) == 0)) { + return true; + } + } + return false; +} + +static bool verify_special_jvm_flags() { + bool success = true; + for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) { + const SpecialFlag& flag = special_jvm_flags[i]; + if (lookup_special_flag(flag.name, i)) { + warning("Duplicate special flag declaration \"%s\"", flag.name); + success = false; + } + if (flag.deprecated_in.is_undefined() && + flag.obsolete_in.is_undefined()) { + warning("Special flag entry \"%s\" must declare version deprecated and/or obsoleted in.", flag.name); + success = false; + } + + if (!flag.deprecated_in.is_undefined()) { + if (!version_less_than(flag.deprecated_in, flag.obsolete_in)) { + warning("Special flag entry \"%s\" must be deprecated before obsoleted.", flag.name); + success = false; + } + + if (!version_less_than(flag.deprecated_in, flag.expired_in)) { + warning("Special flag entry \"%s\" must be deprecated before expired.", flag.name); + success = false; + } + } + + if (!flag.obsolete_in.is_undefined()) { + if (!version_less_than(flag.obsolete_in, flag.expired_in)) { + warning("Special flag entry \"%s\" must be obsoleted before expired.", flag.name); + success = false; + } + + // if flag has become obsolete it should not have a "globals" flag defined anymore. + if (!version_less_than(JDK_Version::current(), flag.obsolete_in)) { + if (Flag::find_flag(flag.name) != NULL) { + warning("Global variable for obsolete special flag entry \"%s\" should be removed", flag.name); + success = false; + } + } + } + + if (!flag.expired_in.is_undefined()) { + // if flag has become expired it should not have a "globals" flag defined anymore. + if (!version_less_than(JDK_Version::current(), flag.expired_in)) { + if (Flag::find_flag(flag.name) != NULL) { + warning("Global variable for expired flag entry \"%s\" should be removed", flag.name); + success = false; + } + } + } + + } + return success; +} +#endif + // Constructs the system class path (aka boot class path) from the following // components, in order: // @@ -778,7 +893,7 @@ JDK_Version since = JDK_Version(); switch (is_deprecated_flag(arg, &since)) { case -1: - return NULL; + return NULL; // obsolete or expired, don't process normally case 0: return real_name; case 1: { @@ -1994,7 +2109,7 @@ // intensive jobs. It is intended for machines with large // amounts of cpu and memory. jint Arguments::set_aggressive_heap_flags() { - // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit + // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit // VM, but we may not be able to represent the total physical memory // available (like having 8gb of memory on a box but using a 32bit VM). // Thus, we need to make sure we're using a julong for intermediate @@ -3747,6 +3862,7 @@ // Parse entry point called from JNI_CreateJavaVM jint Arguments::parse(const JavaVMInitArgs* args) { + assert(verify_special_jvm_flags(), "deprecated and obsolete flag table inconsistent"); // Initialize ranges and constraints CommandLineFlagRangeList::init(); --- old/src/share/vm/runtime/arguments.hpp 2015-08-27 17:40:00.535664974 -0400 +++ new/src/share/vm/runtime/arguments.hpp 2015-08-27 17:40:00.394666737 -0400 @@ -417,16 +417,16 @@ short* methodsNum, short* methodsMax, char*** methods, bool** allClasses ); - // Returns true if the flag is obsolete and fits into the range specified - // for being ignored. In the case the 'version' buffer is filled in with + // Returns true if the flag is obsolete (and not yet expired). + // In this case the 'version' buffer is filled in with // the version number when the flag became obsolete. static bool is_obsolete_flag(const char* flag_name, JDK_Version* version); - // Returns 1 if the flag is deprecated and jdk version is in the range specified. + // 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 // the flag became deprecated. - // Returns -1 if the flag is deprecated and has expired (should be ignored). - // Returns 0 if the flag is not deprecated. + // Returns -1 if the flag is expired or obsolete. + // Returns 0 otherwise. static int is_deprecated_flag(const char* flag_name, JDK_Version* version); // Return the real name for the flag passed on the command line (either an alias name or "flag_name"). --- old/test/testlibrary/jdk/test/lib/cli/CommandLineOptionTest.java 2015-08-27 17:40:01.112657761 -0400 +++ new/test/testlibrary/jdk/test/lib/cli/CommandLineOptionTest.java 2015-08-27 17:40:00.980659411 -0400 @@ -262,78 +262,11 @@ /** * Start VM with given options and values. - * Generates command line option flags from + * Generates command line option flags from * {@code optionNames} and {@code optionValues}. - * - * @param optionNames names of options to pass in - * @param optionValues values of options - * @param additionalVMOpts additional options that should be - * passed to JVM. - * @return output from vm process - */ - public static OutputAnalyzer startVMWithOptions(String[] optionNames, - String[] optionValues, - String... additionalVMOpts) throws Throwable { - List vmOpts = new ArrayList<>(); - if (optionNames == null || optionValues == null || optionNames.length != optionValues.length) { - throw new IllegalArgumentException("optionNames and/or optionValues"); - } - - for (int i = 0; i < optionNames.length; i++) { - vmOpts.add(prepareFlag(optionNames[i], optionValues[i])); - } - Collections.addAll(vmOpts, additionalVMOpts); - Collections.addAll(vmOpts, "-version"); - - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( - vmOpts.toArray(new String[vmOpts.size()])); - - return new OutputAnalyzer(processBuilder.start()); - } - - /** - * Verifies from the output that values of specified JVM options were the same as - * expected values. * - * @param outputAnalyzer search output for expect options and values. - * @param optionNames names of tested options. - * @param expectedValues expected values of tested options. - * @throws Throwable if verification fails or some other issues occur. - */ - public static void verifyOptionValuesFromOutput(OutputAnalyzer outputAnalyzer, - String[] optionNames, - String[] expectedValues) throws Throwable { - outputAnalyzer.shouldHaveExitValue(0); - for (int i = 0; i < optionNames.length; i++) { - outputAnalyzer.shouldMatch(String.format( - CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT, - optionNames[i], expectedValues[i])); - } - } - - /** - * Verifies that value of specified JVM options are the same as - * expected values. - * Generates command line option flags from - * {@code optionNames} and {@code expectedValues}. - * - * @param optionNames names of tested options. - * @param expectedValues expected values of tested options. - * @throws Throwable if verification fails or some other issues occur. - */ - public static void verifyOptionValues(String[] optionNames, - String[] expectedValues) throws Throwable { - OutputAnalyzer outputAnalyzer = startVMWithOptions(optionNames, expectedValues, "-XX:+PrintFlagsFinal"); - verifyOptionValuesFromOutput(outputAnalyzer, optionNames, expectedValues); - } - - /** - * Start VM with given options and values. - * Generates command line option flags from - * {@code optionNames} and {@code optionValues}. - * * @param optionNames names of options to pass in - * @param optionValues values of options + * @param optionValues values of option * @param additionalVMOpts additional options that should be * passed to JVM. * @return output from vm process @@ -377,80 +310,13 @@ optionNames[i], expectedValues[i])); } } - - /** - * Verifies that value of specified JVM options are the same as - * expected values. - * Generates command line option flags from - * {@code optionNames} and {@code expectedValues}. - * - * @param optionNames names of tested options. - * @param expectedValues expected values of tested options. - * @throws Throwable if verification fails or some other issues occur. - */ - public static void verifyOptionValues(String[] optionNames, - String[] expectedValues) throws Throwable { - OutputAnalyzer outputAnalyzer = startVMWithOptions(optionNames, expectedValues, "-XX:+PrintFlagsFinal"); - verifyOptionValuesFromOutput(outputAnalyzer, optionNames, expectedValues); - } - - /** - * Start VM with given options and values. - * Generates command line option flags from - * {@code optionNames} and {@code optionValues}. - * - * @param optionNames names of options to pass in - * @param optionValues values of options - * @param additionalVMOpts additional options that should be - * passed to JVM. - * @return output from vm process - */ - public static OutputAnalyzer startVMWithOptions(String[] optionNames, - String[] optionValues, - String... additionalVMOpts) throws Throwable { - List vmOpts = new ArrayList<>(); - if (optionNames == null || optionValues == null || optionNames.length != optionValues.length) { - throw new IllegalArgumentException("optionNames and/or optionValues"); - } - - for (int i = 0; i < optionNames.length; i++) { - vmOpts.add(prepareFlag(optionNames[i], optionValues[i])); - } - Collections.addAll(vmOpts, additionalVMOpts); - Collections.addAll(vmOpts, "-version"); - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( - vmOpts.toArray(new String[vmOpts.size()])); - - return new OutputAnalyzer(processBuilder.start()); - } - - /** - * Verifies from the output that values of specified JVM options were the same as - * expected values. - * - * @param outputAnalyzer search output for expect options and values. - * @param optionNames names of tested options. - * @param expectedValues expected values of tested options. - * @throws Throwable if verification fails or some other issues occur. - */ - public static void verifyOptionValuesFromOutput(OutputAnalyzer outputAnalyzer, - String[] optionNames, - String[] expectedValues) throws Throwable { - outputAnalyzer.shouldHaveExitValue(0); - for (int i = 0; i < optionNames.length; i++) { - outputAnalyzer.shouldMatch(String.format( - CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT, - optionNames[i], expectedValues[i])); - } - } - /** * Verifies that value of specified JVM options are the same as * expected values. - * Generates command line option flags from + * Generates command line option flags from * {@code optionNames} and {@code expectedValues}. - * + * * @param optionNames names of tested options. * @param expectedValues expected values of tested options. * @throws Throwable if verification fails or some other issues occur. @@ -513,42 +379,6 @@ } /** - * Prepares generic command line flag with name {@code name} by setting - * it's value to {@code value}. - * - * @param name the name of option to be prepared - * @param value the value of option ("+" or "-" can be used instead of "true" or "false") - * @return prepared command line flag - */ - public static String prepareFlag(String name, String value) { - if (value.equals("+") || value.equalsIgnoreCase("true")) { - return "-XX:+" + name; - } else if (value.equals("-") || value.equalsIgnoreCase("false")) { - return "-XX:-" + name; - } else { - return "-XX:" + name + "=" + value; - } - } - - /** - * Prepares generic command line flag with name {@code name} by setting - * it's value to {@code value}. - * - * @param name the name of option to be prepared - * @param value the value of option ("+" or "-" can be used instead of "true" or "false") - * @return prepared command line flag - */ - public static String prepareFlag(String name, String value) { - if (value.equals("+") || value.equalsIgnoreCase("true")) { - return "-XX:+" + name; - } else if (value.equals("-") || value.equalsIgnoreCase("false")) { - return "-XX:-" + name; - } else { - return "-XX:" + name + "=" + value; - } - } - - /** * Prepares generic command line flag with name {@code name} by setting * it's value to {@code value}. * --- /dev/null 2015-08-21 20:45:33.911857331 -0400 +++ new/test/runtime/CommandLine/VMAliasOptions.java 2015-08-27 17:40:01.717650197 -0400 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2015, 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. + */ + +import jdk.test.lib.*; +import jdk.test.lib.cli.*; + +/* + * @test + * @bug 8061611 + * @summary Test that various alias options correctly set the target options. See aliased_jvm_flags in arguments.cpp. + * @library /testlibrary + */ +public class VMAliasOptions { + + /** + * each entry is {[0]: alias name, [1]: alias target, [2]: value to set + * (true/false/n/string)}. + */ + public static final String[][] ALIAS_OPTIONS = { + {"DefaultMaxRAMFraction", "MaxRAMFraction", "1032"}, + {"CMSMarkStackSizeMax", "MarkStackSizeMax", "1032"}, + {"CMSMarkStackSize", "MarkStackSize", "1032"}, + {"G1MarkStackSize", "MarkStackSize", "1032"}, + {"ParallelMarkingThreads", "ConcGCThreads", "2"}, + {"ParallelCMSThreads", "ConcGCThreads", "2"}, + {"CreateMinidumpOnCrash", "CreateCoredumpOnCrash", "false" }, + }; + + static void testAliases(String[][] optionInfo) throws Throwable { + String aliasNames[] = new String[optionInfo.length]; + String optionNames[] = new String[optionInfo.length]; + String expectedValues[] = new String[optionInfo.length]; + for (int i = 0; i < optionInfo.length; i++) { + aliasNames[i] = optionInfo[i][0]; + optionNames[i] = optionInfo[i][1]; + expectedValues[i] = optionInfo[i][2]; + } + + OutputAnalyzer output = CommandLineOptionTest.startVMWithOptions(aliasNames, expectedValues, "-XX:+PrintFlagsFinal"); + CommandLineOptionTest.verifyOptionValuesFromOutput(output, optionNames, expectedValues); + } + + public static void main(String[] args) throws Throwable { + testAliases(ALIAS_OPTIONS); + } +} --- /dev/null 2015-08-21 20:45:33.911857331 -0400 +++ new/test/runtime/CommandLine/VMDeprecatedOptions.java 2015-08-27 17:40:02.416641459 -0400 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2015, 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. + */ + +import jdk.test.lib.*; +import jdk.test.lib.cli.*; + +/* + * @test + * @bug 8066821 + * @summary Test that various options are deprecated. See deprecated_jvm_flags in arguments.cpp. + * @library /testlibrary + */ +public class VMDeprecatedOptions { + + /** + * each entry is {[0]: option name, [1]: value to set + * (true/false/n/string)}. + */ + public static final String[][] DEPRECATED_OPTIONS = { + // deprecated non-alias flags: + {"MaxGCMinorPauseMillis", "1032"}, + {"UseParNewGC", "false"}, + + // deprecated alias flags (see also aliased_jvm_flags): + {"DefaultMaxRAMFraction", "4"}, + {"CMSMarkStackSizeMax", "1032"}, + {"CMSMarkStackSize", "1032"}, + {"G1MarkStackSize", "1032"}, + {"ParallelMarkingThreads", "2"}, + {"ParallelCMSThreads", "2"}, + {"CreateMinidumpOnCrash", "false"} + }; + + static String getDeprecationString(String optionName) { + return "Option " + optionName + + " was deprecated in version [\\S]+ and will likely be removed in a future release"; + } + + static void testDeprecated(String[][] optionInfo) throws Throwable { + String optionNames[] = new String[optionInfo.length]; + String expectedValues[] = new String[optionInfo.length]; + for (int i = 0; i < optionInfo.length; i++) { + optionNames[i] = optionInfo[i][0]; + expectedValues[i] = optionInfo[i][1]; + } + + OutputAnalyzer output = CommandLineOptionTest.startVMWithOptions(optionNames, expectedValues); + + // check for option deprecation messages: + output.shouldHaveExitValue(0); + for (String[] deprecated : optionInfo) { + String match = getDeprecationString(deprecated[0]); + output.shouldMatch(match); + } + } + + public static void main(String[] args) throws Throwable { + testDeprecated(DEPRECATED_OPTIONS); // Make sure that each deprecated option is mentioned in the output. + } +}