290 } |
290 } |
291 FREE_RESOURCE_ARRAY(char, path, path_len); |
291 FREE_RESOURCE_ARRAY(char, path, path_len); |
292 return NULL; |
292 return NULL; |
293 } |
293 } |
294 |
294 |
295 ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append) : ClassPathEntry() { |
295 ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name, |
|
296 bool is_boot_append, bool from_class_path_attr) : ClassPathEntry() { |
296 _zip = zip; |
297 _zip = zip; |
297 char *copy = NEW_C_HEAP_ARRAY(char, strlen(zip_name)+1, mtClass); |
298 char *copy = NEW_C_HEAP_ARRAY(char, strlen(zip_name)+1, mtClass); |
298 strcpy(copy, zip_name); |
299 strcpy(copy, zip_name); |
299 _zip_name = copy; |
300 _zip_name = copy; |
|
301 _from_class_path_attr = from_class_path_attr; |
300 } |
302 } |
301 |
303 |
302 ClassPathZipEntry::~ClassPathZipEntry() { |
304 ClassPathZipEntry::~ClassPathZipEntry() { |
303 if (ZipClose != NULL) { |
305 if (ZipClose != NULL) { |
304 (*ZipClose)(_zip); |
306 (*ZipClose)(_zip); |
575 ResourceMark rm(THREAD); |
577 ResourceMark rm(THREAD); |
576 char* path = NEW_RESOURCE_ARRAY(char, end - start + 1); |
578 char* path = NEW_RESOURCE_ARRAY(char, end - start + 1); |
577 strncpy(path, &class_path[start], end - start); |
579 strncpy(path, &class_path[start], end - start); |
578 path[end - start] = '\0'; |
580 path[end - start] = '\0'; |
579 |
581 |
580 update_class_path_entry_list(path, false, false); |
582 update_class_path_entry_list(path, false, false, false); |
581 |
583 |
582 while (class_path[end] == os::path_separator()[0]) { |
584 while (class_path[end] == os::path_separator()[0]) { |
583 end++; |
585 end++; |
584 } |
586 } |
585 } |
587 } |
610 vm_exit_during_initialization(); |
612 vm_exit_during_initialization(); |
611 } |
613 } |
612 // File or directory found |
614 // File or directory found |
613 ClassPathEntry* new_entry = NULL; |
615 ClassPathEntry* new_entry = NULL; |
614 new_entry = create_class_path_entry(path, &st, true /* throw_exception */, |
616 new_entry = create_class_path_entry(path, &st, true /* throw_exception */, |
615 false /*is_boot_append */, CHECK); |
617 false /*is_boot_append */, false /* from_class_path_attr */, CHECK); |
616 if (new_entry == NULL) { |
618 if (new_entry == NULL) { |
617 return; |
619 return; |
618 } |
620 } |
619 |
621 |
620 add_to_module_path_entries(path, new_entry); |
622 add_to_module_path_entries(path, new_entry); |
666 path[end - start] = '\0'; |
668 path[end - start] = '\0'; |
667 |
669 |
668 struct stat st; |
670 struct stat st; |
669 if (os::stat(path, &st) == 0) { |
671 if (os::stat(path, &st) == 0) { |
670 // File or directory found |
672 // File or directory found |
671 ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, CHECK); |
673 ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, false, CHECK); |
672 // If the path specification is valid, enter it into this module's list |
674 // If the path specification is valid, enter it into this module's list |
673 if (new_entry != NULL) { |
675 if (new_entry != NULL) { |
674 module_cpl->add_to_list(new_entry); |
676 module_cpl->add_to_list(new_entry); |
675 } |
677 } |
676 } |
678 } |
735 assert(string_ends_with(path, MODULES_IMAGE_NAME) || string_ends_with(path, JAVA_BASE_NAME), |
737 assert(string_ends_with(path, MODULES_IMAGE_NAME) || string_ends_with(path, JAVA_BASE_NAME), |
736 "Incorrect boot loader search path, no java runtime image or " JAVA_BASE_NAME " exploded build"); |
738 "Incorrect boot loader search path, no java runtime image or " JAVA_BASE_NAME " exploded build"); |
737 struct stat st; |
739 struct stat st; |
738 if (os::stat(path, &st) == 0) { |
740 if (os::stat(path, &st) == 0) { |
739 // Directory found |
741 // Directory found |
740 ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, CHECK); |
742 ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, false, CHECK); |
741 |
743 |
742 // Check for a jimage |
744 // Check for a jimage |
743 if (Arguments::has_jimage()) { |
745 if (Arguments::has_jimage()) { |
744 assert(_jrt_entry == NULL, "should not setup bootstrap class search path twice"); |
746 assert(_jrt_entry == NULL, "should not setup bootstrap class search path twice"); |
745 _jrt_entry = new_entry; |
747 _jrt_entry = new_entry; |
752 } |
754 } |
753 set_base_piece = false; |
755 set_base_piece = false; |
754 } else { |
756 } else { |
755 // Every entry on the system boot class path after the initial base piece, |
757 // Every entry on the system boot class path after the initial base piece, |
756 // which is set by os::set_boot_path(), is considered an appended entry. |
758 // which is set by os::set_boot_path(), is considered an appended entry. |
757 update_class_path_entry_list(path, false, true); |
759 update_class_path_entry_list(path, false, true, false); |
758 } |
760 } |
759 |
761 |
760 while (class_path[end] == os::path_separator()[0]) { |
762 while (class_path[end] == os::path_separator()[0]) { |
761 end++; |
763 end++; |
762 } |
764 } |
780 jio_snprintf(path, len, "%s%cmodules%c%s", home, file_sep, file_sep, module_name); |
782 jio_snprintf(path, len, "%s%cmodules%c%s", home, file_sep, file_sep, module_name); |
781 |
783 |
782 struct stat st; |
784 struct stat st; |
783 if (os::stat(path, &st) == 0) { |
785 if (os::stat(path, &st) == 0) { |
784 // Directory found |
786 // Directory found |
785 ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, CHECK); |
787 ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, false, CHECK); |
786 |
788 |
787 // If the path specification is valid, enter it into this module's list. |
789 // If the path specification is valid, enter it into this module's list. |
788 // There is no need to check for duplicate modules in the exploded entry list, |
790 // There is no need to check for duplicate modules in the exploded entry list, |
789 // since no two modules with the same name can be defined to the boot loader. |
791 // since no two modules with the same name can be defined to the boot loader. |
790 // This is checked at module definition time in Modules::define_module. |
792 // This is checked at module definition time in Modules::define_module. |
800 } |
802 } |
801 } |
803 } |
802 |
804 |
803 ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const struct stat* st, |
805 ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const struct stat* st, |
804 bool throw_exception, |
806 bool throw_exception, |
805 bool is_boot_append, TRAPS) { |
807 bool is_boot_append, |
|
808 bool from_class_path_attr, |
|
809 TRAPS) { |
806 JavaThread* thread = JavaThread::current(); |
810 JavaThread* thread = JavaThread::current(); |
807 ClassPathEntry* new_entry = NULL; |
811 ClassPathEntry* new_entry = NULL; |
808 if ((st->st_mode & S_IFMT) == S_IFREG) { |
812 if ((st->st_mode & S_IFMT) == S_IFREG) { |
809 ResourceMark rm(thread); |
813 ResourceMark rm(thread); |
810 // Regular file, should be a zip or jimage file |
814 // Regular file, should be a zip or jimage file |
830 ThreadToNativeFromVM ttn(thread); |
834 ThreadToNativeFromVM ttn(thread); |
831 HandleMark hm(thread); |
835 HandleMark hm(thread); |
832 zip = (*ZipOpen)(canonical_path, &error_msg); |
836 zip = (*ZipOpen)(canonical_path, &error_msg); |
833 } |
837 } |
834 if (zip != NULL && error_msg == NULL) { |
838 if (zip != NULL && error_msg == NULL) { |
835 new_entry = new ClassPathZipEntry(zip, path, is_boot_append); |
839 new_entry = new ClassPathZipEntry(zip, path, is_boot_append, from_class_path_attr); |
836 } else { |
840 } else { |
837 char *msg; |
841 char *msg; |
838 if (error_msg == NULL) { |
842 if (error_msg == NULL) { |
839 msg = NEW_RESOURCE_ARRAY_IN_THREAD(thread, char, strlen(path) + 128); ; |
843 msg = NEW_RESOURCE_ARRAY_IN_THREAD(thread, char, strlen(path) + 128); ; |
840 jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path); |
844 jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path); |
880 HandleMark hm(thread); |
884 HandleMark hm(thread); |
881 zip = (*ZipOpen)(canonical_path, &error_msg); |
885 zip = (*ZipOpen)(canonical_path, &error_msg); |
882 } |
886 } |
883 if (zip != NULL && error_msg == NULL) { |
887 if (zip != NULL && error_msg == NULL) { |
884 // create using canonical path |
888 // create using canonical path |
885 return new ClassPathZipEntry(zip, canonical_path, is_boot_append); |
889 return new ClassPathZipEntry(zip, canonical_path, is_boot_append, false); |
886 } |
890 } |
887 } |
891 } |
888 } |
892 } |
889 } |
893 } |
890 return NULL; |
894 return NULL; |
954 |
958 |
955 // Returns true IFF the file/dir exists and the entry was successfully created. |
959 // Returns true IFF the file/dir exists and the entry was successfully created. |
956 bool ClassLoader::update_class_path_entry_list(const char *path, |
960 bool ClassLoader::update_class_path_entry_list(const char *path, |
957 bool check_for_duplicates, |
961 bool check_for_duplicates, |
958 bool is_boot_append, |
962 bool is_boot_append, |
|
963 bool from_class_path_attr, |
959 bool throw_exception) { |
964 bool throw_exception) { |
960 struct stat st; |
965 struct stat st; |
961 if (os::stat(path, &st) == 0) { |
966 if (os::stat(path, &st) == 0) { |
962 // File or directory found |
967 // File or directory found |
963 ClassPathEntry* new_entry = NULL; |
968 ClassPathEntry* new_entry = NULL; |
964 Thread* THREAD = Thread::current(); |
969 Thread* THREAD = Thread::current(); |
965 new_entry = create_class_path_entry(path, &st, throw_exception, is_boot_append, CHECK_(false)); |
970 new_entry = create_class_path_entry(path, &st, throw_exception, is_boot_append, from_class_path_attr, CHECK_(false)); |
966 if (new_entry == NULL) { |
971 if (new_entry == NULL) { |
967 return false; |
972 return false; |
968 } |
973 } |
969 |
974 |
970 // Do not reorder the bootclasspath which would break get_system_package(). |
975 // Do not reorder the bootclasspath which would break get_system_package(). |