34 #include "classfile/modules.hpp" |
34 #include "classfile/modules.hpp" |
35 #include "classfile/packageEntry.hpp" |
35 #include "classfile/packageEntry.hpp" |
36 #include "classfile/klassFactory.hpp" |
36 #include "classfile/klassFactory.hpp" |
37 #include "classfile/symbolTable.hpp" |
37 #include "classfile/symbolTable.hpp" |
38 #include "classfile/systemDictionary.hpp" |
38 #include "classfile/systemDictionary.hpp" |
|
39 #include "classfile/systemDictionaryShared.hpp" |
39 #include "classfile/vmSymbols.hpp" |
40 #include "classfile/vmSymbols.hpp" |
40 #include "compiler/compileBroker.hpp" |
41 #include "compiler/compileBroker.hpp" |
41 #include "interpreter/bytecodeStream.hpp" |
42 #include "interpreter/bytecodeStream.hpp" |
42 #include "interpreter/oopMapCache.hpp" |
43 #include "interpreter/oopMapCache.hpp" |
43 #include "logging/log.hpp" |
44 #include "logging/log.hpp" |
466 return true; |
467 return true; |
467 } |
468 } |
468 |
469 |
469 #if INCLUDE_CDS |
470 #if INCLUDE_CDS |
470 void ClassLoader::exit_with_path_failure(const char* error, const char* message) { |
471 void ClassLoader::exit_with_path_failure(const char* error, const char* message) { |
471 assert(DumpSharedSpaces, "only called at dump time"); |
472 assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "only called at dump time"); |
472 tty->print_cr("Hint: enable -Xlog:class+path=info to diagnose the failure"); |
473 tty->print_cr("Hint: enable -Xlog:class+path=info to diagnose the failure"); |
473 vm_exit_during_initialization(error, message); |
474 vm_exit_during_initialization(error, message); |
474 } |
475 } |
475 #endif |
476 #endif |
476 |
477 |
532 // the same as the bootcp of the shared archive. |
533 // the same as the bootcp of the shared archive. |
533 } else { |
534 } else { |
534 trace_class_path("bootstrap loader class path=", sys_class_path); |
535 trace_class_path("bootstrap loader class path=", sys_class_path); |
535 } |
536 } |
536 #if INCLUDE_CDS |
537 #if INCLUDE_CDS |
537 if (DumpSharedSpaces) { |
538 if (DumpSharedSpaces || DynamicDumpSharedSpaces) { |
538 _shared_paths_misc_info->add_boot_classpath(sys_class_path); |
539 _shared_paths_misc_info->add_boot_classpath(sys_class_path); |
539 } |
540 } |
540 #endif |
541 #endif |
541 setup_boot_search_path(sys_class_path); |
542 setup_boot_search_path(sys_class_path); |
542 } |
543 } |
548 |
549 |
549 void* ClassLoader::get_shared_paths_misc_info() { |
550 void* ClassLoader::get_shared_paths_misc_info() { |
550 return _shared_paths_misc_info->buffer(); |
551 return _shared_paths_misc_info->buffer(); |
551 } |
552 } |
552 |
553 |
553 bool ClassLoader::check_shared_paths_misc_info(void *buf, int size) { |
554 bool ClassLoader::check_shared_paths_misc_info(void *buf, int size, bool is_static) { |
554 SharedPathsMiscInfo* checker = new SharedPathsMiscInfo((char*)buf, size); |
555 SharedPathsMiscInfo* checker = new SharedPathsMiscInfo((char*)buf, size); |
555 bool result = checker->check(); |
556 bool result = checker->check(is_static); |
556 delete checker; |
557 delete checker; |
557 return result; |
558 return result; |
558 } |
559 } |
559 |
560 |
560 void ClassLoader::setup_app_search_path(const char *class_path) { |
561 void ClassLoader::setup_app_search_path(const char *class_path) { |
561 |
562 |
562 assert(DumpSharedSpaces, "Sanity"); |
563 assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "Sanity"); |
563 |
564 |
564 Thread* THREAD = Thread::current(); |
565 Thread* THREAD = Thread::current(); |
565 int len = (int)strlen(class_path); |
566 int len = (int)strlen(class_path); |
566 int end = 0; |
567 int end = 0; |
567 |
568 |
585 } |
586 } |
586 |
587 |
587 void ClassLoader::add_to_module_path_entries(const char* path, |
588 void ClassLoader::add_to_module_path_entries(const char* path, |
588 ClassPathEntry* entry) { |
589 ClassPathEntry* entry) { |
589 assert(entry != NULL, "ClassPathEntry should not be NULL"); |
590 assert(entry != NULL, "ClassPathEntry should not be NULL"); |
590 assert(DumpSharedSpaces, "dump time only"); |
591 assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "dump time only"); |
591 |
592 |
592 // The entry does not exist, add to the list |
593 // The entry does not exist, add to the list |
593 if (_module_path_entries == NULL) { |
594 if (_module_path_entries == NULL) { |
594 assert(_last_module_path_entry == NULL, "Sanity"); |
595 assert(_last_module_path_entry == NULL, "Sanity"); |
595 _module_path_entries = _last_module_path_entry = entry; |
596 _module_path_entries = _last_module_path_entry = entry; |
599 } |
600 } |
600 } |
601 } |
601 |
602 |
602 // Add a module path to the _module_path_entries list. |
603 // Add a module path to the _module_path_entries list. |
603 void ClassLoader::update_module_path_entry_list(const char *path, TRAPS) { |
604 void ClassLoader::update_module_path_entry_list(const char *path, TRAPS) { |
604 assert(DumpSharedSpaces, "dump time only"); |
605 assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "dump time only"); |
605 struct stat st; |
606 struct stat st; |
606 if (os::stat(path, &st) != 0) { |
607 if (os::stat(path, &st) != 0) { |
607 tty->print_cr("os::stat error %d (%s). CDS dump aborted (path was \"%s\").", |
608 tty->print_cr("os::stat error %d (%s). CDS dump aborted (path was \"%s\").", |
608 errno, os::errno_name(errno), path); |
609 errno, os::errno_name(errno), path); |
609 vm_exit_during_initialization(); |
610 vm_exit_during_initialization(); |
707 int len = (int)strlen(class_path); |
708 int len = (int)strlen(class_path); |
708 int end = 0; |
709 int end = 0; |
709 bool set_base_piece = true; |
710 bool set_base_piece = true; |
710 |
711 |
711 #if INCLUDE_CDS |
712 #if INCLUDE_CDS |
712 if (DumpSharedSpaces) { |
713 if (DumpSharedSpaces || DynamicDumpSharedSpaces) { |
713 if (!Arguments::has_jimage()) { |
714 if (!Arguments::has_jimage()) { |
714 vm_exit_during_initialization("CDS is not supported in exploded JDK build", NULL); |
715 vm_exit_during_initialization("CDS is not supported in exploded JDK build", NULL); |
715 } |
716 } |
716 } |
717 } |
717 #endif |
718 #endif |
1332 // At CDS dump time, the --patch-module entries are ignored. That means a |
1333 // At CDS dump time, the --patch-module entries are ignored. That means a |
1333 // class is still loaded from the runtime image even if it might |
1334 // class is still loaded from the runtime image even if it might |
1334 // appear in the _patch_mod_entries. The runtime shared class visibility |
1335 // appear in the _patch_mod_entries. The runtime shared class visibility |
1335 // check will determine if a shared class is visible based on the runtime |
1336 // check will determine if a shared class is visible based on the runtime |
1336 // environemnt, including the runtime --patch-module setting. |
1337 // environemnt, including the runtime --patch-module setting. |
|
1338 // |
|
1339 // DynamicDumpSharedSpaces requires UseSharedSpaces to be enabled. Since --patch-module |
|
1340 // is not supported with UseSharedSpaces, it is not supported with DynamicDumpSharedSpaces. |
|
1341 assert(!DynamicDumpSharedSpaces, "sanity"); |
1337 if (!DumpSharedSpaces) { |
1342 if (!DumpSharedSpaces) { |
1338 stream = search_module_entries(_patch_mod_entries, class_name, file_name, CHECK_NULL); |
1343 stream = search_module_entries(_patch_mod_entries, class_name, file_name, CHECK_NULL); |
1339 } |
1344 } |
1340 } |
1345 } |
1341 |
1346 |
1421 } |
1426 } |
1422 |
1427 |
1423 // Record the shared classpath index and loader type for classes loaded |
1428 // Record the shared classpath index and loader type for classes loaded |
1424 // by the builtin loaders at dump time. |
1429 // by the builtin loaders at dump time. |
1425 void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS) { |
1430 void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS) { |
1426 assert(DumpSharedSpaces, "sanity"); |
1431 assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "sanity"); |
1427 assert(stream != NULL, "sanity"); |
1432 assert(stream != NULL, "sanity"); |
1428 |
1433 |
1429 if (ik->is_unsafe_anonymous()) { |
1434 if (ik->is_unsafe_anonymous()) { |
1430 // We do not archive unsafe anonymous classes. |
1435 // We do not archive unsafe anonymous classes. |
1431 return; |
1436 return; |
1511 |
1516 |
1512 // No path entry found for this class. Must be a shared class loaded by the |
1517 // No path entry found for this class. Must be a shared class loaded by the |
1513 // user defined classloader. |
1518 // user defined classloader. |
1514 if (classpath_index < 0) { |
1519 if (classpath_index < 0) { |
1515 assert(ik->shared_classpath_index() < 0, "Sanity"); |
1520 assert(ik->shared_classpath_index() < 0, "Sanity"); |
|
1521 ik->set_shared_classpath_index(UNREGISTERED_INDEX); |
|
1522 SystemDictionaryShared::set_shared_class_misc_info(ik, (ClassFileStream*)stream); |
1516 return; |
1523 return; |
1517 } |
1524 } |
1518 } else { |
1525 } else { |
1519 // The shared path table is set up after module system initialization. |
1526 // The shared path table is set up after module system initialization. |
1520 // The path table contains no entry before that. Any classes loaded prior |
1527 // The path table contains no entry before that. Any classes loaded prior |
1593 load_zip_library(); |
1600 load_zip_library(); |
1594 // lookup jimage library entry points |
1601 // lookup jimage library entry points |
1595 load_jimage_library(); |
1602 load_jimage_library(); |
1596 #if INCLUDE_CDS |
1603 #if INCLUDE_CDS |
1597 // initialize search path |
1604 // initialize search path |
1598 if (DumpSharedSpaces) { |
1605 if (DumpSharedSpaces || DynamicDumpSharedSpaces) { |
1599 _shared_paths_misc_info = new SharedPathsMiscInfo(); |
1606 _shared_paths_misc_info = new SharedPathsMiscInfo(); |
1600 } |
1607 } |
1601 #endif |
1608 #endif |
1602 setup_bootstrap_search_path(); |
1609 setup_bootstrap_search_path(); |
1603 } |
1610 } |
1604 |
1611 |
1605 #if INCLUDE_CDS |
1612 #if INCLUDE_CDS |
1606 void ClassLoader::initialize_shared_path() { |
1613 void ClassLoader::initialize_shared_path() { |
1607 if (DumpSharedSpaces) { |
1614 if (DumpSharedSpaces || DynamicDumpSharedSpaces) { |
1608 ClassLoaderExt::setup_search_paths(); |
1615 ClassLoaderExt::setup_search_paths(); |
1609 _shared_paths_misc_info->write_jint(0); // see comments in SharedPathsMiscInfo::check() |
1616 _shared_paths_misc_info->write_jint(0); // see comments in SharedPathsMiscInfo::check() |
1610 } |
1617 } |
1611 } |
1618 } |
1612 |
1619 |
1613 void ClassLoader::initialize_module_path(TRAPS) { |
1620 void ClassLoader::initialize_module_path(TRAPS) { |
1614 if (DumpSharedSpaces) { |
1621 if (DumpSharedSpaces || DynamicDumpSharedSpaces) { |
1615 ClassLoaderExt::setup_module_paths(THREAD); |
1622 ClassLoaderExt::setup_module_paths(THREAD); |
1616 FileMapInfo::allocate_shared_path_table(); |
1623 FileMapInfo::allocate_shared_path_table(); |
1617 } |
1624 } |
1618 } |
1625 } |
1619 #endif |
1626 #endif |
1675 // Setup the initial java.base/path pair for the exploded build entries. |
1682 // Setup the initial java.base/path pair for the exploded build entries. |
1676 // As more modules are defined during module system initialization, more |
1683 // As more modules are defined during module system initialization, more |
1677 // entries will be added to the exploded build array. |
1684 // entries will be added to the exploded build array. |
1678 if (!has_jrt_entry()) { |
1685 if (!has_jrt_entry()) { |
1679 assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with exploded module builds"); |
1686 assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with exploded module builds"); |
|
1687 assert(!DynamicDumpSharedSpaces, "DynamicDumpSharedSpaces not supported with exploded module builds"); |
1680 assert(!UseSharedSpaces, "UsedSharedSpaces not supported with exploded module builds"); |
1688 assert(!UseSharedSpaces, "UsedSharedSpaces not supported with exploded module builds"); |
1681 // Set up the boot loader's _exploded_entries list. Note that this gets |
1689 // Set up the boot loader's _exploded_entries list. Note that this gets |
1682 // done before loading any classes, by the same thread that will |
1690 // done before loading any classes, by the same thread that will |
1683 // subsequently do the first class load. So, no lock is needed for this. |
1691 // subsequently do the first class load. So, no lock is needed for this. |
1684 assert(_exploded_entries == NULL, "Should only get initialized once"); |
1692 assert(_exploded_entries == NULL, "Should only get initialized once"); |