3445 FLAG_SET_DEFAULT(UseLargePages, false); 3446 } 3447 3448 #else 3449 if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) { 3450 FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1); 3451 } 3452 #endif 3453 3454 #ifndef TIERED 3455 // Tiered compilation is undefined. 3456 UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation"); 3457 #endif 3458 3459 // If we are running in a headless jre, force java.awt.headless property 3460 // to be true unless the property has already been set. 3461 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state. 3462 if (os::is_headless_jre()) { 3463 const char* headless = Arguments::get_property("java.awt.headless"); 3464 if (headless == NULL) { 3465 char envbuffer[128]; 3466 if (!os::getenv("JAVA_AWT_HEADLESS", envbuffer, sizeof(envbuffer))) { 3467 if (!add_property("java.awt.headless=true")) { 3468 return JNI_ENOMEM; 3469 } 3470 } else { 3471 char buffer[256]; 3472 strcpy(buffer, "java.awt.headless="); 3473 strcat(buffer, envbuffer); 3474 if (!add_property(buffer)) { 3475 return JNI_ENOMEM; 3476 } 3477 } 3478 } 3479 } 3480 3481 if (UseConcMarkSweepGC && FLAG_IS_DEFAULT(UseParNewGC) && !UseParNewGC) { 3482 // CMS can only be used with ParNew 3483 FLAG_SET_ERGO(bool, UseParNewGC, true); 3484 } 3485 3486 if (!check_vm_args_consistency()) { 3487 return JNI_ERR; 3488 } 3489 3490 return JNI_OK; 3491 } 3492 3493 jint Arguments::parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) { 3494 return parse_options_environment_variable("_JAVA_OPTIONS", scp_p, 3495 scp_assembly_required_p); 3496 } 3497 3498 jint Arguments::parse_java_tool_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) { 3499 return parse_options_environment_variable("JAVA_TOOL_OPTIONS", scp_p, 3500 scp_assembly_required_p); 3501 } 3502 3503 jint Arguments::parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p) { 3504 const int N_MAX_OPTIONS = 64; 3505 const int OPTION_BUFFER_SIZE = 1024; 3506 char buffer[OPTION_BUFFER_SIZE]; 3507 3508 // The variable will be ignored if it exceeds the length of the buffer. 3509 // Don't check this variable if user has special privileges 3510 // (e.g. unix su command). 3511 if (os::getenv(name, buffer, sizeof(buffer)) && 3512 !os::have_special_privileges()) { 3513 JavaVMOption options[N_MAX_OPTIONS]; // Construct option array 3514 jio_fprintf(defaultStream::error_stream(), 3515 "Picked up %s: %s\n", name, buffer); 3516 char* rd = buffer; // pointer to the input string (rd) 3517 int i; 3518 for (i = 0; i < N_MAX_OPTIONS;) { // repeat for all options in the input string 3519 while (isspace(*rd)) rd++; // skip whitespace 3520 if (*rd == 0) break; // we re done when the input string is read completely 3521 3522 // The output, option string, overwrites the input string. 3523 // Because of quoting, the pointer to the option string (wrt) may lag the pointer to 3524 // input string (rd). 3525 char* wrt = rd; 3526 3527 options[i++].optionString = wrt; // Fill in option 3528 while (*rd != 0 && !isspace(*rd)) { // unquoted strings terminate with a space or NULL 3529 if (*rd == '\'' || *rd == '"') { // handle a quoted string 3530 int quote = *rd; // matching quote to look for 3531 rd++; // don't copy open quote 3532 while (*rd != quote) { // include everything (even spaces) up until quote 3533 if (*rd == 0) { // string termination means unmatched string 3534 jio_fprintf(defaultStream::error_stream(), 3535 "Unmatched quote in %s\n", name); 3536 return JNI_ERR; 3537 } 3538 *wrt++ = *rd++; // copy to option string 3539 } 3540 rd++; // don't copy close quote 3541 } else { 3542 *wrt++ = *rd++; // copy to option string 3543 } 3544 } 3545 // Need to check if we're done before writing a NULL, 3546 // because the write could be to the byte that rd is pointing to. 3547 if (*rd++ == 0) { 3548 *wrt = 0; 3549 break; 3550 } 3551 *wrt = 0; // Zero terminate option 3552 } 3553 // Construct JavaVMInitArgs structure and parse as if it was part of the command line 3554 JavaVMInitArgs vm_args; 3555 vm_args.version = JNI_VERSION_1_2; 3556 vm_args.options = options; 3557 vm_args.nOptions = i; 3558 vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions; 3559 3560 if (PrintVMOptions) { 3561 const char* tail; 3562 for (int i = 0; i < vm_args.nOptions; i++) { 3563 const JavaVMOption *option = vm_args.options + i; 3564 if (match_option(option, "-XX:", &tail)) { 3565 logOption(tail); 3566 } 3567 } 3568 } 3569 3570 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, Flag::ENVIRON_VAR)); 3571 } 3572 return JNI_OK; 3573 } 3574 3575 void Arguments::set_shared_spaces_flags() { 3576 if (DumpSharedSpaces) { 3577 if (RequireSharedSpaces) { 3578 warning("cannot dump shared archive while using shared archive"); 3579 } 3580 UseSharedSpaces = false; 3581 #ifdef _LP64 3582 if (!UseCompressedOops || !UseCompressedClassPointers) { 3583 vm_exit_during_initialization( 3584 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL); 3585 } 3586 } else { 3587 if (!UseCompressedOops || !UseCompressedClassPointers) { 3588 no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces."); 3589 } 3590 #endif 3591 } 3592 } | 3445 FLAG_SET_DEFAULT(UseLargePages, false); 3446 } 3447 3448 #else 3449 if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) { 3450 FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1); 3451 } 3452 #endif 3453 3454 #ifndef TIERED 3455 // Tiered compilation is undefined. 3456 UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation"); 3457 #endif 3458 3459 // If we are running in a headless jre, force java.awt.headless property 3460 // to be true unless the property has already been set. 3461 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state. 3462 if (os::is_headless_jre()) { 3463 const char* headless = Arguments::get_property("java.awt.headless"); 3464 if (headless == NULL) { 3465 const char *headless_env = ::getenv("JAVA_AWT_HEADLESS"); 3466 if (headless_env == NULL) { 3467 if (!add_property("java.awt.headless=true")) { 3468 return JNI_ENOMEM; 3469 } 3470 } else { 3471 char buffer[256]; 3472 const char *key = "java.awt.headless="; 3473 strcpy(buffer, key); 3474 strncat(buffer, headless_env, 256 - strlen(key) - 1); 3475 if (!add_property(buffer)) { 3476 return JNI_ENOMEM; 3477 } 3478 } 3479 } 3480 } 3481 3482 if (UseConcMarkSweepGC && FLAG_IS_DEFAULT(UseParNewGC) && !UseParNewGC) { 3483 // CMS can only be used with ParNew 3484 FLAG_SET_ERGO(bool, UseParNewGC, true); 3485 } 3486 3487 if (!check_vm_args_consistency()) { 3488 return JNI_ERR; 3489 } 3490 3491 return JNI_OK; 3492 } 3493 3494 jint Arguments::parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) { 3495 return parse_options_environment_variable("_JAVA_OPTIONS", scp_p, 3496 scp_assembly_required_p); 3497 } 3498 3499 jint Arguments::parse_java_tool_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) { 3500 return parse_options_environment_variable("JAVA_TOOL_OPTIONS", scp_p, 3501 scp_assembly_required_p); 3502 } 3503 3504 jint Arguments::parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p) { 3505 char *buffer = ::getenv(name); 3506 3507 // Don't check this variable if user has special privileges 3508 // (e.g. unix su command). 3509 if (buffer == NULL || os::have_special_privileges()) { 3510 return JNI_OK; 3511 } 3512 3513 if ((buffer = os::strdup(buffer)) == NULL) { 3514 return JNI_ENOMEM; 3515 } 3516 3517 GrowableArray<JavaVMOption> options(2, true); // Construct option array 3518 jio_fprintf(defaultStream::error_stream(), 3519 "Picked up %s: %s\n", name, buffer); 3520 char* rd = buffer; // pointer to the input string (rd) 3521 while (true) { // repeat for all options in the input string 3522 while (isspace(*rd)) rd++; // skip whitespace 3523 if (*rd == 0) break; // we re done when the input string is read completely 3524 3525 // The output, option string, overwrites the input string. 3526 // Because of quoting, the pointer to the option string (wrt) may lag the pointer to 3527 // input string (rd). 3528 char* wrt = rd; 3529 3530 JavaVMOption option; 3531 option.optionString = wrt; 3532 options.append(option); // Fill in option 3533 while (*rd != 0 && !isspace(*rd)) { // unquoted strings terminate with a space or NULL 3534 if (*rd == '\'' || *rd == '"') { // handle a quoted string 3535 int quote = *rd; // matching quote to look for 3536 rd++; // don't copy open quote 3537 while (*rd != quote) { // include everything (even spaces) up until quote 3538 if (*rd == 0) { // string termination means unmatched string 3539 jio_fprintf(defaultStream::error_stream(), 3540 "Unmatched quote in %s\n", name); 3541 os::free(buffer); 3542 return JNI_ERR; 3543 } 3544 *wrt++ = *rd++; // copy to option string 3545 } 3546 rd++; // don't copy close quote 3547 } else { 3548 *wrt++ = *rd++; // copy to option string 3549 } 3550 } 3551 // Need to check if we're done before writing a NULL, 3552 // because the write could be to the byte that rd is pointing to. 3553 if (*rd++ == 0) { 3554 *wrt = 0; 3555 break; 3556 } 3557 *wrt = 0; // Zero terminate option 3558 } 3559 JavaVMOption* options_arr = 3560 NEW_C_HEAP_ARRAY_RETURN_NULL(JavaVMOption, options.length(), mtInternal); 3561 if (options_arr == NULL) { 3562 return JNI_ENOMEM; 3563 } 3564 for (int i = 0; i < options.length(); i++) { 3565 options_arr[i] = options.at(i); 3566 } 3567 3568 // Construct JavaVMInitArgs structure and parse as if it was part of the command line 3569 JavaVMInitArgs vm_args; 3570 vm_args.version = JNI_VERSION_1_2; 3571 vm_args.options = options_arr; 3572 vm_args.nOptions = options.length(); 3573 vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions; 3574 3575 if (PrintVMOptions) { 3576 const char* tail; 3577 for (int i = 0; i < vm_args.nOptions; i++) { 3578 const JavaVMOption *option = vm_args.options + i; 3579 if (match_option(option, "-XX:", &tail)) { 3580 logOption(tail); 3581 } 3582 } 3583 } 3584 3585 jint result = parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, 3586 Flag::ENVIRON_VAR); 3587 FREE_C_HEAP_ARRAY(JavaVMOption, options_arr); 3588 os::free(buffer); 3589 return result; 3590 } 3591 3592 void Arguments::set_shared_spaces_flags() { 3593 if (DumpSharedSpaces) { 3594 if (RequireSharedSpaces) { 3595 warning("cannot dump shared archive while using shared archive"); 3596 } 3597 UseSharedSpaces = false; 3598 #ifdef _LP64 3599 if (!UseCompressedOops || !UseCompressedClassPointers) { 3600 vm_exit_during_initialization( 3601 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL); 3602 } 3603 } else { 3604 if (!UseCompressedOops || !UseCompressedClassPointers) { 3605 no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces."); 3606 } 3607 #endif 3608 } 3609 } |