< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page
rev 4130 : 8155968: Update command line options
Reviewed-by: gthornbr, hseigel, mschoene
Contributed-by: gerard.ziemski@oracle.com

*** 501,512 **** const char* ext = name + strlen(name) - 4; bool isJarOrZip = ext > name && (os::file_name_strcmp(ext, ".jar") == 0 || os::file_name_strcmp(ext, ".zip") == 0); if (isJarOrZip) { ! char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name)); ! sprintf(jarpath, "%s%s%s", directory, dir_sep, name); path = add_to_path(path, jarpath, false); FREE_C_HEAP_ARRAY(char, jarpath); } } FREE_C_HEAP_ARRAY(char, dbuf); --- 501,513 ---- const char* ext = name + strlen(name) - 4; bool isJarOrZip = ext > name && (os::file_name_strcmp(ext, ".jar") == 0 || os::file_name_strcmp(ext, ".zip") == 0); if (isJarOrZip) { ! size_t length = directory_len + 2 + strlen(name); ! char* jarpath = NEW_C_HEAP_ARRAY(char, length); ! jio_snprintf(jarpath, length, "%s%s%s", directory, dir_sep, name); path = add_to_path(path, jarpath, false); FREE_C_HEAP_ARRAY(char, jarpath); } } FREE_C_HEAP_ARRAY(char, dbuf);
*** 645,657 **** if (old_len == 0) { value = new_value; } else if (new_len == 0) { value = old_value; } else { ! char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1); // each new setting adds another LINE to the switch: ! sprintf(buf, "%s\n%s", old_value, new_value); value = buf; free_this_too = buf; } (void) CommandLineFlags::ccstrAtPut(name, &value, origin); // CommandLineFlags always returns a pointer that needs freeing. --- 646,659 ---- if (old_len == 0) { value = new_value; } else if (new_len == 0) { value = old_value; } else { ! size_t length = old_len + 1 + new_len + 1; ! char* buf = NEW_C_HEAP_ARRAY(char, length); // each new setting adds another LINE to the switch: ! jio_snprintf(buf, length, "%s\n%s", old_value, new_value); value = buf; free_this_too = buf; } (void) CommandLineFlags::ccstrAtPut(name, &value, origin); // CommandLineFlags always returns a pointer that needs freeing.
*** 754,772 **** // strings in a given char** array const char* Arguments::build_resource_string(char** args, int count) { if (args == NULL || count == 0) { return NULL; } ! size_t length = strlen(args[0]) + 1; // add 1 for the null terminator ! for (int i = 1; i < count; i++) { ! length += strlen(args[i]) + 1; // add 1 for a space } char* s = NEW_RESOURCE_ARRAY(char, length); ! strcpy(s, args[0]); ! for (int j = 1; j < count; j++) { ! strcat(s, " "); ! strcat(s, args[j]); } return (const char*) s; } void Arguments::print_on(outputStream* st) { --- 756,776 ---- // strings in a given char** array const char* Arguments::build_resource_string(char** args, int count) { if (args == NULL || count == 0) { return NULL; } ! size_t length = 0; ! for (int i = 0; i < count; i++) { ! length += strlen(args[i]) + 1; // add 1 for a space or NULL terminating character } char* s = NEW_RESOURCE_ARRAY(char, length); ! char* dst = s; ! for (int j = 0; j < count; j++) { ! size_t offset = strlen(args[j]) + 1; // add 1 for a space or NULL terminating character ! jio_snprintf(dst, length, "%s ", args[j]); // jio_snprintf will replace the last space character with NULL character ! dst += offset; ! length -= offset; } return (const char*) s; } void Arguments::print_on(outputStream* st) {
*** 1598,1608 **** FLAG_SET_DEFAULT(AutoBoxCacheMax, 20000); } // Feed the cache size setting into the JDK char buffer[1024]; ! sprintf(buffer, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax); add_property(buffer); } if (AggressiveOpts && FLAG_IS_DEFAULT(BiasedLockingStartupDelay)) { FLAG_SET_DEFAULT(BiasedLockingStartupDelay, 500); } --- 1602,1612 ---- FLAG_SET_DEFAULT(AutoBoxCacheMax, 20000); } // Feed the cache size setting into the JDK char buffer[1024]; ! jio_snprintf(buffer, 1024, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax); add_property(buffer); } if (AggressiveOpts && FLAG_IS_DEFAULT(BiasedLockingStartupDelay)) { FLAG_SET_DEFAULT(BiasedLockingStartupDelay, 500); }
*** 2180,2190 **** char* name = strncpy(NEW_C_HEAP_ARRAY(char, len + 1), tail, len); name[len] = '\0'; char *options = NULL; if(pos != NULL) { ! options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1), pos + 1); } #ifdef JVMTI_KERNEL if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) { warning("profiling and debugging agents are not supported with Kernel VM"); } else --- 2184,2196 ---- char* name = strncpy(NEW_C_HEAP_ARRAY(char, len + 1), tail, len); name[len] = '\0'; char *options = NULL; if(pos != NULL) { ! size_t length = strlen(pos + 1) + 1; ! options = NEW_C_HEAP_ARRAY(char, length); ! jio_snprintf(options, length, "%s", pos + 1); } #ifdef JVMTI_KERNEL if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) { warning("profiling and debugging agents are not supported with Kernel VM"); } else
*** 2193,2203 **** } // -javaagent } else if (match_option(option, "-javaagent:", &tail)) { if(tail != NULL) { ! char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1), tail); add_init_agent("instrument", options, false); } // -Xnoclassgc } else if (match_option(option, "-Xnoclassgc", &tail)) { FLAG_SET_CMDLINE(bool, ClassUnloading, false); --- 2199,2211 ---- } // -javaagent } else if (match_option(option, "-javaagent:", &tail)) { if(tail != NULL) { ! size_t length = strlen(tail) + 1; ! char *options = NEW_C_HEAP_ARRAY(char, length); ! jio_snprintf(options, length, "%s", tail); add_init_agent("instrument", options, false); } // -Xnoclassgc } else if (match_option(option, "-Xnoclassgc", &tail)) { FLAG_SET_CMDLINE(bool, ClassUnloading, false);
*** 2783,2794 **** 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; } } } --- 2791,2801 ---- if (!add_property("java.awt.headless=true")) { return JNI_ENOMEM; } } else { char buffer[256]; ! jio_snprintf(buffer, 256, "java.awt.headless=%s", envbuffer); if (!add_property(buffer)) { return JNI_ENOMEM; } } }
< prev index next >