< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page

        

*** 3509,3528 **** // to be true unless the property has already been set. // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state. if (os::is_headless_jre()) { const char* headless = Arguments::get_property("java.awt.headless"); if (headless == NULL) { ! char envbuffer[128]; ! if (!os::getenv("JAVA_AWT_HEADLESS", envbuffer, sizeof(envbuffer))) { if (!add_property("java.awt.headless=true")) { return JNI_ENOMEM; } } else { ! char buffer[256]; ! strcpy(buffer, "java.awt.headless="); ! strcat(buffer, envbuffer); ! if (!add_property(buffer)) { return JNI_ENOMEM; } } } } --- 3509,3533 ---- // to be true unless the property has already been set. // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state. if (os::is_headless_jre()) { const char* headless = Arguments::get_property("java.awt.headless"); if (headless == NULL) { ! const char *headless_env = ::getenv("JAVA_AWT_HEADLESS"); ! if (headless_env == NULL) { if (!add_property("java.awt.headless=true")) { return JNI_ENOMEM; } } else { ! const char* key = "java.awt.headless="; ! char* buffer = NEW_C_HEAP_ARRAY( ! char, strlen(key) + strlen(headless_env) + 1, mtInternal); ! ! strcpy(buffer, key); ! strcat(buffer, headless_env); ! bool success = add_property(buffer); ! FREE_C_HEAP_ARRAY(char, buffer); ! if (!success) { return JNI_ENOMEM; } } } }
*** 3548,3589 **** return parse_options_environment_variable("JAVA_TOOL_OPTIONS", scp_p, scp_assembly_required_p); } jint Arguments::parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p) { ! const int N_MAX_OPTIONS = 64; ! const int OPTION_BUFFER_SIZE = 1024; ! char buffer[OPTION_BUFFER_SIZE]; - // The variable will be ignored if it exceeds the length of the buffer. // Don't check this variable if user has special privileges // (e.g. unix su command). ! if (os::getenv(name, buffer, sizeof(buffer)) && ! !os::have_special_privileges()) { ! JavaVMOption options[N_MAX_OPTIONS]; // Construct option array jio_fprintf(defaultStream::error_stream(), "Picked up %s: %s\n", name, buffer); char* rd = buffer; // pointer to the input string (rd) ! int i; ! for (i = 0; i < N_MAX_OPTIONS;) { // repeat for all options in the input string while (isspace(*rd)) rd++; // skip whitespace if (*rd == 0) break; // we re done when the input string is read completely // The output, option string, overwrites the input string. // Because of quoting, the pointer to the option string (wrt) may lag the pointer to // input string (rd). char* wrt = rd; ! options[i++].optionString = wrt; // Fill in option while (*rd != 0 && !isspace(*rd)) { // unquoted strings terminate with a space or NULL if (*rd == '\'' || *rd == '"') { // handle a quoted string int quote = *rd; // matching quote to look for rd++; // don't copy open quote while (*rd != quote) { // include everything (even spaces) up until quote if (*rd == 0) { // string termination means unmatched string jio_fprintf(defaultStream::error_stream(), "Unmatched quote in %s\n", name); return JNI_ERR; } *wrt++ = *rd++; // copy to option string } rd++; // don't copy close quote --- 3553,3598 ---- return parse_options_environment_variable("JAVA_TOOL_OPTIONS", scp_p, scp_assembly_required_p); } jint Arguments::parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p) { ! char *buffer = ::getenv(name); // Don't check this variable if user has special privileges // (e.g. unix su command). ! if (buffer == NULL || os::have_special_privileges()) { ! return JNI_OK; ! } ! ! if ((buffer = os::strdup(buffer)) == NULL) { ! return JNI_OK; ! } ! GrowableArray<JavaVMOption> options(2, true); // Construct option array jio_fprintf(defaultStream::error_stream(), "Picked up %s: %s\n", name, buffer); char* rd = buffer; // pointer to the input string (rd) ! while (true) { // repeat for all options in the input string while (isspace(*rd)) rd++; // skip whitespace if (*rd == 0) break; // we re done when the input string is read completely // The output, option string, overwrites the input string. // Because of quoting, the pointer to the option string (wrt) may lag the pointer to // input string (rd). char* wrt = rd; ! JavaVMOption option; ! option.optionString = wrt; ! options.append(option); // Fill in option while (*rd != 0 && !isspace(*rd)) { // unquoted strings terminate with a space or NULL if (*rd == '\'' || *rd == '"') { // handle a quoted string int quote = *rd; // matching quote to look for rd++; // don't copy open quote while (*rd != quote) { // include everything (even spaces) up until quote if (*rd == 0) { // string termination means unmatched string jio_fprintf(defaultStream::error_stream(), "Unmatched quote in %s\n", name); + os::free(buffer); return JNI_ERR; } *wrt++ = *rd++; // copy to option string } rd++; // don't copy close quote
*** 3597,3611 **** *wrt = 0; break; } *wrt = 0; // Zero terminate option } // Construct JavaVMInitArgs structure and parse as if it was part of the command line JavaVMInitArgs vm_args; vm_args.version = JNI_VERSION_1_2; ! vm_args.options = options; ! vm_args.nOptions = i; vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions; if (PrintVMOptions) { const char* tail; for (int i = 0; i < vm_args.nOptions; i++) { --- 3606,3626 ---- *wrt = 0; break; } *wrt = 0; // Zero terminate option } + JavaVMOption* options_arr = + NEW_C_HEAP_ARRAY(JavaVMOption, options.length(), mtInternal); + for (int i = 0; i < options.length(); i++) { + options_arr[i] = options.at(i); + } + // Construct JavaVMInitArgs structure and parse as if it was part of the command line JavaVMInitArgs vm_args; vm_args.version = JNI_VERSION_1_2; ! vm_args.options = options_arr; ! vm_args.nOptions = options.length(); vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions; if (PrintVMOptions) { const char* tail; for (int i = 0; i < vm_args.nOptions; i++) {
*** 3614,3626 **** logOption(tail); } } } ! return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, Flag::ENVIRON_VAR)); ! } ! return JNI_OK; } void Arguments::set_shared_spaces_flags() { if (DumpSharedSpaces) { if (RequireSharedSpaces) { --- 3629,3643 ---- logOption(tail); } } } ! jint result = parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, ! Flag::ENVIRON_VAR); ! FREE_C_HEAP_ARRAY(JavaVMOption, options_arr); ! os::free(buffer); ! return result; } void Arguments::set_shared_spaces_flags() { if (DumpSharedSpaces) { if (RequireSharedSpaces) {
< prev index next >