--- old/src/hotspot/share/classfile/classLoader.cpp 2018-04-09 15:29:52.635523912 -0700 +++ new/src/hotspot/share/classfile/classLoader.cpp 2018-04-09 15:29:52.357497690 -0700 @@ -739,16 +739,14 @@ } // Add a module path to the _module_path_entries list. -void ClassLoader::update_module_path_entry_list(const char *path, - bool throw_exception) { +void ClassLoader::update_module_path_entry_list(const char *path, TRAPS) { assert(DumpSharedSpaces, "dump time only"); struct stat st; int ret = os::stat(path, &st); assert(ret == 0, "module path must exist"); // File or directory found ClassPathEntry* new_entry = NULL; - Thread* THREAD = Thread::current(); - new_entry = create_class_path_entry(path, &st, throw_exception, + new_entry = create_class_path_entry(path, &st, true /* throw_exception */, false /*is_boot_append */, CHECK); if (new_entry == NULL) { return; @@ -758,9 +756,9 @@ return; } -void ClassLoader::setup_module_search_path(const char* path) { +void ClassLoader::setup_module_search_path(const char* path, TRAPS) { check_shared_classpath(path); - update_module_path_entry_list(path); + update_module_path_entry_list(path, THREAD); } #endif // INCLUDE_CDS @@ -1574,7 +1572,7 @@ // Record the shared classpath index and loader type for classes loaded // by the builtin loaders at dump time. -void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream) { +void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS) { assert(DumpSharedSpaces, "sanity"); assert(stream != NULL, "sanity"); @@ -1596,8 +1594,7 @@ assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build"); - ResourceMark rm; - Thread* THREAD = Thread::current(); + ResourceMark rm(THREAD); int classpath_index = -1; PackageEntry* pkg_entry = ik->package(); @@ -1614,7 +1611,8 @@ // class or module path, then we have a match. if (strcmp(canonical_path, os::native_path((char*)path)) == 0) { // NULL pkg_entry and pkg_entry in an unnamed module implies the class - // is from the -cp or -Xbootclasspath/a. + // is from the -cp or boot loader append path which consists of -Xbootclasspath/a + // and jvmti appended entries. if ((pkg_entry == NULL) || (pkg_entry->in_unnamed_module())) { // Ensure the index is within the -cp range before assigning // to the classpath_index. @@ -1626,7 +1624,8 @@ } else { if ((i >= 1) && (i < ClassLoaderExt::app_class_paths_start_index())) { - // The class must be from -Xbootclasspath/a + // The class must be from boot loader append path which consists of + // -Xbootclasspath/a and jvmti appended entries. assert(loader == NULL, "sanity"); classpath_index = i; break; @@ -1758,9 +1757,9 @@ } } -void ClassLoader::initialize_module_path() { +void ClassLoader::initialize_module_path(TRAPS) { if (DumpSharedSpaces) { - ClassLoaderExt::setup_module_paths(); + ClassLoaderExt::setup_module_paths(THREAD); FileMapInfo::allocate_shared_path_table(); } } --- old/src/hotspot/share/classfile/classLoader.hpp 2018-04-09 15:29:53.343590693 -0700 +++ new/src/hotspot/share/classfile/classLoader.hpp 2018-04-09 15:29:53.083566169 -0700 @@ -241,7 +241,7 @@ CDS_ONLY(static ClassPathEntry* _module_path_entries;) CDS_ONLY(static ClassPathEntry* _last_module_path_entry;) CDS_ONLY(static void setup_app_search_path(const char* class_path);) - CDS_ONLY(static void setup_module_search_path(const char* path);) + CDS_ONLY(static void setup_module_search_path(const char* path, TRAPS);) static void add_to_app_classpath_entries(const char* path, ClassPathEntry* entry, bool check_for_duplicates); @@ -292,8 +292,7 @@ bool check_for_duplicates, bool is_boot_append, bool throw_exception=true); - CDS_ONLY(static void update_module_path_entry_list(const char *path, - bool throw_exception=true);) + CDS_ONLY(static void update_module_path_entry_list(const char *path, TRAPS);) static void print_bootclasspath(); // Timing @@ -390,7 +389,7 @@ static void initialize(); static void classLoader_init2(TRAPS); CDS_ONLY(static void initialize_shared_path();) - CDS_ONLY(static void initialize_module_path();) + CDS_ONLY(static void initialize_module_path(TRAPS);) static int compute_Object_vtable(); @@ -432,7 +431,7 @@ static void* get_module_paths_misc_info(); static void exit_with_path_failure(const char* error, const char* message); static char* skip_uri_protocol(char* source); - static void record_result(InstanceKlass* ik, const ClassFileStream* stream); + static void record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS); #endif static JImageLocationRef jimage_find_resource(JImageFile* jf, const char* module_name, const char* file_name, jlong &size); --- old/src/hotspot/share/classfile/classLoaderExt.cpp 2018-04-09 15:29:54.042656626 -0700 +++ new/src/hotspot/share/classfile/classLoaderExt.cpp 2018-04-09 15:29:53.779631819 -0700 @@ -71,7 +71,7 @@ } } -void ClassLoaderExt::process_module_table(ModuleEntryTable* met) { +void ClassLoaderExt::process_module_table(ModuleEntryTable* met, TRAPS) { ResourceMark rm; for (int i = 0; i < met->table_size(); i++) { for (ModuleEntry* m = met->bucket(i); m != NULL;) { @@ -79,20 +79,19 @@ if (strncmp(path, "file:", 5) == 0 && ClassLoader::string_ends_with(path, ".jar")) { m->print(); path = ClassLoader::skip_uri_protocol(path); - ClassLoader::setup_module_search_path(path); + ClassLoader::setup_module_search_path(path, THREAD); } m = m->next(); } } } -void ClassLoaderExt::setup_module_search_path() { +void ClassLoaderExt::setup_module_search_path(TRAPS) { assert(DumpSharedSpaces, "this function is only used with -Xshare:dump and -XX:+UseAppCDS"); _app_module_paths_start_index = ClassLoader::num_boot_classpath_entries() + ClassLoader::num_app_classpath_entries(); - Thread* thread = Thread::current(); - Handle system_class_loader (thread, SystemDictionary::java_system_loader()); + Handle system_class_loader (THREAD, SystemDictionary::java_system_loader()); ModuleEntryTable* met = Modules::get_module_entry_table(system_class_loader); - process_module_table(met); + process_module_table(met, THREAD); } char* ClassLoaderExt::read_manifest(ClassPathEntry* entry, jint *manifest_size, bool clean_text, TRAPS) { @@ -222,9 +221,9 @@ } } -void ClassLoaderExt::setup_module_paths() { +void ClassLoaderExt::setup_module_paths(TRAPS) { if (UseAppCDS) { - ClassLoaderExt::setup_module_search_path(); + ClassLoaderExt::setup_module_search_path(THREAD); } } --- old/src/hotspot/share/classfile/classLoaderExt.hpp 2018-04-09 15:29:54.744722841 -0700 +++ new/src/hotspot/share/classfile/classLoaderExt.hpp 2018-04-09 15:29:54.475697468 -0700 @@ -94,8 +94,8 @@ #if INCLUDE_CDS static char* get_class_path_attr(const char* jar_path, char* manifest, jint manifest_size); static void setup_app_search_path(); // Only when -Xshare:dump - static void process_module_table(ModuleEntryTable* met); - static void setup_module_search_path(); + static void process_module_table(ModuleEntryTable* met, TRAPS); + static void setup_module_search_path(TRAPS); static SharedPathsMiscInfoExt* shared_paths_misc_info() { return (SharedPathsMiscInfoExt*)_shared_paths_misc_info; } @@ -123,7 +123,7 @@ } static void setup_search_paths() NOT_CDS_RETURN; - static void setup_module_paths() NOT_CDS_RETURN; + static void setup_module_paths(TRAPS) NOT_CDS_RETURN; #if INCLUDE_CDS private: --- old/src/hotspot/share/classfile/klassFactory.cpp 2018-04-09 15:29:55.443788773 -0700 +++ new/src/hotspot/share/classfile/klassFactory.cpp 2018-04-09 15:29:55.176763589 -0700 @@ -232,7 +232,7 @@ #if INCLUDE_CDS if (DumpSharedSpaces) { - ClassLoader::record_result(result, stream); + ClassLoader::record_result(result, stream, THREAD); #if INCLUDE_JVMTI assert(cached_class_file == NULL, "Sanity"); // Archive the class stream data into the optional data section --- old/src/hotspot/share/runtime/thread.cpp 2018-04-09 15:29:56.147855177 -0700 +++ new/src/hotspot/share/runtime/thread.cpp 2018-04-09 15:29:55.875829521 -0700 @@ -3893,7 +3893,7 @@ if (DumpSharedSpaces) { // capture the module path info from the ModuleEntryTable - ClassLoader::initialize_module_path(); + ClassLoader::initialize_module_path(THREAD); } #if INCLUDE_JVMCI