--- old/src/share/vm/runtime/arguments.cpp 2015-01-15 17:50:19.736636672 -0500 +++ new/src/share/vm/runtime/arguments.cpp 2015-01-15 17:50:18.732579601 -0500 @@ -247,21 +247,60 @@ new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(), false)); } -/** - * Provide a slightly more user-friendly way of eliminating -XX flags. - * When a flag is eliminated, 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. This allows - * a flag to die correctly over JDK releases using HSX. +/* + * -XX argument processing: + * + * -XX arguments are usually defined in 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: + * + * ALIAS: An option may be renamed or replaced by another option. The old name can be supported by adding + * the old and new option names to the "aliased_jvm_flags" table. Delete the old variable from globals.hpp. + * This is often part of the process of deprecating a flag, but not all aliases need to be deprecated. + * + * DEPRECATED: An option may be 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. + * Specify the option name, the jdk version that deprecated the option, and the jdk version that will + * expire the option (if removal has been scheduled). + * + * OBSOLETE: An option may be removed (and deleted from globals.hpp), but still be accepted on the command line. + * A warning is printed to let the user know that support may be removed in the future. + * Add an obsolete warning for an option (or alias) by adding an entry in the "obsolete_jvm_flags" table. + * Specify the option name, the jdk version that obsoleted the option, and the jdk version that will + * expire the option (if removal has been scheduled). + * + * EXPIRED: When the current JDK version is equal or greater to the "accept_until" version of a deprecated or obsolete + * option, the system will flatly refuse to admit the existence of the flag. This allows a flag to die correctly + * over JDK releases using HSX. + * Note that manual cleanup of expired options should be done at major JDK version upgrades: + * - Expired options can be removed from the obsolete_jvm_flags, deprecated_jvm_flags tables, and aliased_jvm_flags tables. + * - Expired deprecated options may still have global variable definitions that should be removed (in globals.hpp, etc). + * + * Tests: Aliases are tested in VMAliasOptions.java. Deprecated options in VMDeprecatedOptions.java. Obsolete options are tested in various files. */ + +// Obsolete or deprecated -XX flag. typedef struct { const char* name; - JDK_Version obsoleted_in; // when the flag went away - JDK_Version accept_until; // which version to start denying the existence -} ObsoleteFlag; - -static ObsoleteFlag obsolete_jvm_flags[] = { + JDK_Version obsoleted_in; // When the warning started (obsolete or deprecated). + JDK_Version accept_until; // Which version to start denying the existence of the flag (if scheduled). + + static const uint8_t _removal_unscheduled = 0; + + bool is_removal_scheduled() const { + return accept_until.major_version() != _removal_unscheduled; + } + +} SpecialFlag; + +// When a flag is eliminated, 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. +static SpecialFlag const obsolete_jvm_flags[] = { { "UseTrainGC", JDK_Version::jdk(5), JDK_Version::jdk(7) }, { "UseSpecialLargeObjectHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) }, { "UseOversizedCarHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) }, @@ -294,16 +333,17 @@ JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) }, { "AllowTransitionalJSR292", JDK_Version::jdk(7), JDK_Version::jdk(8) }, { "UseCompressedStrings", JDK_Version::jdk(7), JDK_Version::jdk(8) }, - { "CMSPermGenPrecleaningEnabled", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "CMSTriggerPermRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "CMSInitiatingPermOccupancyFraction", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "AdaptivePermSizeWeight", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "PermGenPadding", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "PermMarkSweepDeadRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "PermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "MaxPermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "MinPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "MaxPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "CMSPermGenPrecleaningEnabled", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "CMSTriggerPermRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "CMSInitiatingPermOccupancyFraction", + JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "AdaptivePermSizeWeight", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "PermGenPadding", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "PermMarkSweepDeadRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "PermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "MaxPermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "MinPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "MaxPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) }, { "CMSRevisitStackSize", JDK_Version::jdk(8), JDK_Version::jdk(9) }, { "PrintRevisitStats", JDK_Version::jdk(8), JDK_Version::jdk(9) }, { "UseVectoredExceptions", JDK_Version::jdk(8), JDK_Version::jdk(9) }, @@ -315,8 +355,7 @@ { "UseOldInlining", JDK_Version::jdk(9), JDK_Version::jdk(10) }, { "SafepointPollOffset", JDK_Version::jdk(9), JDK_Version::jdk(10) }, #ifdef PRODUCT - { "DesiredMethodLimit", - JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) }, + { "DesiredMethodLimit", JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) }, #endif // PRODUCT { "UseVMInterruptibleIO", JDK_Version::jdk(8), JDK_Version::jdk(9) }, { "UseBoundThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) }, @@ -338,31 +377,90 @@ { NULL, JDK_Version(0), JDK_Version(0) } }; -// Returns true if the flag is obsolete and fits into the range specified -// for being ignored. In the case that the flag is ignored, the 'version' -// value is filled in with the version number when the flag became -// obsolete so that that value can be displayed to the user. -bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) { +// When a flag is deprecated, it can be added to this list in order to issuing 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. +static SpecialFlag const deprecated_jvm_flags[] = { + // deprecated non-alias flags: + { "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::jdk(SpecialFlag::_removal_unscheduled) }, + { "UseParNewGC", JDK_Version::jdk(9), JDK_Version::jdk(10) }, + + // deprecated alias flags (see also aliased_jvm_flags): + { "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::jdk(SpecialFlag::_removal_unscheduled) }, + { "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) }, + { NULL, JDK_Version(0), JDK_Version(0) } +}; + +// Flags that are aliases for other flags. +typedef struct { + const char* alias_name; + const char* real_name; +} AliasedFlag; + +static AliasedFlag const aliased_jvm_flags[] = { + { "DefaultMaxRAMFraction", "MaxRAMFraction" }, + { "CMSMarkStackSizeMax", "MarkStackSizeMax" }, + { "CMSMarkStackSize", "MarkStackSize" }, + { "G1MarkStackSize", "MarkStackSize" }, + { "ParallelMarkingThreads", "ConcGCThreads" }, + { "ParallelCMSThreads", "ConcGCThreads" }, + { 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. +static int is_special_flag(const SpecialFlag special_table[], const char *s, JDK_Version* version) { int i = 0; assert(version != NULL, "Must provide a version buffer"); - while (obsolete_jvm_flags[i].name != NULL) { - const ObsoleteFlag& flag_status = obsolete_jvm_flags[i]; + while (special_table[i].name != NULL) { + const SpecialFlag& flag_status = special_table[i]; // =xxx form // [-|+] form size_t len = strlen(flag_status.name); if (((strncmp(flag_status.name, s, len) == 0) && - (strlen(s) == len)) || - ((s[0] == '+' || s[0] == '-') && - (strncmp(flag_status.name, &s[1], len) == 0) && - (strlen(&s[1]) == len))) { - if (JDK_Version::current().compare(flag_status.accept_until) == -1) { - *version = flag_status.obsoleted_in; - return true; + (strlen(s) == len)) || + ((s[0] == '+' || s[0] == '-') && + (strncmp(flag_status.name, &s[1], len) == 0) && + (strlen(&s[1]) == len))) { + if (!flag_status.is_removal_scheduled() || + JDK_Version::current().compare(flag_status.accept_until) == -1) { + *version = flag_status.obsoleted_in; + return 1; + } else { + return -1; } } i++; } - return false; + return 0; +} + +bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) { + return (is_special_flag(obsolete_jvm_flags, s, version) == 1); +} + +int Arguments::is_deprecated_flag(const char *s, JDK_Version* version) { + return is_special_flag(deprecated_jvm_flags, s, version); +} + +const char* Arguments::real_flag_name(const char *flag_name) { + int i = 0; + while (aliased_jvm_flags[i].alias_name != NULL) { + const AliasedFlag& flag_status = aliased_jvm_flags[i]; + size_t len = strlen(flag_status.alias_name); + if (((strncmp(flag_status.alias_name, flag_name, len) == 0) && + (strlen(flag_name) == len))) { + return flag_status.real_name; + } + i++; + } + return flag_name; } // Constructs the system class path (aka boot class path) from the following @@ -633,11 +731,11 @@ } } -static bool set_bool_flag(char* name, bool value, Flag::Flags origin) { +static bool set_bool_flag(const char* name, bool value, Flag::Flags origin) { return CommandLineFlags::boolAtPut(name, &value, origin); } -static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) { +static bool set_fp_numeric_flag(const char* name, char* value, Flag::Flags origin) { double v; if (sscanf(value, "%lf", &v) != 1) { return false; @@ -649,7 +747,7 @@ return false; } -static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) { +static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) { julong v; intx intx_v; bool is_neg = false; @@ -686,14 +784,14 @@ return false; } -static bool set_string_flag(char* name, const char* value, Flag::Flags origin) { +static bool set_string_flag(const char* name, const char* value, Flag::Flags origin) { if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false; // Contract: CommandLineFlags always returns a pointer that needs freeing. FREE_C_HEAP_ARRAY(char, value); return true; } -static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags origin) { +static bool append_to_string_flag(const char* name, const char* new_value, Flag::Flags origin) { const char* old_value = ""; if (!CommandLineFlags::ccstrAt(name, &old_value)) return false; size_t old_len = old_value != NULL ? strlen(old_value) : 0; @@ -721,6 +819,31 @@ return true; } +const char* Arguments::handle_aliases_and_deprecation(const char* arg) { + const char* real_name = real_flag_name(arg); + JDK_Version since = JDK_Version(); + switch (is_deprecated_flag(arg, &since)) { + case -1: + return NULL; + case 0: + return real_name; + case 1: { + char version[256]; + since.to_string(version, sizeof(version)); + if (real_name != arg) { + warning("option %s was deprecated in version %s and will likely be removed in a future release. Use option %s instead.", + arg, version, real_name); + } else { + warning("option %s was deprecated in version %s and will likely be removed in a future release.", + arg, version); + } + return real_name; + } + } + ShouldNotReachHere(); + return NULL; +} + bool Arguments::parse_argument(const char* arg, Flag::Flags origin) { // range of acceptable characters spelled out for portability reasons @@ -728,26 +851,41 @@ #define BUFLEN 255 char name[BUFLEN+1]; char dummy; - + const char* real_name; + if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) { - return set_bool_flag(name, false, origin); + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; // "name" is a deprecated option that has expired. + } + return set_bool_flag(real_name, false, origin); } if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) { - return set_bool_flag(name, true, origin); + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; + } + return set_bool_flag(real_name, true, origin); } char punct; if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') { const char* value = strchr(arg, '=') + 1; - Flag* flag = Flag::find_flag(name, strlen(name)); + Flag* flag; + + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; + } + flag = Flag::find_flag(real_name, strlen(real_name)); if (flag != NULL && flag->is_ccstr()) { if (flag->ccstr_accumulates()) { - return append_to_string_flag(name, value, origin); + return append_to_string_flag(real_name, value, origin); } else { if (value[0] == '\0') { value = NULL; } - return set_string_flag(name, value, origin); + return set_string_flag(real_name, value, origin); } } } @@ -758,7 +896,11 @@ if (value[0] == '\0') { value = NULL; } - return set_string_flag(name, value, origin); + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; + } + return set_string_flag(real_name, value, origin); } #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]" @@ -769,13 +911,21 @@ if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) { // Looks like a floating-point number -- try again with more lenient format string if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) { - return set_fp_numeric_flag(name, value, origin); + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; + } + return set_fp_numeric_flag(real_name, value, origin); } } #define VALUE_RANGE "[-kmgtxKMGTX0123456789abcdefABCDEF]" if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) { - return set_numeric_flag(name, value, origin); + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; + } + return set_numeric_flag(real_name, value, origin); } return false; @@ -1744,7 +1894,6 @@ } else if (UseG1GC) { set_g1_gc_flags(); } - check_deprecated_gc_flags(); if (AssumeMP && !UseSerialGC) { if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) { warning("If the number of processors is expected to increase from one, then" @@ -1774,11 +1923,6 @@ static const uintx DefaultHeapBaseMinAddress = HeapBaseMinAddress; void Arguments::set_heap_size() { - if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) { - // Deprecated flag - FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction); - } - const julong phys_mem = FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM) : (julong)MaxRAM; @@ -2136,20 +2280,6 @@ return true; } -void Arguments::check_deprecated_gc_flags() { - if (FLAG_IS_CMDLINE(UseParNewGC)) { - warning("The UseParNewGC flag is deprecated and will likely be removed in a future release"); - } - if (FLAG_IS_CMDLINE(MaxGCMinorPauseMillis)) { - warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated" - "and will likely be removed in future release"); - } - if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) { - warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. " - "Use MaxRAMFraction instead."); - } -} - // Check stack pages settings bool Arguments::check_stack_pages() { @@ -2386,7 +2516,6 @@ status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction"); status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction"); status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction"); - status = status && verify_min_value(DefaultMaxRAMFraction, 1, "DefaultMaxRAMFraction"); status = status && verify_interval(AdaptiveTimeWeight, 0, 100, "AdaptiveTimeWeight"); status = status && verify_min_value(AdaptiveSizeDecrementScaleFactor, 1, "AdaptiveSizeDecrementScaleFactor"); @@ -3223,46 +3352,6 @@ // disable scavenge before parallel mark-compact FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); #endif - } else if (match_option(option, "-XX:CMSMarkStackSize=", &tail) || - match_option(option, "-XX:G1MarkStackSize=", &tail)) { - julong stack_size = 0; - ArgsRange errcode = parse_memory_size(tail, &stack_size, 1); - if (errcode != arg_in_range) { - jio_fprintf(defaultStream::error_stream(), - "Invalid mark stack size: %s\n", option->optionString); - describe_range_error(errcode); - return JNI_EINVAL; - } - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:MarkStackSize in place of " - "-XX:CMSMarkStackSize or -XX:G1MarkStackSize in the future\n"); - FLAG_SET_CMDLINE(uintx, MarkStackSize, stack_size); - } else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) { - julong max_stack_size = 0; - ArgsRange errcode = parse_memory_size(tail, &max_stack_size, 1); - if (errcode != arg_in_range) { - jio_fprintf(defaultStream::error_stream(), - "Invalid maximum mark stack size: %s\n", - option->optionString); - describe_range_error(errcode); - return JNI_EINVAL; - } - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:MarkStackSizeMax in place of " - "-XX:CMSMarkStackSizeMax in the future\n"); - FLAG_SET_CMDLINE(uintx, MarkStackSizeMax, max_stack_size); - } else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) || - match_option(option, "-XX:ParallelCMSThreads=", &tail)) { - uintx conc_threads = 0; - if (!parse_uintx(tail, &conc_threads, 1)) { - jio_fprintf(defaultStream::error_stream(), - "Invalid concurrent threads: %s\n", option->optionString); - return JNI_EINVAL; - } - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:ConcGCThreads in place of " - "-XX:ParallelMarkingThreads or -XX:ParallelCMSThreads in the future\n"); - FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads); } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) { julong max_direct_memory_size = 0; ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0); --- old/src/share/vm/runtime/arguments.hpp 2015-01-15 17:50:22.964820157 -0500 +++ new/src/share/vm/runtime/arguments.hpp 2015-01-15 17:50:21.972763770 -0500 @@ -426,11 +426,24 @@ short* methodsNum, short* methodsMax, char*** methods, bool** allClasses ); - // Returns true if the string s is in the list of flags that have recently - // been made obsolete. If we detect one of these flags on the command - // line, instead of failing we print a warning message and ignore the - // flag. This gives the user a release or so to stop using the flag. - static bool is_newly_obsolete(const char* s, JDK_Version* buffer); + // 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 + // the version number when the flag became obsolete. Otherwise the flag has + // expired and should be ignored. + static bool is_newly_obsolete(const char* s, JDK_Version* version); + + // Returns 1 if the flag is deprecated 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 deprecated. + // Returns -1 if the flag is deprecated and has expired (should be ignored). + // Returns 0 if the flag is not deprecated. + static int is_deprecated_flag(const char* s, JDK_Version* version); + + // Return the real name for the flag passed on the command line. + static const char* real_flag_name(const char *flag_name); + + // Return the "real" name for option arg if arg is an alias, and print a warning if arg is deprecated. + static const char* handle_aliases_and_deprecation(const char* arg); static short CompileOnlyClassesNum; static short CompileOnlyClassesMax; @@ -474,7 +487,6 @@ // Check for consistency in the selection of the garbage collector. static bool check_gc_consistency_user(); // Check user-selected gc static inline bool check_gc_consistency_ergo(); // Check ergonomic-selected gc - static void check_deprecated_gc_flags(); // Check consistency or otherwise of VM argument settings static bool check_vm_args_consistency(); // Check stack pages settings --- old/src/share/vm/runtime/globals.hpp 2015-01-15 17:50:26.088997730 -0500 +++ new/src/share/vm/runtime/globals.hpp 2015-01-15 17:50:25.068939752 -0500 @@ -2037,10 +2037,6 @@ "Maximum fraction (1/n) of real memory used for maximum heap " \ "size") \ \ - product(uintx, DefaultMaxRAMFraction, 4, \ - "Maximum fraction (1/n) of real memory used for maximum heap " \ - "size; deprecated: to be renamed to MaxRAMFraction") \ - \ product(uintx, MinRAMFraction, 2, \ "Minimum fraction (1/n) of real memory used for maximum heap " \ "size on systems with small physical memory size") \ --- old/test/TEST.groups 2015-01-15 17:50:29.265178259 -0500 +++ new/test/TEST.groups 2015-01-15 17:50:28.257120965 -0500 @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 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 @@ -179,7 +179,6 @@ gc/g1/TestShrinkToOneRegion.java \ gc/metaspace/G1AddMetaspaceDependency.java \ gc/startup_warnings/TestCMS.java \ - gc/startup_warnings/TestDefaultMaxRAMFraction.java \ gc/startup_warnings/TestDefNewCMS.java \ gc/startup_warnings/TestParallelGC.java \ gc/startup_warnings/TestParallelScavengeSerialOld.java \ --- old/test/gc/startup_warnings/TestParNewCMS.java 2015-01-15 17:50:32.357354012 -0500 +++ new/test/gc/startup_warnings/TestParNewCMS.java 2015-01-15 17:50:31.345296489 -0500 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2013, 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 @@ -38,7 +38,7 @@ public static void main(String args[]) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseParNewGC", "-XX:+UseConcMarkSweepGC", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("warning: The UseParNewGC flag is deprecated and will likely be removed in a future release"); + output.shouldContain("warning: option UseParNewGC was deprecated in version"); output.shouldNotContain("error"); output.shouldHaveExitValue(0); } --- old/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java 2015-01-15 17:50:35.473531128 -0500 +++ new/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java 2015-01-15 17:50:34.469474060 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -261,6 +261,73 @@ } /** + * 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 + * {@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); + } + + /** * Verifies that value of specified JVM when type of newly started VM * is the same as the type of current. * This method filter out option with {@code optionName} @@ -310,6 +377,24 @@ public static String prepareNumericFlag(String name, Number value) { return String.format("-XX:%s=%s", name, value.toString()); } + + /** + * 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; + } + } /** * Returns message that should occur in VM output if option --- /dev/null 2014-12-13 10:35:39.117184000 -0500 +++ new/test/runtime/CommandLine/VMAliasOptions.java 2015-01-15 17:50:37.557649584 -0500 @@ -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 com.oracle.java.testlibrary.OutputAnalyzer; +import com.oracle.java.testlibrary.cli.CommandLineOptionTest; + +/* + * @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", "77"}, + {"ParallelCMSThreads", "ConcGCThreads", "77"} + }; + + 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 2014-12-13 10:35:39.117184000 -0500 +++ new/test/runtime/CommandLine/VMDeprecatedOptions.java 2015-01-15 17:50:40.649825334 -0500 @@ -0,0 +1,79 @@ +/* + * 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 com.oracle.java.testlibrary.OutputAnalyzer; +import com.oracle.java.testlibrary.cli.CommandLineOptionTest; + +/* + * @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", "77"}, + {"ParallelCMSThreads", "77"} + }; + + 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. + } +} --- old/test/gc/startup_warnings/TestDefaultMaxRAMFraction.java 2015-01-15 17:50:44.650052693 -0500 +++ /dev/null 2014-12-13 10:35:39.117184000 -0500 @@ -1,44 +0,0 @@ -/* -* 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. -*/ - -/* -* @test TestDefaultMaxRAMFraction -* @key gc -* @bug 8021967 -* @summary Test that the deprecated TestDefaultMaxRAMFraction flag print a warning message -* @library /testlibrary -*/ - -import com.oracle.java.testlibrary.OutputAnalyzer; -import com.oracle.java.testlibrary.ProcessTools; - -public class TestDefaultMaxRAMFraction { - public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:DefaultMaxRAMFraction=4", "-version"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("warning: DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. Use MaxRAMFraction instead."); - output.shouldNotContain("error"); - output.shouldHaveExitValue(0); - } - -} --- old/test/gc/startup_warnings/TestNoParNew.java 2015-01-15 17:50:46.662167054 -0500 +++ /dev/null 2014-12-13 10:35:39.117184000 -0500 @@ -1,46 +0,0 @@ -/* -* Copyright (c) 2014, 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 TestNoParNew -* @key gc -* @bug 8065972 -* @summary Test that specifying -XX:-UseParNewGC on the command line logs a warning message -* @library /testlibrary -*/ - -import com.oracle.java.testlibrary.OutputAnalyzer; -import com.oracle.java.testlibrary.ProcessTools; - - -public class TestNoParNew { - - public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:-UseParNewGC", "-version"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("warning: The UseParNewGC flag is deprecated and will likely be removed in a future release"); - output.shouldNotContain("error"); - output.shouldHaveExitValue(0); - } - -}