< prev index next >

src/hotspot/share/classfile/classLoader.cpp

Print this page




 122 PerfCounter*    ClassLoader::_perf_app_classload_time = NULL;
 123 PerfCounter*    ClassLoader::_perf_app_classload_selftime = NULL;
 124 PerfCounter*    ClassLoader::_perf_app_classload_count = NULL;
 125 PerfCounter*    ClassLoader::_perf_define_appclasses = NULL;
 126 PerfCounter*    ClassLoader::_perf_define_appclass_time = NULL;
 127 PerfCounter*    ClassLoader::_perf_define_appclass_selftime = NULL;
 128 PerfCounter*    ClassLoader::_perf_app_classfile_bytes_read = NULL;
 129 PerfCounter*    ClassLoader::_perf_sys_classfile_bytes_read = NULL;
 130 PerfCounter*    ClassLoader::_sync_systemLoaderLockContentionRate = NULL;
 131 PerfCounter*    ClassLoader::_sync_nonSystemLoaderLockContentionRate = NULL;
 132 PerfCounter*    ClassLoader::_sync_JVMFindLoadedClassLockFreeCounter = NULL;
 133 PerfCounter*    ClassLoader::_sync_JVMDefineClassLockFreeCounter = NULL;
 134 PerfCounter*    ClassLoader::_sync_JNIDefineClassLockFreeCounter = NULL;
 135 PerfCounter*    ClassLoader::_unsafe_defineClassCallCounter = NULL;
 136 
 137 GrowableArray<ModuleClassPathList*>* ClassLoader::_patch_mod_entries = NULL;
 138 GrowableArray<ModuleClassPathList*>* ClassLoader::_exploded_entries = NULL;
 139 ClassPathEntry* ClassLoader::_jrt_entry = NULL;
 140 ClassPathEntry* ClassLoader::_first_append_entry = NULL;
 141 ClassPathEntry* ClassLoader::_last_append_entry  = NULL;

 142 #if INCLUDE_CDS
 143 ClassPathEntry* ClassLoader::_app_classpath_entries = NULL;
 144 ClassPathEntry* ClassLoader::_last_app_classpath_entry = NULL;
 145 ClassPathEntry* ClassLoader::_module_path_entries = NULL;
 146 ClassPathEntry* ClassLoader::_last_module_path_entry = NULL;
 147 SharedPathsMiscInfo* ClassLoader::_shared_paths_misc_info = NULL;
 148 #endif
 149 
 150 // helper routines
 151 bool string_starts_with(const char* str, const char* str_to_find) {
 152   size_t str_len = strlen(str);
 153   size_t str_to_find_len = strlen(str_to_find);
 154   if (str_to_find_len > str_len) {
 155     return false;
 156   }
 157   return (strncmp(str, str_to_find, str_to_find_len) == 0);
 158 }
 159 
 160 static const char* get_jimage_version_string() {
 161   static char version_string[10] = "";


 719     }
 720     EXCEPTION_MARK;
 721     ResourceMark rm(THREAD);
 722     char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
 723     strncpy(path, &class_path[start], end - start);
 724     path[end - start] = '\0';
 725 
 726     if (set_base_piece) {
 727       // The first time through the bootstrap_search setup, it must be determined
 728       // what the base or core piece of the boot loader search is.  Either a java runtime
 729       // image is present or this is an exploded module build situation.
 730       assert(string_ends_with(path, MODULES_IMAGE_NAME) || string_ends_with(path, JAVA_BASE_NAME),
 731              "Incorrect boot loader search path, no java runtime image or " JAVA_BASE_NAME " exploded build");
 732       struct stat st;
 733       if (os::stat(path, &st) == 0) {
 734         // Directory found
 735         ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, CHECK);
 736 
 737         // Check for a jimage
 738         if (Arguments::has_jimage()) {


 739           assert(_jrt_entry == NULL, "should not setup bootstrap class search path twice");
 740           assert(new_entry != NULL && new_entry->is_modules_image(), "No java runtime image present");
 741           _jrt_entry = new_entry;
 742           assert(_jrt_entry->jimage() != NULL, "No java runtime image");
 743         }
 744       } else {
 745         // If path does not exist, exit
 746         vm_exit_during_initialization("Unable to establish the boot loader search path", path);
 747       }
 748       set_base_piece = false;
 749     } else {
 750       // Every entry on the system boot class path after the initial base piece,
 751       // which is set by os::set_boot_path(), is considered an appended entry.
 752       update_class_path_entry_list(path, false, true);
 753     }
 754 
 755     while (class_path[end] == os::path_separator()[0]) {
 756       end++;
 757     }
 758   }


 829       if (zip != NULL && error_msg == NULL) {
 830         new_entry = new ClassPathZipEntry(zip, path, is_boot_append);
 831       } else {
 832         char *msg;
 833         if (error_msg == NULL) {
 834           msg = NEW_RESOURCE_ARRAY_IN_THREAD(thread, char, strlen(path) + 128); ;
 835           jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path);
 836         } else {
 837           int len = (int)(strlen(path) + strlen(error_msg) + 128);
 838           msg = NEW_RESOURCE_ARRAY_IN_THREAD(thread, char, len); ;
 839           jio_snprintf(msg, len - 1, "error in opening JAR file <%s> %s", error_msg, path);
 840         }
 841         // Don't complain about bad jar files added via -Xbootclasspath/a:.
 842         if (throw_exception && is_init_completed()) {
 843           THROW_MSG_(vmSymbols::java_lang_ClassNotFoundException(), msg, NULL);
 844         } else {
 845           return NULL;
 846         }
 847       }
 848     }
 849     log_info(class, path)("opened: %s", path);
 850     log_info(class, load)("opened: %s", path);
 851   } else {
 852     // Directory
 853     new_entry = new ClassPathDirEntry(path);
 854     log_info(class, load)("path: %s", path);
 855   }
 856   return new_entry;
 857 }
 858 
 859 
 860 // Create a class path zip entry for a given path (return NULL if not found
 861 // or zip/JAR file cannot be opened)
 862 ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path, bool is_boot_append) {
 863   // check for a regular file
 864   struct stat st;
 865   if (os::stat(path, &st) == 0) {
 866     if ((st.st_mode & S_IFMT) == S_IFREG) {
 867       char canonical_path[JVM_MAXPATHLEN];
 868       if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
 869         char* error_msg = NULL;




 122 PerfCounter*    ClassLoader::_perf_app_classload_time = NULL;
 123 PerfCounter*    ClassLoader::_perf_app_classload_selftime = NULL;
 124 PerfCounter*    ClassLoader::_perf_app_classload_count = NULL;
 125 PerfCounter*    ClassLoader::_perf_define_appclasses = NULL;
 126 PerfCounter*    ClassLoader::_perf_define_appclass_time = NULL;
 127 PerfCounter*    ClassLoader::_perf_define_appclass_selftime = NULL;
 128 PerfCounter*    ClassLoader::_perf_app_classfile_bytes_read = NULL;
 129 PerfCounter*    ClassLoader::_perf_sys_classfile_bytes_read = NULL;
 130 PerfCounter*    ClassLoader::_sync_systemLoaderLockContentionRate = NULL;
 131 PerfCounter*    ClassLoader::_sync_nonSystemLoaderLockContentionRate = NULL;
 132 PerfCounter*    ClassLoader::_sync_JVMFindLoadedClassLockFreeCounter = NULL;
 133 PerfCounter*    ClassLoader::_sync_JVMDefineClassLockFreeCounter = NULL;
 134 PerfCounter*    ClassLoader::_sync_JNIDefineClassLockFreeCounter = NULL;
 135 PerfCounter*    ClassLoader::_unsafe_defineClassCallCounter = NULL;
 136 
 137 GrowableArray<ModuleClassPathList*>* ClassLoader::_patch_mod_entries = NULL;
 138 GrowableArray<ModuleClassPathList*>* ClassLoader::_exploded_entries = NULL;
 139 ClassPathEntry* ClassLoader::_jrt_entry = NULL;
 140 ClassPathEntry* ClassLoader::_first_append_entry = NULL;
 141 ClassPathEntry* ClassLoader::_last_append_entry  = NULL;
 142 const char*     ClassLoader::_modules_image_identity = MODULES_IMAGE_NAME;
 143 #if INCLUDE_CDS
 144 ClassPathEntry* ClassLoader::_app_classpath_entries = NULL;
 145 ClassPathEntry* ClassLoader::_last_app_classpath_entry = NULL;
 146 ClassPathEntry* ClassLoader::_module_path_entries = NULL;
 147 ClassPathEntry* ClassLoader::_last_module_path_entry = NULL;
 148 SharedPathsMiscInfo* ClassLoader::_shared_paths_misc_info = NULL;
 149 #endif
 150 
 151 // helper routines
 152 bool string_starts_with(const char* str, const char* str_to_find) {
 153   size_t str_len = strlen(str);
 154   size_t str_to_find_len = strlen(str_to_find);
 155   if (str_to_find_len > str_len) {
 156     return false;
 157   }
 158   return (strncmp(str, str_to_find, str_to_find_len) == 0);
 159 }
 160 
 161 static const char* get_jimage_version_string() {
 162   static char version_string[10] = "";


 720     }
 721     EXCEPTION_MARK;
 722     ResourceMark rm(THREAD);
 723     char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
 724     strncpy(path, &class_path[start], end - start);
 725     path[end - start] = '\0';
 726 
 727     if (set_base_piece) {
 728       // The first time through the bootstrap_search setup, it must be determined
 729       // what the base or core piece of the boot loader search is.  Either a java runtime
 730       // image is present or this is an exploded module build situation.
 731       assert(string_ends_with(path, MODULES_IMAGE_NAME) || string_ends_with(path, JAVA_BASE_NAME),
 732              "Incorrect boot loader search path, no java runtime image or " JAVA_BASE_NAME " exploded build");
 733       struct stat st;
 734       if (os::stat(path, &st) == 0) {
 735         // Directory found
 736         ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, CHECK);
 737 
 738         // Check for a jimage
 739         if (Arguments::has_jimage()) {
 740           _modules_image_identity = os::strdup(new_entry->name());
 741 
 742           assert(_jrt_entry == NULL, "should not setup bootstrap class search path twice");
 743           assert(new_entry != NULL && new_entry->is_modules_image(), "No java runtime image present");
 744           _jrt_entry = new_entry;
 745           assert(_jrt_entry->jimage() != NULL, "No java runtime image");
 746         }
 747       } else {
 748         // If path does not exist, exit
 749         vm_exit_during_initialization("Unable to establish the boot loader search path", path);
 750       }
 751       set_base_piece = false;
 752     } else {
 753       // Every entry on the system boot class path after the initial base piece,
 754       // which is set by os::set_boot_path(), is considered an appended entry.
 755       update_class_path_entry_list(path, false, true);
 756     }
 757 
 758     while (class_path[end] == os::path_separator()[0]) {
 759       end++;
 760     }
 761   }


 832       if (zip != NULL && error_msg == NULL) {
 833         new_entry = new ClassPathZipEntry(zip, path, is_boot_append);
 834       } else {
 835         char *msg;
 836         if (error_msg == NULL) {
 837           msg = NEW_RESOURCE_ARRAY_IN_THREAD(thread, char, strlen(path) + 128); ;
 838           jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path);
 839         } else {
 840           int len = (int)(strlen(path) + strlen(error_msg) + 128);
 841           msg = NEW_RESOURCE_ARRAY_IN_THREAD(thread, char, len); ;
 842           jio_snprintf(msg, len - 1, "error in opening JAR file <%s> %s", error_msg, path);
 843         }
 844         // Don't complain about bad jar files added via -Xbootclasspath/a:.
 845         if (throw_exception && is_init_completed()) {
 846           THROW_MSG_(vmSymbols::java_lang_ClassNotFoundException(), msg, NULL);
 847         } else {
 848           return NULL;
 849         }
 850       }
 851     }
 852     log_info(class, path)("opened: %s (real path: %s)", path, canonical_path);
 853     log_info(class, load)("opened: %s", path);
 854   } else {
 855     // Directory
 856     new_entry = new ClassPathDirEntry(path);
 857     log_info(class, load)("path: %s", path);
 858   }
 859   return new_entry;
 860 }
 861 
 862 
 863 // Create a class path zip entry for a given path (return NULL if not found
 864 // or zip/JAR file cannot be opened)
 865 ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path, bool is_boot_append) {
 866   // check for a regular file
 867   struct stat st;
 868   if (os::stat(path, &st) == 0) {
 869     if ((st.st_mode & S_IFMT) == S_IFREG) {
 870       char canonical_path[JVM_MAXPATHLEN];
 871       if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
 872         char* error_msg = NULL;


< prev index next >