38 #include "runtime/java.hpp" |
39 #include "runtime/java.hpp" |
39 #include "services/management.hpp" |
40 #include "services/management.hpp" |
40 #include "services/memTracker.hpp" |
41 #include "services/memTracker.hpp" |
41 #include "utilities/defaultStream.hpp" |
42 #include "utilities/defaultStream.hpp" |
42 #include "utilities/macros.hpp" |
43 #include "utilities/macros.hpp" |
|
44 #include "utilities/stringUtils.hpp" |
43 #include "utilities/taskqueue.hpp" |
45 #include "utilities/taskqueue.hpp" |
44 #ifdef TARGET_OS_FAMILY_linux |
46 #ifdef TARGET_OS_FAMILY_linux |
45 # include "os_linux.inline.hpp" |
47 # include "os_linux.inline.hpp" |
46 #endif |
48 #endif |
47 #ifdef TARGET_OS_FAMILY_solaris |
49 #ifdef TARGET_OS_FAMILY_solaris |
1107 |
1109 |
1108 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS |
1110 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS |
1109 // Conflict: required to use shared spaces (-Xshare:on), but |
1111 // Conflict: required to use shared spaces (-Xshare:on), but |
1110 // incompatible command line options were chosen. |
1112 // incompatible command line options were chosen. |
1111 |
1113 |
1112 static void no_shared_spaces() { |
1114 static void no_shared_spaces(const char* message) { |
1113 if (RequireSharedSpaces) { |
1115 if (RequireSharedSpaces) { |
1114 jio_fprintf(defaultStream::error_stream(), |
1116 jio_fprintf(defaultStream::error_stream(), |
1115 "Class data sharing is inconsistent with other specified options.\n"); |
1117 "Class data sharing is inconsistent with other specified options.\n"); |
1116 vm_exit_during_initialization("Unable to use shared archive.", NULL); |
1118 vm_exit_during_initialization("Unable to use shared archive.", message); |
1117 } else { |
1119 } else { |
1118 FLAG_SET_DEFAULT(UseSharedSpaces, false); |
1120 FLAG_SET_DEFAULT(UseSharedSpaces, false); |
1119 } |
1121 } |
1120 } |
1122 } |
1121 #endif |
1123 #endif |
1552 // server performance. When -server is specified, keep the default off |
1554 // server performance. When -server is specified, keep the default off |
1553 // unless it is asked for. Future work: either add bytecode rewriting |
1555 // unless it is asked for. Future work: either add bytecode rewriting |
1554 // at link time, or rewrite bytecodes in non-shared methods. |
1556 // at link time, or rewrite bytecodes in non-shared methods. |
1555 if (!DumpSharedSpaces && !RequireSharedSpaces && |
1557 if (!DumpSharedSpaces && !RequireSharedSpaces && |
1556 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) { |
1558 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) { |
1557 no_shared_spaces(); |
1559 no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on."); |
1558 } |
1560 } |
1559 #endif |
1561 #endif |
1560 |
1562 |
1561 set_conservative_max_heap_alignment(); |
1563 set_conservative_max_heap_alignment(); |
1562 |
1564 |
3241 } else if (is_bad_option(option, args->ignoreUnrecognized)) { |
3243 } else if (is_bad_option(option, args->ignoreUnrecognized)) { |
3242 return JNI_ERR; |
3244 return JNI_ERR; |
3243 } |
3245 } |
3244 } |
3246 } |
3245 |
3247 |
|
3248 // PrintSharedArchiveAndExit will turn on |
|
3249 // -Xshare:on |
|
3250 // -XX:+TraceClassPaths |
|
3251 if (PrintSharedArchiveAndExit) { |
|
3252 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); |
|
3253 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true); |
|
3254 FLAG_SET_CMDLINE(bool, TraceClassPaths, true); |
|
3255 } |
|
3256 |
3246 // Change the default value for flags which have different default values |
3257 // Change the default value for flags which have different default values |
3247 // when working with older JDKs. |
3258 // when working with older JDKs. |
3248 #ifdef LINUX |
3259 #ifdef LINUX |
3249 if (JDK_Version::current().compare_major(6) <= 0 && |
3260 if (JDK_Version::current().compare_major(6) <= 0 && |
3250 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) { |
3261 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) { |
3251 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false); |
3262 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false); |
3252 } |
3263 } |
3253 #endif // LINUX |
3264 #endif // LINUX |
|
3265 fix_appclasspath(); |
3254 return JNI_OK; |
3266 return JNI_OK; |
|
3267 } |
|
3268 |
|
3269 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled) |
|
3270 // |
|
3271 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar |
|
3272 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar". |
|
3273 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty |
|
3274 // path is treated as the current directory. |
|
3275 // |
|
3276 // This causes problems with CDS, which requires that all directories specified in the classpath |
|
3277 // must be empty. In most cases, applications do NOT want to load classes from the current |
|
3278 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up |
|
3279 // scripts compatible with CDS. |
|
3280 void Arguments::fix_appclasspath() { |
|
3281 if (IgnoreEmptyClassPaths) { |
|
3282 const char separator = *os::path_separator(); |
|
3283 const char* src = _java_class_path->value(); |
|
3284 |
|
3285 // skip over all the leading empty paths |
|
3286 while (*src == separator) { |
|
3287 src ++; |
|
3288 } |
|
3289 |
|
3290 char* copy = AllocateHeap(strlen(src) + 1, mtInternal); |
|
3291 strncpy(copy, src, strlen(src) + 1); |
|
3292 |
|
3293 // trim all trailing empty paths |
|
3294 for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) { |
|
3295 *tail = '\0'; |
|
3296 } |
|
3297 |
|
3298 char from[3] = {separator, separator, '\0'}; |
|
3299 char to [2] = {separator, '\0'}; |
|
3300 while (StringUtils::replace_no_expand(copy, from, to) > 0) { |
|
3301 // Keep replacing "::" -> ":" until we have no more "::" (non-windows) |
|
3302 // Keep replacing ";;" -> ";" until we have no more ";;" (windows) |
|
3303 } |
|
3304 |
|
3305 _java_class_path->set_value(copy); |
|
3306 FreeHeap(copy); // a copy was made by set_value, so don't need this anymore |
|
3307 } |
|
3308 |
|
3309 if (!PrintSharedArchiveAndExit) { |
|
3310 ClassLoader::trace_class_path("[classpath: ", _java_class_path->value()); |
|
3311 } |
3255 } |
3312 } |
3256 |
3313 |
3257 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) { |
3314 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) { |
3258 // This must be done after all -D arguments have been processed. |
3315 // This must be done after all -D arguments have been processed. |
3259 scp_p->expand_endorsed(); |
3316 scp_p->expand_endorsed(); |