8155968: Update command line options
Reviewed-by: gthornbr, hseigel, mschoene
This commit is contained in:
parent
065f9a3a4e
commit
656510aa27
@ -794,9 +794,10 @@ static bool append_to_string_flag(const char* name, const char* new_value, Flag:
|
|||||||
} else if (new_len == 0) {
|
} else if (new_len == 0) {
|
||||||
value = old_value;
|
value = old_value;
|
||||||
} else {
|
} else {
|
||||||
char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtArguments);
|
size_t length = old_len + 1 + new_len + 1;
|
||||||
|
char* buf = NEW_C_HEAP_ARRAY(char, length, mtArguments);
|
||||||
// each new setting adds another LINE to the switch:
|
// each new setting adds another LINE to the switch:
|
||||||
sprintf(buf, "%s\n%s", old_value, new_value);
|
jio_snprintf(buf, length, "%s\n%s", old_value, new_value);
|
||||||
value = buf;
|
value = buf;
|
||||||
free_this_too = buf;
|
free_this_too = buf;
|
||||||
}
|
}
|
||||||
@ -1014,15 +1015,17 @@ const char* Arguments::build_resource_string(char** args, int count) {
|
|||||||
if (args == NULL || count == 0) {
|
if (args == NULL || count == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
size_t length = strlen(args[0]) + 1; // add 1 for the null terminator
|
size_t length = 0;
|
||||||
for (int i = 1; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
length += strlen(args[i]) + 1; // add 1 for a space
|
length += strlen(args[i]) + 1; // add 1 for a space or NULL terminating character
|
||||||
}
|
}
|
||||||
char* s = NEW_RESOURCE_ARRAY(char, length);
|
char* s = NEW_RESOURCE_ARRAY(char, length);
|
||||||
strcpy(s, args[0]);
|
char* dst = s;
|
||||||
for (int j = 1; j < count; j++) {
|
for (int j = 0; j < count; j++) {
|
||||||
strcat(s, " ");
|
size_t offset = strlen(args[j]) + 1; // add 1 for a space or NULL terminating character
|
||||||
strcat(s, args[j]);
|
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;
|
return (const char*) s;
|
||||||
}
|
}
|
||||||
@ -1106,9 +1109,8 @@ bool Arguments::process_argument(const char* arg,
|
|||||||
// Only make the obsolete check for valid arguments.
|
// Only make the obsolete check for valid arguments.
|
||||||
if (arg_len <= BUFLEN) {
|
if (arg_len <= BUFLEN) {
|
||||||
// Construct a string which consists only of the argument name without '+', '-', or '='.
|
// Construct a string which consists only of the argument name without '+', '-', or '='.
|
||||||
char stripped_argname[BUFLEN+1];
|
char stripped_argname[BUFLEN+1]; // +1 for '\0'
|
||||||
strncpy(stripped_argname, argname, arg_len);
|
jio_snprintf(stripped_argname, arg_len+1, "%s", argname); // +1 for '\0'
|
||||||
stripped_argname[arg_len] = '\0'; // strncpy may not null terminate.
|
|
||||||
if (is_obsolete_flag(stripped_argname, &since)) {
|
if (is_obsolete_flag(stripped_argname, &since)) {
|
||||||
char version[256];
|
char version[256];
|
||||||
since.to_string(version, sizeof(version));
|
since.to_string(version, sizeof(version));
|
||||||
@ -1260,8 +1262,7 @@ bool Arguments::add_property(const char* prop, PropertyWriteable writeable, Prop
|
|||||||
size_t key_len = eq - prop;
|
size_t key_len = eq - prop;
|
||||||
char* tmp_key = AllocateHeap(key_len + 1, mtArguments);
|
char* tmp_key = AllocateHeap(key_len + 1, mtArguments);
|
||||||
|
|
||||||
strncpy(tmp_key, prop, key_len);
|
jio_snprintf(tmp_key, key_len + 1, "%s", prop);
|
||||||
tmp_key[key_len] = '\0';
|
|
||||||
key = tmp_key;
|
key = tmp_key;
|
||||||
|
|
||||||
value = &prop[key_len + 1];
|
value = &prop[key_len + 1];
|
||||||
@ -2256,7 +2257,7 @@ jint Arguments::set_aggressive_opts_flags() {
|
|||||||
|
|
||||||
// Feed the cache size setting into the JDK
|
// Feed the cache size setting into the JDK
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
sprintf(buffer, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax);
|
jio_snprintf(buffer, 1024, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax);
|
||||||
if (!add_property(buffer)) {
|
if (!add_property(buffer)) {
|
||||||
return JNI_ENOMEM;
|
return JNI_ENOMEM;
|
||||||
}
|
}
|
||||||
@ -2777,8 +2778,8 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
|
|||||||
if (tail != NULL) {
|
if (tail != NULL) {
|
||||||
const char* pos = strchr(tail, ':');
|
const char* pos = strchr(tail, ':');
|
||||||
size_t len = (pos == NULL) ? strlen(tail) : pos - tail;
|
size_t len = (pos == NULL) ? strlen(tail) : pos - tail;
|
||||||
char* name = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len + 1, mtArguments), tail, len);
|
char* name = NEW_C_HEAP_ARRAY(char, len + 1, mtArguments);
|
||||||
name[len] = '\0';
|
jio_snprintf(name, len + 1, "%s", tail);
|
||||||
|
|
||||||
char *options = NULL;
|
char *options = NULL;
|
||||||
if(pos != NULL) {
|
if(pos != NULL) {
|
||||||
@ -2854,7 +2855,9 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
|
|||||||
return JNI_ERR;
|
return JNI_ERR;
|
||||||
#else
|
#else
|
||||||
if (tail != NULL) {
|
if (tail != NULL) {
|
||||||
char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtArguments), tail);
|
size_t length = strlen(tail) + 1;
|
||||||
|
char *options = NEW_C_HEAP_ARRAY(char, length, mtArguments);
|
||||||
|
jio_snprintf(options, length, "%s", tail);
|
||||||
add_init_agent("instrument", options, false);
|
add_init_agent("instrument", options, false);
|
||||||
// java agents need module java.instrument
|
// java agents need module java.instrument
|
||||||
if (!create_numbered_property("jdk.module.addmods", "java.instrument", addmods_count++)) {
|
if (!create_numbered_property("jdk.module.addmods", "java.instrument", addmods_count++)) {
|
||||||
@ -3512,7 +3515,7 @@ jint Arguments::finalize_vm_init_args() {
|
|||||||
// check if the default lib/endorsed directory exists; if so, error
|
// check if the default lib/endorsed directory exists; if so, error
|
||||||
char path[JVM_MAXPATHLEN];
|
char path[JVM_MAXPATHLEN];
|
||||||
const char* fileSep = os::file_separator();
|
const char* fileSep = os::file_separator();
|
||||||
sprintf(path, "%s%slib%sendorsed", Arguments::get_java_home(), fileSep, fileSep);
|
jio_snprintf(path, JVM_MAXPATHLEN, "%s%slib%sendorsed", Arguments::get_java_home(), fileSep, fileSep);
|
||||||
|
|
||||||
if (CheckEndorsedAndExtDirs) {
|
if (CheckEndorsedAndExtDirs) {
|
||||||
int nonEmptyDirs = 0;
|
int nonEmptyDirs = 0;
|
||||||
@ -3534,7 +3537,7 @@ jint Arguments::finalize_vm_init_args() {
|
|||||||
return JNI_ERR;
|
return JNI_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(path, "%s%slib%sext", Arguments::get_java_home(), fileSep, fileSep);
|
jio_snprintf(path, JVM_MAXPATHLEN, "%s%slib%sext", Arguments::get_java_home(), fileSep, fileSep);
|
||||||
dir = os::opendir(path);
|
dir = os::opendir(path);
|
||||||
if (dir != NULL) {
|
if (dir != NULL) {
|
||||||
jio_fprintf(defaultStream::output_stream(),
|
jio_fprintf(defaultStream::output_stream(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user