3495 FLAG_SET_DEFAULT(UseLargePages, false); 3496 } 3497 3498 #else 3499 if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) { 3500 FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1); 3501 } 3502 #endif 3503 3504 #ifndef TIERED 3505 // Tiered compilation is undefined. 3506 UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation"); 3507 #endif 3508 3509 // If we are running in a headless jre, force java.awt.headless property 3510 // to be true unless the property has already been set. 3511 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state. 3512 if (os::is_headless_jre()) { 3513 const char* headless = Arguments::get_property("java.awt.headless"); 3514 if (headless == NULL) { 3515 char envbuffer[128]; 3516 if (!os::getenv("JAVA_AWT_HEADLESS", envbuffer, sizeof(envbuffer))) { 3517 if (!add_property("java.awt.headless=true")) { 3518 return JNI_ENOMEM; 3519 } 3520 } else { 3521 char buffer[256]; 3522 strcpy(buffer, "java.awt.headless="); 3523 strcat(buffer, envbuffer); 3524 if (!add_property(buffer)) { 3525 return JNI_ENOMEM; 3526 } 3527 } 3528 } 3529 } 3530 3531 if (UseConcMarkSweepGC && FLAG_IS_DEFAULT(UseParNewGC) && !UseParNewGC) { 3532 // CMS can only be used with ParNew 3533 FLAG_SET_ERGO(bool, UseParNewGC, true); 3534 } 3535 3536 if (!check_vm_args_consistency()) { 3537 return JNI_ERR; 3538 } 3539 3540 return JNI_OK; 3541 } 3542 3543 jint Arguments::parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) { 3544 return parse_options_environment_variable("_JAVA_OPTIONS", scp_p, 3545 scp_assembly_required_p); 3546 } 3547 3548 jint Arguments::parse_java_tool_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) { 3549 return parse_options_environment_variable("JAVA_TOOL_OPTIONS", scp_p, 3550 scp_assembly_required_p); 3551 } 3552 3553 jint Arguments::parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p) { 3554 const int N_MAX_OPTIONS = 64; 3555 const int OPTION_BUFFER_SIZE = 1024; 3556 char buffer[OPTION_BUFFER_SIZE]; 3557 3558 // The variable will be ignored if it exceeds the length of the buffer. 3559 // Don't check this variable if user has special privileges 3560 // (e.g. unix su command). 3561 if (os::getenv(name, buffer, sizeof(buffer)) && 3562 !os::have_special_privileges()) { 3563 JavaVMOption options[N_MAX_OPTIONS]; // Construct option array 3564 jio_fprintf(defaultStream::error_stream(), 3565 "Picked up %s: %s\n", name, buffer); 3566 char* rd = buffer; // pointer to the input string (rd) 3567 int i; 3568 for (i = 0; i < N_MAX_OPTIONS;) { // repeat for all options in the input string 3569 while (isspace(*rd)) rd++; // skip whitespace 3570 if (*rd == 0) break; // we re done when the input string is read completely 3571 3572 // The output, option string, overwrites the input string. 3573 // Because of quoting, the pointer to the option string (wrt) may lag the pointer to 3574 // input string (rd). 3575 char* wrt = rd; 3576 3577 options[i++].optionString = wrt; // Fill in option 3578 while (*rd != 0 && !isspace(*rd)) { // unquoted strings terminate with a space or NULL 3579 if (*rd == '\'' || *rd == '"') { // handle a quoted string 3580 int quote = *rd; // matching quote to look for 3581 rd++; // don't copy open quote 3582 while (*rd != quote) { // include everything (even spaces) up until quote 3583 if (*rd == 0) { // string termination means unmatched string 3584 jio_fprintf(defaultStream::error_stream(), 3585 "Unmatched quote in %s\n", name); 3586 return JNI_ERR; 3587 } 3588 *wrt++ = *rd++; // copy to option string 3589 } 3590 rd++; // don't copy close quote 3591 } else { 3592 *wrt++ = *rd++; // copy to option string 3593 } 3594 } 3595 // Need to check if we're done before writing a NULL, 3596 // because the write could be to the byte that rd is pointing to. 3597 if (*rd++ == 0) { 3598 *wrt = 0; 3599 break; 3600 } 3601 *wrt = 0; // Zero terminate option 3602 } 3603 // Construct JavaVMInitArgs structure and parse as if it was part of the command line 3604 JavaVMInitArgs vm_args; 3605 vm_args.version = JNI_VERSION_1_2; 3606 vm_args.options = options; 3607 vm_args.nOptions = i; 3608 vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions; 3609 3610 if (PrintVMOptions) { 3611 const char* tail; 3612 for (int i = 0; i < vm_args.nOptions; i++) { 3613 const JavaVMOption *option = vm_args.options + i; 3614 if (match_option(option, "-XX:", &tail)) { 3615 logOption(tail); 3616 } 3617 } 3618 } 3619 3620 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, Flag::ENVIRON_VAR)); 3621 } 3622 return JNI_OK; 3623 } 3624 3625 void Arguments::set_shared_spaces_flags() { 3626 if (DumpSharedSpaces) { 3627 if (RequireSharedSpaces) { 3628 warning("cannot dump shared archive while using shared archive"); 3629 } 3630 UseSharedSpaces = false; 3631 #ifdef _LP64 3632 if (!UseCompressedOops || !UseCompressedClassPointers) { 3633 vm_exit_during_initialization( 3634 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL); 3635 } 3636 } else { 3637 if (!UseCompressedOops || !UseCompressedClassPointers) { 3638 no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces."); 3639 } 3640 #endif 3641 } 3642 } | 3495 FLAG_SET_DEFAULT(UseLargePages, false); 3496 } 3497 3498 #else 3499 if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) { 3500 FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1); 3501 } 3502 #endif 3503 3504 #ifndef TIERED 3505 // Tiered compilation is undefined. 3506 UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation"); 3507 #endif 3508 3509 // If we are running in a headless jre, force java.awt.headless property 3510 // to be true unless the property has already been set. 3511 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state. 3512 if (os::is_headless_jre()) { 3513 const char* headless = Arguments::get_property("java.awt.headless"); 3514 if (headless == NULL) { 3515 const char *headless_env = ::getenv("JAVA_AWT_HEADLESS"); 3516 if (headless_env == NULL) { 3517 if (!add_property("java.awt.headless=true")) { 3518 return JNI_ENOMEM; 3519 } 3520 } else { 3521 char buffer[256]; 3522 const char *key = "java.awt.headless="; 3523 strcpy(buffer, key); 3524 strncat(buffer, headless_env, 256 - strlen(key) - 1); 3525 if (!add_property(buffer)) { 3526 return JNI_ENOMEM; 3527 } 3528 } 3529 } 3530 } 3531 3532 if (UseConcMarkSweepGC && FLAG_IS_DEFAULT(UseParNewGC) && !UseParNewGC) { 3533 // CMS can only be used with ParNew 3534 FLAG_SET_ERGO(bool, UseParNewGC, true); 3535 } 3536 3537 if (!check_vm_args_consistency()) { 3538 return JNI_ERR; 3539 } 3540 3541 return JNI_OK; 3542 } 3543 3544 jint Arguments::parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) { 3545 return parse_options_environment_variable("_JAVA_OPTIONS", scp_p, 3546 scp_assembly_required_p); 3547 } 3548 3549 jint Arguments::parse_java_tool_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) { 3550 return parse_options_environment_variable("JAVA_TOOL_OPTIONS", scp_p, 3551 scp_assembly_required_p); 3552 } 3553 3554 jint Arguments::parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p) { 3555 char *buffer = ::getenv(name); 3556 3557 // Don't check this variable if user has special privileges 3558 // (e.g. unix su command). 3559 if (buffer == NULL || os::have_special_privileges()) { 3560 return JNI_OK; 3561 } 3562 3563 if ((buffer = os::strdup(buffer)) == NULL) { 3564 return JNI_ENOMEM; 3565 } 3566 GrowableArray<JavaVMOption> options(2, true); // Construct option array 3567 jio_fprintf(defaultStream::error_stream(), 3568 "Picked up %s: %s\n", name, buffer); 3569 char* rd = buffer; // pointer to the input string (rd) 3570 while (true) { // repeat for all options in the input string 3571 while (isspace(*rd)) rd++; // skip whitespace 3572 if (*rd == 0) break; // we re done when the input string is read completely 3573 3574 // The output, option string, overwrites the input string. 3575 // Because of quoting, the pointer to the option string (wrt) may lag the pointer to 3576 // input string (rd). 3577 char* wrt = rd; 3578 3579 JavaVMOption option; 3580 option.optionString = wrt; 3581 options.append(option); // Fill in option 3582 while (*rd != 0 && !isspace(*rd)) { // unquoted strings terminate with a space or NULL 3583 if (*rd == '\'' || *rd == '"') { // handle a quoted string 3584 int quote = *rd; // matching quote to look for 3585 rd++; // don't copy open quote 3586 while (*rd != quote) { // include everything (even spaces) up until quote 3587 if (*rd == 0) { // string termination means unmatched string 3588 jio_fprintf(defaultStream::error_stream(), 3589 "Unmatched quote in %s\n", name); 3590 os::free(buffer); 3591 return JNI_ERR; 3592 } 3593 *wrt++ = *rd++; // copy to option string 3594 } 3595 rd++; // don't copy close quote 3596 } else { 3597 *wrt++ = *rd++; // copy to option string 3598 } 3599 } 3600 // Need to check if we're done before writing a NULL, 3601 // because the write could be to the byte that rd is pointing to. 3602 if (*rd++ == 0) { 3603 *wrt = 0; 3604 break; 3605 } 3606 *wrt = 0; // Zero terminate option 3607 } 3608 JavaVMOption* options_arr = 3609 NEW_C_HEAP_ARRAY_RETURN_NULL(JavaVMOption, options.length(), mtInternal); 3610 if (options_arr == NULL) { 3611 return JNI_ENOMEM; 3612 } 3613 for (int i = 0; i < options.length(); i++) { 3614 options_arr[i] = options.at(i); 3615 } 3616 3617 // Construct JavaVMInitArgs structure and parse as if it was part of the command line 3618 JavaVMInitArgs vm_args; 3619 vm_args.version = JNI_VERSION_1_2; 3620 vm_args.options = options_arr; 3621 vm_args.nOptions = options.length(); 3622 vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions; 3623 3624 if (PrintVMOptions) { 3625 const char* tail; 3626 for (int i = 0; i < vm_args.nOptions; i++) { 3627 const JavaVMOption *option = vm_args.options + i; 3628 if (match_option(option, "-XX:", &tail)) { 3629 logOption(tail); 3630 } 3631 } 3632 } 3633 3634 jint result = parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, 3635 Flag::ENVIRON_VAR); 3636 FREE_C_HEAP_ARRAY(JavaVMOption, options_arr); 3637 os::free(buffer); 3638 return result; 3639 } 3640 3641 void Arguments::set_shared_spaces_flags() { 3642 if (DumpSharedSpaces) { 3643 if (RequireSharedSpaces) { 3644 warning("cannot dump shared archive while using shared archive"); 3645 } 3646 UseSharedSpaces = false; 3647 #ifdef _LP64 3648 if (!UseCompressedOops || !UseCompressedClassPointers) { 3649 vm_exit_during_initialization( 3650 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL); 3651 } 3652 } else { 3653 if (!UseCompressedOops || !UseCompressedClassPointers) { 3654 no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces."); 3655 } 3656 #endif 3657 } 3658 } |