14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classFileParser.hpp"
27 #include "classfile/classFileStream.hpp"
28 #include "classfile/classListParser.hpp"
29 #include "classfile/classLoader.inline.hpp"
30 #include "classfile/classLoaderExt.hpp"
31 #include "classfile/classLoaderData.inline.hpp"
32 #include "classfile/klassFactory.hpp"
33 #include "classfile/modules.hpp"
34 #include "classfile/sharedClassUtil.hpp"
35 #include "classfile/sharedPathsMiscInfo.hpp"
36 #include "classfile/systemDictionaryShared.hpp"
37 #include "classfile/vmSymbols.hpp"
38 #include "memory/allocation.inline.hpp"
39 #include "memory/filemap.hpp"
40 #include "memory/resourceArea.hpp"
41 #include "oops/instanceKlass.hpp"
42 #include "oops/oop.inline.hpp"
43 #include "oops/symbol.hpp"
44 #include "runtime/arguments.hpp"
45 #include "runtime/handles.inline.hpp"
46 #include "runtime/java.hpp"
47 #include "runtime/javaCalls.hpp"
48 #include "runtime/os.hpp"
49 #include "services/threadService.hpp"
50 #include "utilities/stringUtils.hpp"
51
52 jshort ClassLoaderExt::_app_class_paths_start_index = ClassLoaderExt::max_classpath_index;
53 jshort ClassLoaderExt::_app_module_paths_start_index = ClassLoaderExt::max_classpath_index;
54 bool ClassLoaderExt::_has_app_classes = false;
55 bool ClassLoaderExt::_has_platform_classes = false;
56
57 void ClassLoaderExt::append_boot_classpath(ClassPathEntry* new_entry) {
58 #if INCLUDE_CDS
59 warning("Sharing is only supported for boot loader classes because bootstrap classpath has been appended");
60 FileMapHeaderExt* header = (FileMapHeaderExt*)FileMapInfo::current_info()->header();
61 header->set_has_platform_or_app_classes(false);
62 #endif
63 ClassLoader::add_to_boot_append_entries(new_entry);
64 }
65
66 void ClassLoaderExt::setup_app_search_path() {
67 assert(DumpSharedSpaces, "this function is only used with -Xshare:dump");
68 _app_class_paths_start_index = ClassLoader::num_boot_classpath_entries();
69 char* app_class_path = os::strdup(Arguments::get_appclasspath());
70
71 if (strcmp(app_class_path, ".") == 0) {
72 // This doesn't make any sense, even for AppCDS, so let's skip it. We
73 // don't want to throw an error here because -cp "." is usually assigned
74 // by the launcher when classpath is not specified.
75 trace_class_path("app loader class path (skipped)=", app_class_path);
76 } else {
77 trace_class_path("app loader class path=", app_class_path);
78 shared_paths_misc_info()->add_app_classpath(app_class_path);
79 ClassLoader::setup_app_search_path(app_class_path);
80 }
81 }
211 if (name_len > 0) {
212 ResourceMark rm(THREAD);
213 char* libname = NEW_RESOURCE_ARRAY(char, dir_len + name_len + 1);
214 *libname = 0;
215 strncat(libname, dir_name, dir_len);
216 strncat(libname, file_start, name_len);
217 trace_class_path("library = ", libname);
218 ClassLoader::update_class_path_entry_list(libname, true, false);
219 }
220
221 file_start = file_end;
222 }
223 }
224 }
225
226 void ClassLoaderExt::setup_search_paths() {
227 shared_paths_misc_info()->record_app_offset();
228 ClassLoaderExt::setup_app_search_path();
229 }
230
231 Thread* ClassLoaderExt::Context::_dump_thread = NULL;
232
233 void ClassLoaderExt::record_result(ClassLoaderExt::Context *context,
234 Symbol* class_name,
235 const s2 classpath_index,
236 InstanceKlass* result,
237 TRAPS) {
238 assert(DumpSharedSpaces, "Sanity");
239
240 // We need to remember where the class comes from during dumping.
241 oop loader = result->class_loader();
242 s2 classloader_type = ClassLoader::BOOT_LOADER;
243 if (SystemDictionary::is_system_class_loader(loader)) {
244 classloader_type = ClassLoader::APP_LOADER;
245 ClassLoaderExt::set_has_app_classes();
246 } else if (SystemDictionary::is_platform_class_loader(loader)) {
247 classloader_type = ClassLoader::PLATFORM_LOADER;
248 ClassLoaderExt::set_has_platform_classes();
249 }
250 result->set_shared_classpath_index(classpath_index);
251 result->set_class_loader_type(classloader_type);
252 }
253
254 void ClassLoaderExt::finalize_shared_paths_misc_info() {
255 if (!_has_app_classes) {
|
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classFileParser.hpp"
27 #include "classfile/classFileStream.hpp"
28 #include "classfile/classListParser.hpp"
29 #include "classfile/classLoader.inline.hpp"
30 #include "classfile/classLoaderExt.hpp"
31 #include "classfile/classLoaderData.inline.hpp"
32 #include "classfile/klassFactory.hpp"
33 #include "classfile/modules.hpp"
34 #include "classfile/sharedPathsMiscInfo.hpp"
35 #include "classfile/systemDictionaryShared.hpp"
36 #include "classfile/vmSymbols.hpp"
37 #include "memory/allocation.inline.hpp"
38 #include "memory/filemap.hpp"
39 #include "memory/resourceArea.hpp"
40 #include "oops/instanceKlass.hpp"
41 #include "oops/oop.inline.hpp"
42 #include "oops/symbol.hpp"
43 #include "runtime/arguments.hpp"
44 #include "runtime/handles.inline.hpp"
45 #include "runtime/java.hpp"
46 #include "runtime/javaCalls.hpp"
47 #include "runtime/os.hpp"
48 #include "services/threadService.hpp"
49 #include "utilities/stringUtils.hpp"
50
51 jshort ClassLoaderExt::_app_class_paths_start_index = ClassLoaderExt::max_classpath_index;
52 jshort ClassLoaderExt::_app_module_paths_start_index = ClassLoaderExt::max_classpath_index;
53 bool ClassLoaderExt::_has_app_classes = false;
54 bool ClassLoaderExt::_has_platform_classes = false;
55
56 void ClassLoaderExt::append_boot_classpath(ClassPathEntry* new_entry) {
57 #if INCLUDE_CDS
58 warning("Sharing is only supported for boot loader classes because bootstrap classpath has been appended");
59 FileMapInfo::current_info()->header()->set_has_platform_or_app_classes(false);
60 #endif
61 ClassLoader::add_to_boot_append_entries(new_entry);
62 }
63
64 void ClassLoaderExt::setup_app_search_path() {
65 assert(DumpSharedSpaces, "this function is only used with -Xshare:dump");
66 _app_class_paths_start_index = ClassLoader::num_boot_classpath_entries();
67 char* app_class_path = os::strdup(Arguments::get_appclasspath());
68
69 if (strcmp(app_class_path, ".") == 0) {
70 // This doesn't make any sense, even for AppCDS, so let's skip it. We
71 // don't want to throw an error here because -cp "." is usually assigned
72 // by the launcher when classpath is not specified.
73 trace_class_path("app loader class path (skipped)=", app_class_path);
74 } else {
75 trace_class_path("app loader class path=", app_class_path);
76 shared_paths_misc_info()->add_app_classpath(app_class_path);
77 ClassLoader::setup_app_search_path(app_class_path);
78 }
79 }
209 if (name_len > 0) {
210 ResourceMark rm(THREAD);
211 char* libname = NEW_RESOURCE_ARRAY(char, dir_len + name_len + 1);
212 *libname = 0;
213 strncat(libname, dir_name, dir_len);
214 strncat(libname, file_start, name_len);
215 trace_class_path("library = ", libname);
216 ClassLoader::update_class_path_entry_list(libname, true, false);
217 }
218
219 file_start = file_end;
220 }
221 }
222 }
223
224 void ClassLoaderExt::setup_search_paths() {
225 shared_paths_misc_info()->record_app_offset();
226 ClassLoaderExt::setup_app_search_path();
227 }
228
229 void ClassLoaderExt::record_result(const s2 classpath_index,
230 InstanceKlass* result,
231 TRAPS) {
232 assert(DumpSharedSpaces, "Sanity");
233
234 // We need to remember where the class comes from during dumping.
235 oop loader = result->class_loader();
236 s2 classloader_type = ClassLoader::BOOT_LOADER;
237 if (SystemDictionary::is_system_class_loader(loader)) {
238 classloader_type = ClassLoader::APP_LOADER;
239 ClassLoaderExt::set_has_app_classes();
240 } else if (SystemDictionary::is_platform_class_loader(loader)) {
241 classloader_type = ClassLoader::PLATFORM_LOADER;
242 ClassLoaderExt::set_has_platform_classes();
243 }
244 result->set_shared_classpath_index(classpath_index);
245 result->set_class_loader_type(classloader_type);
246 }
247
248 void ClassLoaderExt::finalize_shared_paths_misc_info() {
249 if (!_has_app_classes) {
|