3505 |
3505 |
3506 if ((buffer = os::strdup(buffer)) == NULL) { |
3506 if ((buffer = os::strdup(buffer)) == NULL) { |
3507 return JNI_ENOMEM; |
3507 return JNI_ENOMEM; |
3508 } |
3508 } |
3509 |
3509 |
3510 GrowableArray<JavaVMOption> options(2, true); // Construct option array |
3510 GrowableArray<JavaVMOption> *options = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<JavaVMOption>(2, true); // Construct option array |
3511 jio_fprintf(defaultStream::error_stream(), |
3511 jio_fprintf(defaultStream::error_stream(), |
3512 "Picked up %s: %s\n", name, buffer); |
3512 "Picked up %s: %s\n", name, buffer); |
3513 char* rd = buffer; // pointer to the input string (rd) |
3513 char* rd = buffer; // pointer to the input string (rd) |
3514 while (true) { // repeat for all options in the input string |
3514 while (true) { // repeat for all options in the input string |
3515 while (isspace(*rd)) rd++; // skip whitespace |
3515 while (isspace(*rd)) rd++; // skip whitespace |
3520 // input string (rd). |
3520 // input string (rd). |
3521 char* wrt = rd; |
3521 char* wrt = rd; |
3522 |
3522 |
3523 JavaVMOption option; |
3523 JavaVMOption option; |
3524 option.optionString = wrt; |
3524 option.optionString = wrt; |
3525 options.append(option); // Fill in option |
3525 options->append(option); // Fill in option |
3526 while (*rd != 0 && !isspace(*rd)) { // unquoted strings terminate with a space or NULL |
3526 while (*rd != 0 && !isspace(*rd)) { // unquoted strings terminate with a space or NULL |
3527 if (*rd == '\'' || *rd == '"') { // handle a quoted string |
3527 if (*rd == '\'' || *rd == '"') { // handle a quoted string |
3528 int quote = *rd; // matching quote to look for |
3528 int quote = *rd; // matching quote to look for |
3529 rd++; // don't copy open quote |
3529 rd++; // don't copy open quote |
3530 while (*rd != quote) { // include everything (even spaces) up until quote |
3530 while (*rd != quote) { // include everything (even spaces) up until quote |
3531 if (*rd == 0) { // string termination means unmatched string |
3531 if (*rd == 0) { // string termination means unmatched string |
3532 jio_fprintf(defaultStream::error_stream(), |
3532 jio_fprintf(defaultStream::error_stream(), |
3533 "Unmatched quote in %s\n", name); |
3533 "Unmatched quote in %s\n", name); |
|
3534 delete options; |
3534 os::free(buffer); |
3535 os::free(buffer); |
3535 return JNI_ERR; |
3536 return JNI_ERR; |
3536 } |
3537 } |
3537 *wrt++ = *rd++; // copy to option string |
3538 *wrt++ = *rd++; // copy to option string |
3538 } |
3539 } |
3548 break; |
3549 break; |
3549 } |
3550 } |
3550 *wrt = 0; // Zero terminate option |
3551 *wrt = 0; // Zero terminate option |
3551 } |
3552 } |
3552 JavaVMOption* options_arr = |
3553 JavaVMOption* options_arr = |
3553 NEW_C_HEAP_ARRAY_RETURN_NULL(JavaVMOption, options.length(), mtInternal); |
3554 NEW_C_HEAP_ARRAY_RETURN_NULL(JavaVMOption, options->length(), mtInternal); |
3554 if (options_arr == NULL) { |
3555 if (options_arr == NULL) { |
|
3556 delete options; |
|
3557 os::free(buffer); |
3555 return JNI_ENOMEM; |
3558 return JNI_ENOMEM; |
3556 } |
3559 } |
3557 for (int i = 0; i < options.length(); i++) { |
3560 for (int i = 0; i < options->length(); i++) { |
3558 options_arr[i] = options.at(i); |
3561 options_arr[i] = options->at(i); |
3559 } |
3562 } |
3560 |
3563 |
3561 // Construct JavaVMInitArgs structure and parse as if it was part of the command line |
3564 // Construct JavaVMInitArgs structure and parse as if it was part of the command line |
3562 JavaVMInitArgs vm_args; |
3565 JavaVMInitArgs vm_args; |
3563 vm_args.version = JNI_VERSION_1_2; |
3566 vm_args.version = JNI_VERSION_1_2; |
3564 vm_args.options = options_arr; |
3567 vm_args.options = options_arr; |
3565 vm_args.nOptions = options.length(); |
3568 vm_args.nOptions = options->length(); |
3566 vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions; |
3569 vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions; |
3567 |
3570 |
3568 if (PrintVMOptions) { |
3571 if (PrintVMOptions) { |
3569 const char* tail; |
3572 const char* tail; |
3570 for (int i = 0; i < vm_args.nOptions; i++) { |
3573 for (int i = 0; i < vm_args.nOptions; i++) { |
3576 } |
3579 } |
3577 |
3580 |
3578 jint result = parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, |
3581 jint result = parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, |
3579 Flag::ENVIRON_VAR); |
3582 Flag::ENVIRON_VAR); |
3580 FREE_C_HEAP_ARRAY(JavaVMOption, options_arr); |
3583 FREE_C_HEAP_ARRAY(JavaVMOption, options_arr); |
|
3584 delete options; |
3581 os::free(buffer); |
3585 os::free(buffer); |
3582 return result; |
3586 return result; |
3583 } |
3587 } |
3584 |
3588 |
3585 void Arguments::set_shared_spaces_flags() { |
3589 void Arguments::set_shared_spaces_flags() { |