41 #include "runtime/vm_version.hpp" |
42 #include "runtime/vm_version.hpp" |
42 #include "services/management.hpp" |
43 #include "services/management.hpp" |
43 #include "services/memTracker.hpp" |
44 #include "services/memTracker.hpp" |
44 #include "utilities/defaultStream.hpp" |
45 #include "utilities/defaultStream.hpp" |
45 #include "utilities/macros.hpp" |
46 #include "utilities/macros.hpp" |
|
47 #include "utilities/stringUtils.hpp" |
46 #include "utilities/taskqueue.hpp" |
48 #include "utilities/taskqueue.hpp" |
47 #if INCLUDE_ALL_GCS |
49 #if INCLUDE_ALL_GCS |
48 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp" |
50 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp" |
49 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
51 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
50 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" |
52 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" |
1113 |
1115 |
1114 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS |
1116 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS |
1115 // Conflict: required to use shared spaces (-Xshare:on), but |
1117 // Conflict: required to use shared spaces (-Xshare:on), but |
1116 // incompatible command line options were chosen. |
1118 // incompatible command line options were chosen. |
1117 |
1119 |
1118 static void no_shared_spaces() { |
1120 static void no_shared_spaces(const char* message) { |
1119 if (RequireSharedSpaces) { |
1121 if (RequireSharedSpaces) { |
1120 jio_fprintf(defaultStream::error_stream(), |
1122 jio_fprintf(defaultStream::error_stream(), |
1121 "Class data sharing is inconsistent with other specified options.\n"); |
1123 "Class data sharing is inconsistent with other specified options.\n"); |
1122 vm_exit_during_initialization("Unable to use shared archive.", NULL); |
1124 vm_exit_during_initialization("Unable to use shared archive.", message); |
1123 } else { |
1125 } else { |
1124 FLAG_SET_DEFAULT(UseSharedSpaces, false); |
1126 FLAG_SET_DEFAULT(UseSharedSpaces, false); |
1125 } |
1127 } |
1126 } |
1128 } |
1127 #endif |
1129 #endif |
1579 // server performance. When -server is specified, keep the default off |
1581 // server performance. When -server is specified, keep the default off |
1580 // unless it is asked for. Future work: either add bytecode rewriting |
1582 // unless it is asked for. Future work: either add bytecode rewriting |
1581 // at link time, or rewrite bytecodes in non-shared methods. |
1583 // at link time, or rewrite bytecodes in non-shared methods. |
1582 if (!DumpSharedSpaces && !RequireSharedSpaces && |
1584 if (!DumpSharedSpaces && !RequireSharedSpaces && |
1583 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) { |
1585 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) { |
1584 no_shared_spaces(); |
1586 no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on."); |
1585 } |
1587 } |
1586 #endif |
1588 #endif |
1587 |
1589 |
1588 set_conservative_max_heap_alignment(); |
1590 set_conservative_max_heap_alignment(); |
1589 |
1591 |
3300 } else if (is_bad_option(option, args->ignoreUnrecognized)) { |
3302 } else if (is_bad_option(option, args->ignoreUnrecognized)) { |
3301 return JNI_ERR; |
3303 return JNI_ERR; |
3302 } |
3304 } |
3303 } |
3305 } |
3304 |
3306 |
|
3307 // PrintSharedArchiveAndExit will turn on |
|
3308 // -Xshare:on |
|
3309 // -XX:+TraceClassPaths |
|
3310 if (PrintSharedArchiveAndExit) { |
|
3311 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); |
|
3312 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true); |
|
3313 FLAG_SET_CMDLINE(bool, TraceClassPaths, true); |
|
3314 } |
|
3315 |
3305 // Change the default value for flags which have different default values |
3316 // Change the default value for flags which have different default values |
3306 // when working with older JDKs. |
3317 // when working with older JDKs. |
3307 #ifdef LINUX |
3318 #ifdef LINUX |
3308 if (JDK_Version::current().compare_major(6) <= 0 && |
3319 if (JDK_Version::current().compare_major(6) <= 0 && |
3309 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) { |
3320 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) { |
3310 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false); |
3321 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false); |
3311 } |
3322 } |
3312 #endif // LINUX |
3323 #endif // LINUX |
|
3324 fix_appclasspath(); |
3313 return JNI_OK; |
3325 return JNI_OK; |
|
3326 } |
|
3327 |
|
3328 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled) |
|
3329 // |
|
3330 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar |
|
3331 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar". |
|
3332 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty |
|
3333 // path is treated as the current directory. |
|
3334 // |
|
3335 // This causes problems with CDS, which requires that all directories specified in the classpath |
|
3336 // must be empty. In most cases, applications do NOT want to load classes from the current |
|
3337 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up |
|
3338 // scripts compatible with CDS. |
|
3339 void Arguments::fix_appclasspath() { |
|
3340 if (IgnoreEmptyClassPaths) { |
|
3341 const char separator = *os::path_separator(); |
|
3342 const char* src = _java_class_path->value(); |
|
3343 |
|
3344 // skip over all the leading empty paths |
|
3345 while (*src == separator) { |
|
3346 src ++; |
|
3347 } |
|
3348 |
|
3349 char* copy = AllocateHeap(strlen(src) + 1, mtInternal); |
|
3350 strncpy(copy, src, strlen(src) + 1); |
|
3351 |
|
3352 // trim all trailing empty paths |
|
3353 for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) { |
|
3354 *tail = '\0'; |
|
3355 } |
|
3356 |
|
3357 char from[3] = {separator, separator, '\0'}; |
|
3358 char to [2] = {separator, '\0'}; |
|
3359 while (StringUtils::replace_no_expand(copy, from, to) > 0) { |
|
3360 // Keep replacing "::" -> ":" until we have no more "::" (non-windows) |
|
3361 // Keep replacing ";;" -> ";" until we have no more ";;" (windows) |
|
3362 } |
|
3363 |
|
3364 _java_class_path->set_value(copy); |
|
3365 FreeHeap(copy); // a copy was made by set_value, so don't need this anymore |
|
3366 } |
|
3367 |
|
3368 if (!PrintSharedArchiveAndExit) { |
|
3369 ClassLoader::trace_class_path("[classpath: ", _java_class_path->value()); |
|
3370 } |
3314 } |
3371 } |
3315 |
3372 |
3316 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) { |
3373 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) { |
3317 // This must be done after all -D arguments have been processed. |
3374 // This must be done after all -D arguments have been processed. |
3318 scp_p->expand_endorsed(); |
3375 scp_p->expand_endorsed(); |