1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
385 // Flags that are aliases for other flags.
386 typedef struct {
387 const char* alias_name;
388 const char* real_name;
389 } AliasedFlag;
390
391 static AliasedFlag const aliased_jvm_flags[] = {
392 { "DefaultMaxRAMFraction", "MaxRAMFraction" },
393 { "CMSMarkStackSizeMax", "MarkStackSizeMax" },
394 { "CMSMarkStackSize", "MarkStackSize" },
395 { "G1MarkStackSize", "MarkStackSize" },
396 { "ParallelMarkingThreads", "ConcGCThreads" },
397 { "ParallelCMSThreads", "ConcGCThreads" },
398 { "CreateMinidumpOnCrash", "CreateCoredumpOnCrash" },
399 { NULL, NULL}
400 };
401
402 static AliasedFlag const aliased_jvm_logging_flags[] = {
403 { "-XX:+TraceClassResolution", "-Xlog:classresolve=info"},
404 { "-XX:-TraceClassResolution", "-Xlog:classresolve=off"},
405 { "-XX:+TraceExceptions", "-Xlog:exceptions=info" },
406 { "-XX:-TraceExceptions", "-Xlog:exceptions=off" },
407 { "-XX:+TraceMonitorInflation", "-Xlog:monitorinflation=debug" },
408 { "-XX:-TraceMonitorInflation", "-Xlog:monitorinflation=off" },
409 { NULL, NULL }
410 };
411
412 // Return true if "v" is less than "other", where "other" may be "undefined".
413 static bool version_less_than(JDK_Version v, JDK_Version other) {
414 assert(!v.is_undefined(), "must be defined");
415 if (!other.is_undefined() && v.compare(other) >= 0) {
416 return false;
417 } else {
418 return true;
419 }
420 }
421
422 static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {
423 for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
424 if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
2638 // add all jvm options to the jvm_args string. This string
2639 // is used later to set the java.vm.args PerfData string constant.
2640 // the -Djava.class.path and the -Dsun.java.command options are
2641 // omitted from jvm_args string as each have their own PerfData
2642 // string constant object.
2643 build_jvm_args(option->optionString);
2644 }
2645
2646 // char buffer to store looked up logging option.
2647 char aliased_logging_option[256];
2648
2649 // Catch -XX options which are aliased to Unified logging commands.
2650 if (match_option(option, "-XX:", &tail)) {
2651 if (lookup_logging_aliases(option->optionString, aliased_logging_option)) {
2652 option->optionString = aliased_logging_option;
2653 }
2654 }
2655
2656 // -verbose:[class/gc/jni]
2657 if (match_option(option, "-verbose", &tail)) {
2658 if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
2659 if (FLAG_SET_CMDLINE(bool, TraceClassLoading, true) != Flag::SUCCESS) {
2660 return JNI_EINVAL;
2661 }
2662 if (FLAG_SET_CMDLINE(bool, TraceClassUnloading, true) != Flag::SUCCESS) {
2663 return JNI_EINVAL;
2664 }
2665 } else if (!strcmp(tail, ":gc")) {
2666 // LogConfiguration_lock is not set up yet, but this code is executed by a single thread
2667 bool ret = LogConfiguration::parse_log_arguments("stdout", "gc", NULL, NULL, NULL);
2668 if (!ret) {
2669 return JNI_EINVAL;
2670 }
2671 } else if (!strcmp(tail, ":jni")) {
2672 if (FLAG_SET_CMDLINE(bool, PrintJNIResolving, true) != Flag::SUCCESS) {
2673 return JNI_EINVAL;
2674 }
2675 }
2676 // -da / -ea / -disableassertions / -enableassertions
2677 // These accept an optional class/package name separated by a colon, e.g.,
2678 // -da:java.lang.Thread.
2679 } else if (match_option(option, user_assertion_options, &tail, true)) {
2680 bool enable = option->optionString[1] == 'e'; // char after '-' is 'e'
2681 if (*tail == '\0') {
2682 JavaAssertions::setUserClassDefault(enable);
2683 } else {
2684 assert(*tail == ':', "bogus match by match_option()");
2685 JavaAssertions::addOption(tail + 1, enable);
2686 }
2687 // -dsa / -esa / -disablesystemassertions / -enablesystemassertions
|
1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
385 // Flags that are aliases for other flags.
386 typedef struct {
387 const char* alias_name;
388 const char* real_name;
389 } AliasedFlag;
390
391 static AliasedFlag const aliased_jvm_flags[] = {
392 { "DefaultMaxRAMFraction", "MaxRAMFraction" },
393 { "CMSMarkStackSizeMax", "MarkStackSizeMax" },
394 { "CMSMarkStackSize", "MarkStackSize" },
395 { "G1MarkStackSize", "MarkStackSize" },
396 { "ParallelMarkingThreads", "ConcGCThreads" },
397 { "ParallelCMSThreads", "ConcGCThreads" },
398 { "CreateMinidumpOnCrash", "CreateCoredumpOnCrash" },
399 { NULL, NULL}
400 };
401
402 static AliasedFlag const aliased_jvm_logging_flags[] = {
403 { "-XX:+TraceClassResolution", "-Xlog:classresolve=info"},
404 { "-XX:-TraceClassResolution", "-Xlog:classresolve=off"},
405 { "-XX:+TraceClassLoading", "-Xlog:classload=info"},
406 { "-XX:-TraceClassLoading", "-Xlog:classload=off"},
407 { "-XX:+TraceClassUnloading", "-Xlog:classunload=info"},
408 { "-XX:-TraceClassUnloading", "-Xlog:classunload=off"},
409 { "-XX:+TraceExceptions", "-Xlog:exceptions=info" },
410 { "-XX:-TraceExceptions", "-Xlog:exceptions=off" },
411 { "-XX:+TraceMonitorInflation", "-Xlog:monitorinflation=debug" },
412 { "-XX:-TraceMonitorInflation", "-Xlog:monitorinflation=off" },
413 { NULL, NULL }
414 };
415
416 // Return true if "v" is less than "other", where "other" may be "undefined".
417 static bool version_less_than(JDK_Version v, JDK_Version other) {
418 assert(!v.is_undefined(), "must be defined");
419 if (!other.is_undefined() && v.compare(other) >= 0) {
420 return false;
421 } else {
422 return true;
423 }
424 }
425
426 static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {
427 for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
428 if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
2642 // add all jvm options to the jvm_args string. This string
2643 // is used later to set the java.vm.args PerfData string constant.
2644 // the -Djava.class.path and the -Dsun.java.command options are
2645 // omitted from jvm_args string as each have their own PerfData
2646 // string constant object.
2647 build_jvm_args(option->optionString);
2648 }
2649
2650 // char buffer to store looked up logging option.
2651 char aliased_logging_option[256];
2652
2653 // Catch -XX options which are aliased to Unified logging commands.
2654 if (match_option(option, "-XX:", &tail)) {
2655 if (lookup_logging_aliases(option->optionString, aliased_logging_option)) {
2656 option->optionString = aliased_logging_option;
2657 }
2658 }
2659
2660 // -verbose:[class/gc/jni]
2661 if (match_option(option, "-verbose", &tail)) {
2662 bool ret;
2663 if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
2664 ret = LogConfiguration::parse_log_arguments("stdout", "classload=info", NULL, NULL, NULL);
2665 if (!ret) {
2666 return JNI_EINVAL;
2667 }
2668 ret = LogConfiguration::parse_log_arguments("stdout", "classunload=info", NULL, NULL, NULL);
2669 if (!ret) {
2670 return JNI_EINVAL;
2671 }
2672 } else if (!strcmp(tail, ":gc")) {
2673 // LogConfiguration_lock is not set up yet, but this code is executed by a single thread
2674 ret = LogConfiguration::parse_log_arguments("stdout", "gc", NULL, NULL, NULL);
2675 if (!ret) {
2676 return JNI_EINVAL;
2677 }
2678 } else if (!strcmp(tail, ":jni")) {
2679 if (FLAG_SET_CMDLINE(bool, PrintJNIResolving, true) != Flag::SUCCESS) {
2680 return JNI_EINVAL;
2681 }
2682 }
2683 // -da / -ea / -disableassertions / -enableassertions
2684 // These accept an optional class/package name separated by a colon, e.g.,
2685 // -da:java.lang.Thread.
2686 } else if (match_option(option, user_assertion_options, &tail, true)) {
2687 bool enable = option->optionString[1] == 'e'; // char after '-' is 'e'
2688 if (*tail == '\0') {
2689 JavaAssertions::setUserClassDefault(enable);
2690 } else {
2691 assert(*tail == ':', "bogus match by match_option()");
2692 JavaAssertions::addOption(tail + 1, enable);
2693 }
2694 // -dsa / -esa / -disablesystemassertions / -enablesystemassertions
|