2688 #if !INCLUDE_JVMTI
2689 if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) {
2690 jio_fprintf(defaultStream::error_stream(),
2691 "Profiling and debugging agents are not supported in this VM\n");
2692 return JNI_ERR;
2693 }
2694 #endif // !INCLUDE_JVMTI
2695 add_init_library(name, options);
2696 }
2697 // -agentlib and -agentpath
2698 } else if (match_option(option, "-agentlib:", &tail) ||
2699 (is_absolute_path = match_option(option, "-agentpath:", &tail))) {
2700 if(tail != NULL) {
2701 const char* pos = strchr(tail, '=');
2702 size_t len = (pos == NULL) ? strlen(tail) : pos - tail;
2703 char* name = strncpy(NEW_C_HEAP_ARRAY(char, len + 1, mtInternal), tail, len);
2704 name[len] = '\0';
2705
2706 char *options = NULL;
2707 if(pos != NULL) {
2708 options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1, mtInternal), pos + 1);
2709 }
2710 #if !INCLUDE_JVMTI
2711 if (valid_hprof_or_jdwp_agent(name, is_absolute_path)) {
2712 jio_fprintf(defaultStream::error_stream(),
2713 "Profiling and debugging agents are not supported in this VM\n");
2714 return JNI_ERR;
2715 }
2716 #endif // !INCLUDE_JVMTI
2717 add_init_agent(name, options, is_absolute_path);
2718 }
2719 // -javaagent
2720 } else if (match_option(option, "-javaagent:", &tail)) {
2721 #if !INCLUDE_JVMTI
2722 jio_fprintf(defaultStream::error_stream(),
2723 "Instrumentation agents are not supported in this VM\n");
2724 return JNI_ERR;
2725 #else
2726 if(tail != NULL) {
2727 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail);
2728 add_init_agent("instrument", options, false);
3279 //
3280 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
3281 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
3282 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
3283 // path is treated as the current directory.
3284 //
3285 // This causes problems with CDS, which requires that all directories specified in the classpath
3286 // must be empty. In most cases, applications do NOT want to load classes from the current
3287 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up
3288 // scripts compatible with CDS.
3289 void Arguments::fix_appclasspath() {
3290 if (IgnoreEmptyClassPaths) {
3291 const char separator = *os::path_separator();
3292 const char* src = _java_class_path->value();
3293
3294 // skip over all the leading empty paths
3295 while (*src == separator) {
3296 src ++;
3297 }
3298
3299 char* copy = AllocateHeap(strlen(src) + 1, mtInternal);
3300 strncpy(copy, src, strlen(src) + 1);
3301
3302 // trim all trailing empty paths
3303 for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) {
3304 *tail = '\0';
3305 }
3306
3307 char from[3] = {separator, separator, '\0'};
3308 char to [2] = {separator, '\0'};
3309 while (StringUtils::replace_no_expand(copy, from, to) > 0) {
3310 // Keep replacing "::" -> ":" until we have no more "::" (non-windows)
3311 // Keep replacing ";;" -> ";" until we have no more ";;" (windows)
3312 }
3313
3314 _java_class_path->set_value(copy);
3315 FreeHeap(copy); // a copy was made by set_value, so don't need this anymore
3316 }
3317
3318 if (!PrintSharedArchiveAndExit) {
3319 ClassLoader::trace_class_path("[classpath: ", _java_class_path->value());
3320 }
3445 #endif
3446
3447 #ifndef TIERED
3448 // Tiered compilation is undefined.
3449 UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
3450 #endif
3451
3452 // If we are running in a headless jre, force java.awt.headless property
3453 // to be true unless the property has already been set.
3454 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
3455 if (os::is_headless_jre()) {
3456 const char* headless = Arguments::get_property("java.awt.headless");
3457 if (headless == NULL) {
3458 const char *headless_env = ::getenv("JAVA_AWT_HEADLESS");
3459 if (headless_env == NULL) {
3460 if (!add_property("java.awt.headless=true")) {
3461 return JNI_ENOMEM;
3462 }
3463 } else {
3464 char buffer[256];
3465 const char *key = "java.awt.headless=";
3466 strcpy(buffer, key);
3467 strncat(buffer, headless_env, 256 - strlen(key) - 1);
3468 if (!add_property(buffer)) {
3469 return JNI_ENOMEM;
3470 }
3471 }
3472 }
3473 }
3474
3475 if (UseConcMarkSweepGC && FLAG_IS_DEFAULT(UseParNewGC) && !UseParNewGC) {
3476 // CMS can only be used with ParNew
3477 FLAG_SET_ERGO(bool, UseParNewGC, true);
3478 }
3479
3480 if (!check_vm_args_consistency()) {
3481 return JNI_ERR;
3482 }
3483
3484 return JNI_OK;
3485 }
3486
3487 jint Arguments::parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) {
3610 FLAG_SET_DEFAULT(UseSerialGC, true);
3611 UNSUPPORTED_GC_OPTION(UseG1GC);
3612 UNSUPPORTED_GC_OPTION(UseParallelGC);
3613 UNSUPPORTED_GC_OPTION(UseParallelOldGC);
3614 UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
3615 UNSUPPORTED_GC_OPTION(UseParNewGC);
3616 }
3617 #endif // INCLUDE_ALL_GCS
3618
3619 // Sharing support
3620 // Construct the path to the archive
3621 static char* get_shared_archive_path() {
3622 char *shared_archive_path;
3623 if (SharedArchiveFile == NULL) {
3624 char jvm_path[JVM_MAXPATHLEN];
3625 os::jvm_path(jvm_path, sizeof(jvm_path));
3626 char *end = strrchr(jvm_path, *os::file_separator());
3627 if (end != NULL) *end = '\0';
3628 size_t jvm_path_len = strlen(jvm_path);
3629 size_t file_sep_len = strlen(os::file_separator());
3630 shared_archive_path = NEW_C_HEAP_ARRAY(char, jvm_path_len +
3631 file_sep_len + 20, mtInternal);
3632 if (shared_archive_path != NULL) {
3633 strncpy(shared_archive_path, jvm_path, jvm_path_len + 1);
3634 strncat(shared_archive_path, os::file_separator(), file_sep_len);
3635 strncat(shared_archive_path, "classes.jsa", 11);
3636 }
3637 } else {
3638 shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(SharedArchiveFile) + 1, mtInternal);
3639 if (shared_archive_path != NULL) {
3640 strncpy(shared_archive_path, SharedArchiveFile, strlen(SharedArchiveFile) + 1);
3641 }
3642 }
3643 return shared_archive_path;
3644 }
3645
3646 #ifndef PRODUCT
3647 // Determine whether LogVMOutput should be implicitly turned on.
3648 static bool use_vm_log() {
3649 if (LogCompilation || !FLAG_IS_DEFAULT(LogFile) ||
3650 PrintCompilation || PrintInlining || PrintDependencies || PrintNativeNMethods ||
3651 PrintDebugInfo || PrintRelocations || PrintNMethods || PrintExceptionHandlers ||
3652 PrintAssembly || TraceDeoptimization || TraceDependencies ||
3653 (VerifyDependencies && FLAG_IS_CMDLINE(VerifyDependencies))) {
3654 return true;
3655 }
3656
3657 #ifdef COMPILER1
3658 if (PrintC1Statistics) {
3659 return true;
3660 }
3661 #endif // COMPILER1
|
2688 #if !INCLUDE_JVMTI
2689 if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) {
2690 jio_fprintf(defaultStream::error_stream(),
2691 "Profiling and debugging agents are not supported in this VM\n");
2692 return JNI_ERR;
2693 }
2694 #endif // !INCLUDE_JVMTI
2695 add_init_library(name, options);
2696 }
2697 // -agentlib and -agentpath
2698 } else if (match_option(option, "-agentlib:", &tail) ||
2699 (is_absolute_path = match_option(option, "-agentpath:", &tail))) {
2700 if(tail != NULL) {
2701 const char* pos = strchr(tail, '=');
2702 size_t len = (pos == NULL) ? strlen(tail) : pos - tail;
2703 char* name = strncpy(NEW_C_HEAP_ARRAY(char, len + 1, mtInternal), tail, len);
2704 name[len] = '\0';
2705
2706 char *options = NULL;
2707 if(pos != NULL) {
2708 options = os::strdup_check_oom(pos + 1, mtInternal);
2709 }
2710 #if !INCLUDE_JVMTI
2711 if (valid_hprof_or_jdwp_agent(name, is_absolute_path)) {
2712 jio_fprintf(defaultStream::error_stream(),
2713 "Profiling and debugging agents are not supported in this VM\n");
2714 return JNI_ERR;
2715 }
2716 #endif // !INCLUDE_JVMTI
2717 add_init_agent(name, options, is_absolute_path);
2718 }
2719 // -javaagent
2720 } else if (match_option(option, "-javaagent:", &tail)) {
2721 #if !INCLUDE_JVMTI
2722 jio_fprintf(defaultStream::error_stream(),
2723 "Instrumentation agents are not supported in this VM\n");
2724 return JNI_ERR;
2725 #else
2726 if(tail != NULL) {
2727 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail);
2728 add_init_agent("instrument", options, false);
3279 //
3280 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
3281 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
3282 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
3283 // path is treated as the current directory.
3284 //
3285 // This causes problems with CDS, which requires that all directories specified in the classpath
3286 // must be empty. In most cases, applications do NOT want to load classes from the current
3287 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up
3288 // scripts compatible with CDS.
3289 void Arguments::fix_appclasspath() {
3290 if (IgnoreEmptyClassPaths) {
3291 const char separator = *os::path_separator();
3292 const char* src = _java_class_path->value();
3293
3294 // skip over all the leading empty paths
3295 while (*src == separator) {
3296 src ++;
3297 }
3298
3299 char* copy = os::strdup_check_oom(src, mtInternal);
3300
3301 // trim all trailing empty paths
3302 for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) {
3303 *tail = '\0';
3304 }
3305
3306 char from[3] = {separator, separator, '\0'};
3307 char to [2] = {separator, '\0'};
3308 while (StringUtils::replace_no_expand(copy, from, to) > 0) {
3309 // Keep replacing "::" -> ":" until we have no more "::" (non-windows)
3310 // Keep replacing ";;" -> ";" until we have no more ";;" (windows)
3311 }
3312
3313 _java_class_path->set_value(copy);
3314 FreeHeap(copy); // a copy was made by set_value, so don't need this anymore
3315 }
3316
3317 if (!PrintSharedArchiveAndExit) {
3318 ClassLoader::trace_class_path("[classpath: ", _java_class_path->value());
3319 }
3444 #endif
3445
3446 #ifndef TIERED
3447 // Tiered compilation is undefined.
3448 UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
3449 #endif
3450
3451 // If we are running in a headless jre, force java.awt.headless property
3452 // to be true unless the property has already been set.
3453 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
3454 if (os::is_headless_jre()) {
3455 const char* headless = Arguments::get_property("java.awt.headless");
3456 if (headless == NULL) {
3457 const char *headless_env = ::getenv("JAVA_AWT_HEADLESS");
3458 if (headless_env == NULL) {
3459 if (!add_property("java.awt.headless=true")) {
3460 return JNI_ENOMEM;
3461 }
3462 } else {
3463 char buffer[256];
3464 jio_snprintf(buffer, sizeof(buffer), "java.awt.headless=%s", headless_env);
3465 if (!add_property(buffer)) {
3466 return JNI_ENOMEM;
3467 }
3468 }
3469 }
3470 }
3471
3472 if (UseConcMarkSweepGC && FLAG_IS_DEFAULT(UseParNewGC) && !UseParNewGC) {
3473 // CMS can only be used with ParNew
3474 FLAG_SET_ERGO(bool, UseParNewGC, true);
3475 }
3476
3477 if (!check_vm_args_consistency()) {
3478 return JNI_ERR;
3479 }
3480
3481 return JNI_OK;
3482 }
3483
3484 jint Arguments::parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) {
3607 FLAG_SET_DEFAULT(UseSerialGC, true);
3608 UNSUPPORTED_GC_OPTION(UseG1GC);
3609 UNSUPPORTED_GC_OPTION(UseParallelGC);
3610 UNSUPPORTED_GC_OPTION(UseParallelOldGC);
3611 UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
3612 UNSUPPORTED_GC_OPTION(UseParNewGC);
3613 }
3614 #endif // INCLUDE_ALL_GCS
3615
3616 // Sharing support
3617 // Construct the path to the archive
3618 static char* get_shared_archive_path() {
3619 char *shared_archive_path;
3620 if (SharedArchiveFile == NULL) {
3621 char jvm_path[JVM_MAXPATHLEN];
3622 os::jvm_path(jvm_path, sizeof(jvm_path));
3623 char *end = strrchr(jvm_path, *os::file_separator());
3624 if (end != NULL) *end = '\0';
3625 size_t jvm_path_len = strlen(jvm_path);
3626 size_t file_sep_len = strlen(os::file_separator());
3627 const size_t len = jvm_path_len + file_sep_len + 20;
3628 shared_archive_path = NEW_C_HEAP_ARRAY(char, len, mtInternal);
3629 if (shared_archive_path != NULL) {
3630 jio_snprintf(shared_archive_path, len, "%s%sclasses.jsa",
3631 jvm_path, os::file_separator());
3632 }
3633 } else {
3634 shared_archive_path = os::strdup_check_oom(SharedArchiveFile, mtInternal);
3635 }
3636 return shared_archive_path;
3637 }
3638
3639 #ifndef PRODUCT
3640 // Determine whether LogVMOutput should be implicitly turned on.
3641 static bool use_vm_log() {
3642 if (LogCompilation || !FLAG_IS_DEFAULT(LogFile) ||
3643 PrintCompilation || PrintInlining || PrintDependencies || PrintNativeNMethods ||
3644 PrintDebugInfo || PrintRelocations || PrintNMethods || PrintExceptionHandlers ||
3645 PrintAssembly || TraceDeoptimization || TraceDependencies ||
3646 (VerifyDependencies && FLAG_IS_CMDLINE(VerifyDependencies))) {
3647 return true;
3648 }
3649
3650 #ifdef COMPILER1
3651 if (PrintC1Statistics) {
3652 return true;
3653 }
3654 #endif // COMPILER1
|