28 #include "classfile/classListParser.hpp" |
28 #include "classfile/classListParser.hpp" |
29 #include "classfile/classLoader.inline.hpp" |
29 #include "classfile/classLoader.inline.hpp" |
30 #include "classfile/classLoaderExt.hpp" |
30 #include "classfile/classLoaderExt.hpp" |
31 #include "classfile/classLoaderData.inline.hpp" |
31 #include "classfile/classLoaderData.inline.hpp" |
32 #include "classfile/klassFactory.hpp" |
32 #include "classfile/klassFactory.hpp" |
|
33 #include "classfile/modules.hpp" |
33 #include "classfile/sharedClassUtil.hpp" |
34 #include "classfile/sharedClassUtil.hpp" |
34 #include "classfile/sharedPathsMiscInfo.hpp" |
35 #include "classfile/sharedPathsMiscInfo.hpp" |
35 #include "classfile/systemDictionaryShared.hpp" |
36 #include "classfile/systemDictionaryShared.hpp" |
36 #include "classfile/vmSymbols.hpp" |
37 #include "classfile/vmSymbols.hpp" |
37 #include "memory/allocation.inline.hpp" |
38 #include "memory/allocation.inline.hpp" |
39 #include "memory/resourceArea.hpp" |
40 #include "memory/resourceArea.hpp" |
40 #include "oops/instanceKlass.hpp" |
41 #include "oops/instanceKlass.hpp" |
41 #include "oops/oop.inline.hpp" |
42 #include "oops/oop.inline.hpp" |
42 #include "oops/symbol.hpp" |
43 #include "oops/symbol.hpp" |
43 #include "runtime/arguments.hpp" |
44 #include "runtime/arguments.hpp" |
|
45 #include "runtime/handles.inline.hpp" |
44 #include "runtime/java.hpp" |
46 #include "runtime/java.hpp" |
45 #include "runtime/javaCalls.hpp" |
47 #include "runtime/javaCalls.hpp" |
46 #include "runtime/os.hpp" |
48 #include "runtime/os.hpp" |
47 #include "services/threadService.hpp" |
49 #include "services/threadService.hpp" |
48 #include "utilities/stringUtils.hpp" |
50 #include "utilities/stringUtils.hpp" |
49 |
51 |
50 jshort ClassLoaderExt::_app_paths_start_index = ClassLoaderExt::max_classpath_index; |
52 jshort ClassLoaderExt::_app_class_paths_start_index = ClassLoaderExt::max_classpath_index; |
|
53 jshort ClassLoaderExt::_app_module_paths_start_index = ClassLoaderExt::max_classpath_index; |
51 bool ClassLoaderExt::_has_app_classes = false; |
54 bool ClassLoaderExt::_has_app_classes = false; |
52 bool ClassLoaderExt::_has_platform_classes = false; |
55 bool ClassLoaderExt::_has_platform_classes = false; |
53 |
56 |
54 void ClassLoaderExt::setup_app_search_path() { |
57 void ClassLoaderExt::setup_app_search_path() { |
55 assert(DumpSharedSpaces, "this function is only used with -Xshare:dump and -XX:+UseAppCDS"); |
58 assert(DumpSharedSpaces, "this function is only used with -Xshare:dump and -XX:+UseAppCDS"); |
56 _app_paths_start_index = ClassLoader::num_boot_classpath_entries(); |
59 _app_class_paths_start_index = ClassLoader::num_boot_classpath_entries(); |
57 char* app_class_path = os::strdup(Arguments::get_appclasspath()); |
60 char* app_class_path = os::strdup(Arguments::get_appclasspath()); |
58 |
61 |
59 if (strcmp(app_class_path, ".") == 0) { |
62 if (strcmp(app_class_path, ".") == 0) { |
60 // This doesn't make any sense, even for AppCDS, so let's skip it. We |
63 // This doesn't make any sense, even for AppCDS, so let's skip it. We |
61 // don't want to throw an error here because -cp "." is usually assigned |
64 // don't want to throw an error here because -cp "." is usually assigned |
66 shared_paths_misc_info()->add_app_classpath(app_class_path); |
69 shared_paths_misc_info()->add_app_classpath(app_class_path); |
67 ClassLoader::setup_app_search_path(app_class_path); |
70 ClassLoader::setup_app_search_path(app_class_path); |
68 } |
71 } |
69 } |
72 } |
70 |
73 |
|
74 void ClassLoaderExt::process_module_table(ModuleEntryTable* met, TRAPS) { |
|
75 ResourceMark rm; |
|
76 for (int i = 0; i < met->table_size(); i++) { |
|
77 for (ModuleEntry* m = met->bucket(i); m != NULL;) { |
|
78 char* path = m->location()->as_C_string(); |
|
79 if (strncmp(path, "file:", 5) == 0 && ClassLoader::string_ends_with(path, ".jar")) { |
|
80 m->print(); |
|
81 path = ClassLoader::skip_uri_protocol(path); |
|
82 ClassLoader::setup_module_search_path(path, THREAD); |
|
83 } |
|
84 m = m->next(); |
|
85 } |
|
86 } |
|
87 } |
|
88 void ClassLoaderExt::setup_module_search_path(TRAPS) { |
|
89 assert(DumpSharedSpaces, "this function is only used with -Xshare:dump and -XX:+UseAppCDS"); |
|
90 _app_module_paths_start_index = ClassLoader::num_boot_classpath_entries() + |
|
91 ClassLoader::num_app_classpath_entries(); |
|
92 Handle system_class_loader (THREAD, SystemDictionary::java_system_loader()); |
|
93 ModuleEntryTable* met = Modules::get_module_entry_table(system_class_loader); |
|
94 process_module_table(met, THREAD); |
|
95 } |
|
96 |
71 char* ClassLoaderExt::read_manifest(ClassPathEntry* entry, jint *manifest_size, bool clean_text, TRAPS) { |
97 char* ClassLoaderExt::read_manifest(ClassPathEntry* entry, jint *manifest_size, bool clean_text, TRAPS) { |
72 const char* name = "META-INF/MANIFEST.MF"; |
98 const char* name = "META-INF/MANIFEST.MF"; |
73 char* manifest; |
99 char* manifest; |
74 jint size; |
100 jint size; |
75 |
101 |
193 shared_paths_misc_info()->record_app_offset(); |
219 shared_paths_misc_info()->record_app_offset(); |
194 ClassLoaderExt::setup_app_search_path(); |
220 ClassLoaderExt::setup_app_search_path(); |
195 } |
221 } |
196 } |
222 } |
197 |
223 |
|
224 void ClassLoaderExt::setup_module_paths(TRAPS) { |
|
225 if (UseAppCDS) { |
|
226 ClassLoaderExt::setup_module_search_path(THREAD); |
|
227 } |
|
228 } |
|
229 |
198 Thread* ClassLoaderExt::Context::_dump_thread = NULL; |
230 Thread* ClassLoaderExt::Context::_dump_thread = NULL; |
199 |
231 |
200 void ClassLoaderExt::record_result(ClassLoaderExt::Context *context, |
232 void ClassLoaderExt::record_result(ClassLoaderExt::Context *context, |
201 Symbol* class_name, |
233 Symbol* class_name, |
202 const s2 classpath_index, |
234 const s2 classpath_index, |