Skip to content

Commit fa9c865

Browse files
weixluDavid Holmes
authored andcommitted
8273112: -Xloggc:<filename> should override -verbose:gc
Reviewed-by: iklam, dholmes
1 parent dd87181 commit fa9c865

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/hotspot/share/runtime/arguments.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ char** Arguments::_jvm_args_array = NULL;
7272
int Arguments::_num_jvm_args = 0;
7373
char* Arguments::_java_command = NULL;
7474
SystemProperty* Arguments::_system_properties = NULL;
75-
const char* Arguments::_gc_log_filename = NULL;
7675
size_t Arguments::_conservative_max_heap_alignment = 0;
7776
Arguments::Mode Arguments::_mode = _mixed;
7877
bool Arguments::_java_compiler = false;
@@ -93,6 +92,8 @@ bool Arguments::_enable_preview = false;
9392
char* Arguments::SharedArchivePath = NULL;
9493
char* Arguments::SharedDynamicArchivePath = NULL;
9594

95+
LegacyGCLogging Arguments::_legacyGCLogging = { 0, 0 };
96+
9697
AgentLibraryList Arguments::_libraryList;
9798
AgentLibraryList Arguments::_agentList;
9899

@@ -2332,7 +2333,9 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
23322333
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(module, load));
23332334
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(module, unload));
23342335
} else if (!strcmp(tail, ":gc")) {
2335-
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc));
2336+
if (_legacyGCLogging.lastFlag == 0) {
2337+
_legacyGCLogging.lastFlag = 1;
2338+
}
23362339
} else if (!strcmp(tail, ":jni")) {
23372340
LogConfiguration::configure_stdout(LogLevel::Debug, true, LOG_TAGS(jni, resolve));
23382341
}
@@ -2739,7 +2742,8 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
27392742
} else if (match_option(option, "-Xloggc:", &tail)) {
27402743
// Deprecated flag to redirect GC output to a file. -Xloggc:<filename>
27412744
log_warning(gc)("-Xloggc is deprecated. Will use -Xlog:gc:%s instead.", tail);
2742-
_gc_log_filename = os::strdup_check_oom(tail);
2745+
_legacyGCLogging.lastFlag = 2;
2746+
_legacyGCLogging.file = os::strdup_check_oom(tail);
27432747
} else if (match_option(option, "-Xlog", &tail)) {
27442748
bool ret = false;
27452749
if (strcmp(tail, ":help") == 0) {
@@ -3727,14 +3731,14 @@ bool Arguments::handle_deprecated_print_gc_flags() {
37273731
log_warning(gc)("-XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead.");
37283732
}
37293733

3730-
if (_gc_log_filename != NULL) {
3734+
if (_legacyGCLogging.lastFlag == 2) {
37313735
// -Xloggc was used to specify a filename
37323736
const char* gc_conf = PrintGCDetails ? "gc*" : "gc";
37333737

37343738
LogTarget(Error, logging) target;
37353739
LogStream errstream(target);
3736-
return LogConfiguration::parse_log_arguments(_gc_log_filename, gc_conf, NULL, NULL, &errstream);
3737-
} else if (PrintGC || PrintGCDetails) {
3740+
return LogConfiguration::parse_log_arguments(_legacyGCLogging.file, gc_conf, NULL, NULL, &errstream);
3741+
} else if (PrintGC || PrintGCDetails || (_legacyGCLogging.lastFlag == 1)) {
37383742
LogConfiguration::configure_stdout(LogLevel::Info, !PrintGCDetails, LOG_TAGS(gc));
37393743
}
37403744
return true;

src/hotspot/share/runtime/arguments.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ struct SpecialFlag {
5151
JDK_Version expired_in; // When the option expires (or "undefined").
5252
};
5353

54+
struct LegacyGCLogging {
55+
const char* file; // NULL -> stdout
56+
int lastFlag; // 0 not set; 1 -> -verbose:gc; 2 -> -Xloggc
57+
};
58+
5459
// PathString is used as:
5560
// - the underlying value for a SystemProperty
5661
// - the path portion of an --patch-module module/path pair
@@ -317,8 +322,9 @@ class Arguments : AllStatic {
317322
// was this VM created via the -XXaltjvm=<path> option
318323
static bool _sun_java_launcher_is_altjvm;
319324

320-
// Option flags
321-
static const char* _gc_log_filename;
325+
// for legacy gc options (-verbose:gc and -Xloggc:)
326+
static LegacyGCLogging _legacyGCLogging;
327+
322328
// Value of the conservative maximum heap alignment needed
323329
static size_t _conservative_max_heap_alignment;
324330

0 commit comments

Comments
 (0)