388
389 // Flags that are aliases for other flags.
390 typedef struct {
391 const char* alias_name;
392 const char* real_name;
393 } AliasedFlag;
394
395 static AliasedFlag const aliased_jvm_flags[] = {
396 { "DefaultMaxRAMFraction", "MaxRAMFraction" },
397 { "CMSMarkStackSizeMax", "MarkStackSizeMax" },
398 { "CMSMarkStackSize", "MarkStackSize" },
399 { "G1MarkStackSize", "MarkStackSize" },
400 { "ParallelMarkingThreads", "ConcGCThreads" },
401 { "ParallelCMSThreads", "ConcGCThreads" },
402 { "CreateMinidumpOnCrash", "CreateCoredumpOnCrash" },
403 { NULL, NULL}
404 };
405
406 static AliasedLoggingFlag const aliased_logging_flags[] = {
407 { "TraceClassLoading", LogLevel::Info, true, LogTag::_classload },
408 { "TraceClassUnloading", LogLevel::Info, true, LogTag::_classunload },
409 { "TraceClassResolution", LogLevel::Info, true, LogTag::_classresolve },
410 { "TraceExceptions", LogLevel::Info, true, LogTag::_exceptions },
411 { "TraceMonitorInflation", LogLevel::Debug, true, LogTag::_monitorinflation },
412 { NULL, LogLevel::Off, false, LogTag::__NO_TAG }
413 };
414
415 // Return true if "v" is less than "other", where "other" may be "undefined".
416 static bool version_less_than(JDK_Version v, JDK_Version other) {
417 assert(!v.is_undefined(), "must be defined");
418 if (!other.is_undefined() && v.compare(other) >= 0) {
419 return false;
420 } else {
421 return true;
422 }
423 }
424
425 static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {
426 for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
427 if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
428 flag = special_jvm_flags[i];
429 return true;
3237 "ManagementServer is not supported in this VM.\n");
3238 return JNI_ERR;
3239 #endif // INCLUDE_MANAGEMENT
3240 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3241 // Skip -XX:Flags= and -XX:VMOptionsFile= since those cases have
3242 // already been handled
3243 if ((strncmp(tail, "Flags=", strlen("Flags=")) != 0) &&
3244 (strncmp(tail, "VMOptionsFile=", strlen("VMOptionsFile=")) != 0)) {
3245 if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
3246 return JNI_EINVAL;
3247 }
3248 }
3249 // Unknown option
3250 } else if (is_bad_option(option, args->ignoreUnrecognized)) {
3251 return JNI_ERR;
3252 }
3253 }
3254
3255 // PrintSharedArchiveAndExit will turn on
3256 // -Xshare:on
3257 // -XX:+TraceClassPaths
3258 if (PrintSharedArchiveAndExit) {
3259 if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) {
3260 return JNI_EINVAL;
3261 }
3262 if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) {
3263 return JNI_EINVAL;
3264 }
3265 if (FLAG_SET_CMDLINE(bool, TraceClassPaths, true) != Flag::SUCCESS) {
3266 return JNI_EINVAL;
3267 }
3268 }
3269
3270 // Change the default value for flags which have different default values
3271 // when working with older JDKs.
3272 #ifdef LINUX
3273 if (JDK_Version::current().compare_major(6) <= 0 &&
3274 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) {
3275 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false);
3276 }
3277 #endif // LINUX
3278 fix_appclasspath();
3279 return JNI_OK;
3280 }
3281
3282 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled)
3283 //
3284 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
3285 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
3286 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
3287 // path is treated as the current directory.
3299 while (*src == separator) {
3300 src ++;
3301 }
3302
3303 char* copy = os::strdup_check_oom(src, mtInternal);
3304
3305 // trim all trailing empty paths
3306 for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) {
3307 *tail = '\0';
3308 }
3309
3310 char from[3] = {separator, separator, '\0'};
3311 char to [2] = {separator, '\0'};
3312 while (StringUtils::replace_no_expand(copy, from, to) > 0) {
3313 // Keep replacing "::" -> ":" until we have no more "::" (non-windows)
3314 // Keep replacing ";;" -> ";" until we have no more ";;" (windows)
3315 }
3316
3317 _java_class_path->set_value(copy);
3318 FreeHeap(copy); // a copy was made by set_value, so don't need this anymore
3319 }
3320
3321 if (!PrintSharedArchiveAndExit) {
3322 ClassLoader::trace_class_path(tty, "[classpath: ", _java_class_path->value());
3323 }
3324 }
3325
3326 static bool has_jar_files(const char* directory) {
3327 DIR* dir = os::opendir(directory);
3328 if (dir == NULL) return false;
3329
3330 struct dirent *entry;
3331 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
3332 bool hasJarFile = false;
3333 while (!hasJarFile && (entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
3334 const char* name = entry->d_name;
3335 const char* ext = name + strlen(name) - 4;
3336 hasJarFile = ext > name && (os::file_name_strcmp(ext, ".jar") == 0);
3337 }
3338 FREE_C_HEAP_ARRAY(char, dbuf);
3339 os::closedir(dir);
3340 return hasJarFile ;
3341 }
3342
|
388
389 // Flags that are aliases for other flags.
390 typedef struct {
391 const char* alias_name;
392 const char* real_name;
393 } AliasedFlag;
394
395 static AliasedFlag const aliased_jvm_flags[] = {
396 { "DefaultMaxRAMFraction", "MaxRAMFraction" },
397 { "CMSMarkStackSizeMax", "MarkStackSizeMax" },
398 { "CMSMarkStackSize", "MarkStackSize" },
399 { "G1MarkStackSize", "MarkStackSize" },
400 { "ParallelMarkingThreads", "ConcGCThreads" },
401 { "ParallelCMSThreads", "ConcGCThreads" },
402 { "CreateMinidumpOnCrash", "CreateCoredumpOnCrash" },
403 { NULL, NULL}
404 };
405
406 static AliasedLoggingFlag const aliased_logging_flags[] = {
407 { "TraceClassLoading", LogLevel::Info, true, LogTag::_classload },
408 { "TraceClassPaths", LogLevel::Info, true, LogTag::_classpath },
409 { "TraceClassResolution", LogLevel::Info, true, LogTag::_classresolve },
410 { "TraceClassUnloading", LogLevel::Info, true, LogTag::_classunload },
411 { "TraceExceptions", LogLevel::Info, true, LogTag::_exceptions },
412 { "TraceMonitorInflation", LogLevel::Debug, true, LogTag::_monitorinflation },
413 { NULL, LogLevel::Off, false, LogTag::__NO_TAG }
414 };
415
416 // Return true if "v" is less than "other", where "other" may be "undefined".
417 static bool version_less_than(JDK_Version v, JDK_Version other) {
418 assert(!v.is_undefined(), "must be defined");
419 if (!other.is_undefined() && v.compare(other) >= 0) {
420 return false;
421 } else {
422 return true;
423 }
424 }
425
426 static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {
427 for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
428 if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
429 flag = special_jvm_flags[i];
430 return true;
3238 "ManagementServer is not supported in this VM.\n");
3239 return JNI_ERR;
3240 #endif // INCLUDE_MANAGEMENT
3241 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3242 // Skip -XX:Flags= and -XX:VMOptionsFile= since those cases have
3243 // already been handled
3244 if ((strncmp(tail, "Flags=", strlen("Flags=")) != 0) &&
3245 (strncmp(tail, "VMOptionsFile=", strlen("VMOptionsFile=")) != 0)) {
3246 if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
3247 return JNI_EINVAL;
3248 }
3249 }
3250 // Unknown option
3251 } else if (is_bad_option(option, args->ignoreUnrecognized)) {
3252 return JNI_ERR;
3253 }
3254 }
3255
3256 // PrintSharedArchiveAndExit will turn on
3257 // -Xshare:on
3258 // -Xlog:classpath=info
3259 if (PrintSharedArchiveAndExit) {
3260 if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) {
3261 return JNI_EINVAL;
3262 }
3263 if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) {
3264 return JNI_EINVAL;
3265 }
3266 LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(classpath));
3267 }
3268
3269 // Change the default value for flags which have different default values
3270 // when working with older JDKs.
3271 #ifdef LINUX
3272 if (JDK_Version::current().compare_major(6) <= 0 &&
3273 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) {
3274 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false);
3275 }
3276 #endif // LINUX
3277 fix_appclasspath();
3278 return JNI_OK;
3279 }
3280
3281 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled)
3282 //
3283 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
3284 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
3285 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
3286 // path is treated as the current directory.
3298 while (*src == separator) {
3299 src ++;
3300 }
3301
3302 char* copy = os::strdup_check_oom(src, mtInternal);
3303
3304 // trim all trailing empty paths
3305 for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) {
3306 *tail = '\0';
3307 }
3308
3309 char from[3] = {separator, separator, '\0'};
3310 char to [2] = {separator, '\0'};
3311 while (StringUtils::replace_no_expand(copy, from, to) > 0) {
3312 // Keep replacing "::" -> ":" until we have no more "::" (non-windows)
3313 // Keep replacing ";;" -> ";" until we have no more ";;" (windows)
3314 }
3315
3316 _java_class_path->set_value(copy);
3317 FreeHeap(copy); // a copy was made by set_value, so don't need this anymore
3318 }
3319 }
3320
3321 static bool has_jar_files(const char* directory) {
3322 DIR* dir = os::opendir(directory);
3323 if (dir == NULL) return false;
3324
3325 struct dirent *entry;
3326 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
3327 bool hasJarFile = false;
3328 while (!hasJarFile && (entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
3329 const char* name = entry->d_name;
3330 const char* ext = name + strlen(name) - 4;
3331 hasJarFile = ext > name && (os::file_name_strcmp(ext, ".jar") == 0);
3332 }
3333 FREE_C_HEAP_ARRAY(char, dbuf);
3334 os::closedir(dir);
3335 return hasJarFile ;
3336 }
3337
|