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