53 #include "runtime/mutexLocker.hpp" |
53 #include "runtime/mutexLocker.hpp" |
54 #include "runtime/os.inline.hpp" |
54 #include "runtime/os.inline.hpp" |
55 #include "runtime/vm_version.hpp" |
55 #include "runtime/vm_version.hpp" |
56 #include "services/memTracker.hpp" |
56 #include "services/memTracker.hpp" |
57 #include "utilities/align.hpp" |
57 #include "utilities/align.hpp" |
|
58 #include "utilities/classpathStream.hpp" |
58 #include "utilities/defaultStream.hpp" |
59 #include "utilities/defaultStream.hpp" |
59 #if INCLUDE_G1GC |
60 #if INCLUDE_G1GC |
60 #include "gc/g1/g1CollectedHeap.hpp" |
61 #include "gc/g1/g1CollectedHeap.hpp" |
61 #include "gc/g1/heapRegion.hpp" |
62 #include "gc/g1/heapRegion.hpp" |
62 #endif |
63 #endif |
564 } |
565 } |
565 } |
566 } |
566 return npaths; |
567 return npaths; |
567 } |
568 } |
568 |
569 |
569 GrowableArray<char*>* FileMapInfo::create_path_array(const char* path) { |
570 GrowableArray<const char*>* FileMapInfo::create_path_array(const char* paths) { |
570 GrowableArray<char*>* path_array = new(ResourceObj::RESOURCE_AREA, mtInternal) |
571 GrowableArray<const char*>* path_array = new(ResourceObj::RESOURCE_AREA, mtInternal) |
571 GrowableArray<char*>(10); |
572 GrowableArray<const char*>(10); |
572 char* begin_ptr = (char*)path; |
573 |
573 char* end_ptr = strchr((char*)path, os::path_separator()[0]); |
574 ClasspathStream cp_stream(paths); |
574 if (end_ptr == NULL) { |
575 while (cp_stream.has_next()) { |
575 end_ptr = strchr((char*)path, '\0'); |
576 const char* path = cp_stream.get_next(); |
576 } |
577 struct stat st; |
577 while (end_ptr != NULL) { |
578 if (os::stat(path, &st) == 0) { |
578 if ((end_ptr - begin_ptr) > 1) { |
579 path_array->append(path); |
579 struct stat st; |
|
580 char* temp_name = NEW_RESOURCE_ARRAY(char, (size_t)(end_ptr - begin_ptr + 1)); |
|
581 strncpy(temp_name, begin_ptr, end_ptr - begin_ptr); |
|
582 temp_name[end_ptr - begin_ptr] = '\0'; |
|
583 if (os::stat(temp_name, &st) == 0) { |
|
584 path_array->append(temp_name); |
|
585 } |
|
586 } |
|
587 if (end_ptr < (path + strlen(path))) { |
|
588 begin_ptr = ++end_ptr; |
|
589 end_ptr = strchr(begin_ptr, os::path_separator()[0]); |
|
590 if (end_ptr == NULL) { |
|
591 end_ptr = strchr(begin_ptr, '\0'); |
|
592 } |
|
593 } else { |
|
594 break; |
|
595 } |
580 } |
596 } |
581 } |
597 return path_array; |
582 return path_array; |
598 } |
583 } |
599 |
584 |
601 ClassLoader::trace_class_path(msg, name); |
586 ClassLoader::trace_class_path(msg, name); |
602 MetaspaceShared::set_archive_loading_failed(); |
587 MetaspaceShared::set_archive_loading_failed(); |
603 return false; |
588 return false; |
604 } |
589 } |
605 |
590 |
606 bool FileMapInfo::check_paths(int shared_path_start_idx, int num_paths, GrowableArray<char*>* rp_array) { |
591 bool FileMapInfo::check_paths(int shared_path_start_idx, int num_paths, GrowableArray<const char*>* rp_array) { |
607 int i = 0; |
592 int i = 0; |
608 int j = shared_path_start_idx; |
593 int j = shared_path_start_idx; |
609 bool mismatch = false; |
594 bool mismatch = false; |
610 while (i < num_paths && !mismatch) { |
595 while (i < num_paths && !mismatch) { |
611 while (shared_path(j)->from_class_path_attr()) { |
596 while (shared_path(j)->from_class_path_attr()) { |
655 mismatch = true; |
640 mismatch = true; |
656 } |
641 } |
657 } else if (dp_len > 0 && rp != NULL) { |
642 } else if (dp_len > 0 && rp != NULL) { |
658 int num; |
643 int num; |
659 ResourceMark rm; |
644 ResourceMark rm; |
660 GrowableArray<char*>* rp_array = create_path_array(rp); |
645 GrowableArray<const char*>* rp_array = create_path_array(rp); |
661 int rp_len = rp_array->length(); |
646 int rp_len = rp_array->length(); |
662 if (rp_len >= dp_len) { |
647 if (rp_len >= dp_len) { |
663 if (relaxed_check) { |
648 if (relaxed_check) { |
664 // only check the leading entries in the runtime boot path, up to |
649 // only check the leading entries in the runtime boot path, up to |
665 // the length of the dump time boot path |
650 // the length of the dump time boot path |
688 return fail("Run time APP classpath is shorter than the one at dump time: ", appcp); |
673 return fail("Run time APP classpath is shorter than the one at dump time: ", appcp); |
689 } |
674 } |
690 if (shared_app_paths_len != 0 && rp_len != 0) { |
675 if (shared_app_paths_len != 0 && rp_len != 0) { |
691 // Prefix is OK: E.g., dump with -cp foo.jar, but run with -cp foo.jar:bar.jar. |
676 // Prefix is OK: E.g., dump with -cp foo.jar, but run with -cp foo.jar:bar.jar. |
692 ResourceMark rm; |
677 ResourceMark rm; |
693 GrowableArray<char*>* rp_array = create_path_array(appcp); |
678 GrowableArray<const char*>* rp_array = create_path_array(appcp); |
694 if (rp_array->length() == 0) { |
679 if (rp_array->length() == 0) { |
695 // None of the jar file specified in the runtime -cp exists. |
680 // None of the jar file specified in the runtime -cp exists. |
696 return fail("None of the jar file specified in the runtime -cp exists: -Djava.class.path=", appcp); |
681 return fail("None of the jar file specified in the runtime -cp exists: -Djava.class.path=", appcp); |
697 } |
682 } |
698 int j = _header->_app_class_paths_start_index; |
683 int j = _header->_app_class_paths_start_index; |