< prev index next >

src/hotspot/share/classfile/systemDictionaryShared.cpp

Print this page




  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/classFileStream.hpp"
  27 #include "classfile/classListParser.hpp"
  28 #include "classfile/classLoader.hpp"
  29 #include "classfile/classLoaderData.inline.hpp"
  30 #include "classfile/classLoaderDataGraph.hpp"
  31 #include "classfile/classLoaderExt.hpp"
  32 #include "classfile/dictionary.hpp"
  33 #include "classfile/javaClasses.hpp"
  34 #include "classfile/symbolTable.hpp"
  35 #include "classfile/systemDictionary.hpp"
  36 #include "classfile/systemDictionaryShared.hpp"
  37 #include "classfile/verificationType.hpp"
  38 #include "classfile/vmSymbols.hpp"

  39 #include "logging/log.hpp"
  40 #include "memory/allocation.hpp"
  41 #include "memory/archiveUtils.hpp"
  42 #include "memory/dynamicArchive.hpp"
  43 #include "memory/filemap.hpp"
  44 #include "memory/heapShared.hpp"
  45 #include "memory/metadataFactory.hpp"
  46 #include "memory/metaspaceClosure.hpp"
  47 #include "memory/oopFactory.hpp"
  48 #include "memory/resourceArea.hpp"
  49 #include "memory/universe.hpp"
  50 #include "oops/instanceKlass.hpp"
  51 #include "oops/klass.inline.hpp"
  52 #include "oops/objArrayOop.inline.hpp"
  53 #include "oops/oop.inline.hpp"
  54 #include "oops/typeArrayOop.inline.hpp"
  55 #include "runtime/handles.inline.hpp"
  56 #include "runtime/java.hpp"
  57 #include "runtime/javaCalls.hpp"
  58 #include "runtime/mutexLocker.hpp"


1650         ResourceMark rm;
1651         log_debug(cds)("Loaded lambda proxy: %s", proxy_klass->external_name());
1652       }
1653     } else {
1654       if (log_is_enabled(Debug, cds)) {
1655         ResourceMark rm;
1656         log_debug(cds)("Used all archived lambda proxy classes for: %s %s%s",
1657                        caller_ik->external_name(), invoked_name->as_C_string(), invoked_type->as_C_string());
1658       }
1659     }
1660   }
1661   return proxy_klass;
1662 }
1663 
1664 InstanceKlass* SystemDictionaryShared::get_shared_nest_host(InstanceKlass* lambda_ik) {
1665   assert(!DumpSharedSpaces && UseSharedSpaces, "called at run time with CDS enabled only");
1666   RunTimeSharedClassInfo* record = RunTimeSharedClassInfo::get_for(lambda_ik);
1667   return record->nest_host();
1668 }
1669 
1670 InstanceKlass* SystemDictionaryShared::load_shared_lambda_proxy_class(InstanceKlass* lambda_ik,
1671                                                                       InstanceKlass* caller_ik,
1672                                                                       bool initialize, TRAPS) {
1673   Handle class_loader(THREAD, caller_ik->class_loader());
1674   Handle protection_domain;
1675   PackageEntry* pkg_entry = get_package_entry_from_class_name(class_loader, caller_ik->name());
1676   if (caller_ik->class_loader() != NULL) {
1677     protection_domain = SystemDictionaryShared::init_security_info(class_loader, caller_ik, pkg_entry, CHECK_NULL);
1678   }
1679 
1680   InstanceKlass* shared_nest_host = get_shared_nest_host(lambda_ik);
1681   assert(shared_nest_host != NULL, "unexpected NULL _nest_host");
1682 
1683   InstanceKlass* loaded_lambda =
1684     SystemDictionary::load_shared_lambda_proxy_class(lambda_ik, class_loader, protection_domain, pkg_entry, initialize, CHECK_NULL);
1685 
1686   InstanceKlass* nest_host = caller_ik->nest_host(THREAD);
1687   // The following ensures that the caller's nest host is the same as the lambda proxy's
1688   // nest host recorded at dump time.
1689   assert(nest_host->has_nest_member(caller_ik, THREAD) ||
1690          nest_host == caller_ik, "caller_ik failed nest member check");
1691   assert(nest_host == shared_nest_host, "mismatched nest host");























1692 
1693   return loaded_lambda;
1694 }
1695 
1696 static char get_loader_type_by(oop  loader) {
1697   assert(SystemDictionary::is_builtin_class_loader(loader), "Must be built-in loader");
1698   if (SystemDictionary::is_boot_class_loader(loader)) {
1699     return (char)ClassLoader::BOOT_LOADER;
1700   } else if (SystemDictionary::is_platform_class_loader(loader)) {
1701     return (char)ClassLoader::PLATFORM_LOADER;
1702   } else {
1703     assert(SystemDictionary::is_system_class_loader(loader), "Class loader mismatch");
1704     return (char)ClassLoader::APP_LOADER;
1705   }
1706 }
1707 
1708 static oop get_class_loader_by(char type) {
1709   if (type == (char)ClassLoader::BOOT_LOADER) {
1710     return (oop)NULL;
1711   } else if (type == (char)ClassLoader::PLATFORM_LOADER) {




  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/classFileStream.hpp"
  27 #include "classfile/classListParser.hpp"
  28 #include "classfile/classLoader.hpp"
  29 #include "classfile/classLoaderData.inline.hpp"
  30 #include "classfile/classLoaderDataGraph.hpp"
  31 #include "classfile/classLoaderExt.hpp"
  32 #include "classfile/dictionary.hpp"
  33 #include "classfile/javaClasses.hpp"
  34 #include "classfile/symbolTable.hpp"
  35 #include "classfile/systemDictionary.hpp"
  36 #include "classfile/systemDictionaryShared.hpp"
  37 #include "classfile/verificationType.hpp"
  38 #include "classfile/vmSymbols.hpp"
  39 #include "jfr/jfrEvents.hpp"
  40 #include "logging/log.hpp"
  41 #include "memory/allocation.hpp"
  42 #include "memory/archiveUtils.hpp"
  43 #include "memory/dynamicArchive.hpp"
  44 #include "memory/filemap.hpp"
  45 #include "memory/heapShared.hpp"
  46 #include "memory/metadataFactory.hpp"
  47 #include "memory/metaspaceClosure.hpp"
  48 #include "memory/oopFactory.hpp"
  49 #include "memory/resourceArea.hpp"
  50 #include "memory/universe.hpp"
  51 #include "oops/instanceKlass.hpp"
  52 #include "oops/klass.inline.hpp"
  53 #include "oops/objArrayOop.inline.hpp"
  54 #include "oops/oop.inline.hpp"
  55 #include "oops/typeArrayOop.inline.hpp"
  56 #include "runtime/handles.inline.hpp"
  57 #include "runtime/java.hpp"
  58 #include "runtime/javaCalls.hpp"
  59 #include "runtime/mutexLocker.hpp"


1651         ResourceMark rm;
1652         log_debug(cds)("Loaded lambda proxy: %s", proxy_klass->external_name());
1653       }
1654     } else {
1655       if (log_is_enabled(Debug, cds)) {
1656         ResourceMark rm;
1657         log_debug(cds)("Used all archived lambda proxy classes for: %s %s%s",
1658                        caller_ik->external_name(), invoked_name->as_C_string(), invoked_type->as_C_string());
1659       }
1660     }
1661   }
1662   return proxy_klass;
1663 }
1664 
1665 InstanceKlass* SystemDictionaryShared::get_shared_nest_host(InstanceKlass* lambda_ik) {
1666   assert(!DumpSharedSpaces && UseSharedSpaces, "called at run time with CDS enabled only");
1667   RunTimeSharedClassInfo* record = RunTimeSharedClassInfo::get_for(lambda_ik);
1668   return record->nest_host();
1669 }
1670 
1671 InstanceKlass* SystemDictionaryShared::prepare_shared_lambda_proxy_class(InstanceKlass* lambda_ik,
1672                                                                          InstanceKlass* caller_ik,
1673                                                                          bool initialize, TRAPS) {
1674   Handle class_loader(THREAD, caller_ik->class_loader());
1675   Handle protection_domain;
1676   PackageEntry* pkg_entry = get_package_entry_from_class_name(class_loader, caller_ik->name());
1677   if (caller_ik->class_loader() != NULL) {
1678     protection_domain = SystemDictionaryShared::init_security_info(class_loader, caller_ik, pkg_entry, CHECK_NULL);
1679   }
1680 
1681   InstanceKlass* shared_nest_host = get_shared_nest_host(lambda_ik);
1682   assert(shared_nest_host != NULL, "unexpected NULL _nest_host");
1683 
1684   InstanceKlass* loaded_lambda =
1685     SystemDictionary::load_shared_lambda_proxy_class(lambda_ik, class_loader, protection_domain, pkg_entry, CHECK_NULL);
1686 
1687   // Ensures the nest host is the same as the lambda proxy's

1688   // nest host recorded at dump time.
1689   InstanceKlass* nest_host = caller_ik->nest_host(THREAD);

1690   assert(nest_host == shared_nest_host, "mismatched nest host");
1691 
1692   EventClassLoad class_load_start_event;
1693   {
1694     MutexLocker mu_r(THREAD, Compile_lock);
1695 
1696     // Add to class hierarchy, initialize vtables, and do possible
1697     // deoptimizations.
1698     SystemDictionary::add_to_hierarchy(loaded_lambda, CHECK_NULL); // No exception, but can block
1699     // But, do not add to dictionary.
1700   }
1701   loaded_lambda->link_class(CHECK_NULL);
1702   // notify jvmti
1703   if (JvmtiExport::should_post_class_load()) {
1704       assert(THREAD->is_Java_thread(), "thread->is_Java_thread()");
1705       JvmtiExport::post_class_load((JavaThread *) THREAD, loaded_lambda);
1706   }
1707   if (class_load_start_event.should_commit()) {
1708     SystemDictionary::post_class_load_event(&class_load_start_event, loaded_lambda, ClassLoaderData::class_loader_data(class_loader()));
1709   }
1710 
1711   if (initialize) {
1712     loaded_lambda->initialize(CHECK_NULL);
1713   }
1714 
1715   return loaded_lambda;
1716 }
1717 
1718 static char get_loader_type_by(oop  loader) {
1719   assert(SystemDictionary::is_builtin_class_loader(loader), "Must be built-in loader");
1720   if (SystemDictionary::is_boot_class_loader(loader)) {
1721     return (char)ClassLoader::BOOT_LOADER;
1722   } else if (SystemDictionary::is_platform_class_loader(loader)) {
1723     return (char)ClassLoader::PLATFORM_LOADER;
1724   } else {
1725     assert(SystemDictionary::is_system_class_loader(loader), "Class loader mismatch");
1726     return (char)ClassLoader::APP_LOADER;
1727   }
1728 }
1729 
1730 static oop get_class_loader_by(char type) {
1731   if (type == (char)ClassLoader::BOOT_LOADER) {
1732     return (oop)NULL;
1733   } else if (type == (char)ClassLoader::PLATFORM_LOADER) {


< prev index next >