< prev index next >

src/hotspot/share/oops/instanceKlass.cpp

Print this page




2694   for (int hash_index = 0; hash_index < hash_len; ) {
2695     dest[dest_index++] = hash_buf[hash_index++];
2696   }
2697 
2698   // Add the semicolon and the NULL
2699   dest[dest_index++] = JVM_SIGNATURE_ENDCLASS;
2700   dest[dest_index] = '\0';
2701   return dest;
2702 }
2703 
2704 ModuleEntry* InstanceKlass::module() const {
2705   // For an unsafe anonymous class return the host class' module
2706   if (is_unsafe_anonymous()) {
2707     assert(unsafe_anonymous_host() != NULL, "unsafe anonymous class must have a host class");
2708     return unsafe_anonymous_host()->module();
2709   }
2710 
2711   if (is_hidden() &&
2712       in_unnamed_package() &&
2713       class_loader_data()->has_class_mirror_holder()) {
2714     // For a weak hidden class defined to an unnamed package,
2715     // its (class held) CLD will not have an unnamed module created for it.
2716     // Two choices to find the correct ModuleEntry:
2717     // 1. If hidden class is within a nest, use nest host's module
2718     // 2. Find the unnamed module off from the class loader
2719     // For now option #2 is used since a nest host is not set until
2720     // after the instance class is created in jvm_lookup_define_class().
2721     if (class_loader_data()->is_boot_class_loader_data()) {
2722       return ClassLoaderData::the_null_class_loader_data()->unnamed_module();
2723     } else {
2724       oop module = java_lang_ClassLoader::unnamedModule(class_loader_data()->class_loader());
2725       assert(java_lang_Module::is_instance(module), "Not an instance of java.lang.Module");
2726       return java_lang_Module::module_entry(module);
2727     }
2728   }
2729 
2730   // Class is in a named package
2731   if (!in_unnamed_package()) {
2732     return _package_entry->module();
2733   }
2734 




2694   for (int hash_index = 0; hash_index < hash_len; ) {
2695     dest[dest_index++] = hash_buf[hash_index++];
2696   }
2697 
2698   // Add the semicolon and the NULL
2699   dest[dest_index++] = JVM_SIGNATURE_ENDCLASS;
2700   dest[dest_index] = '\0';
2701   return dest;
2702 }
2703 
2704 ModuleEntry* InstanceKlass::module() const {
2705   // For an unsafe anonymous class return the host class' module
2706   if (is_unsafe_anonymous()) {
2707     assert(unsafe_anonymous_host() != NULL, "unsafe anonymous class must have a host class");
2708     return unsafe_anonymous_host()->module();
2709   }
2710 
2711   if (is_hidden() &&
2712       in_unnamed_package() &&
2713       class_loader_data()->has_class_mirror_holder()) {
2714     // For a non-strong hidden class defined to an unnamed package,
2715     // its (class held) CLD will not have an unnamed module created for it.
2716     // Two choices to find the correct ModuleEntry:
2717     // 1. If hidden class is within a nest, use nest host's module
2718     // 2. Find the unnamed module off from the class loader
2719     // For now option #2 is used since a nest host is not set until
2720     // after the instance class is created in jvm_lookup_define_class().
2721     if (class_loader_data()->is_boot_class_loader_data()) {
2722       return ClassLoaderData::the_null_class_loader_data()->unnamed_module();
2723     } else {
2724       oop module = java_lang_ClassLoader::unnamedModule(class_loader_data()->class_loader());
2725       assert(java_lang_Module::is_instance(module), "Not an instance of java.lang.Module");
2726       return java_lang_Module::module_entry(module);
2727     }
2728   }
2729 
2730   // Class is in a named package
2731   if (!in_unnamed_package()) {
2732     return _package_entry->module();
2733   }
2734 


< prev index next >