< prev index next >

src/hotspot/share/oops/instanceKlass.cpp

Print this page

  28 #include "cds/cdsConfig.hpp"
  29 #include "cds/cdsEnumKlass.hpp"
  30 #include "cds/classListWriter.hpp"
  31 #include "cds/heapShared.hpp"
  32 #include "classfile/classFileParser.hpp"
  33 #include "classfile/classFileStream.hpp"
  34 #include "classfile/classLoader.hpp"
  35 #include "classfile/classLoaderData.inline.hpp"
  36 #include "classfile/javaClasses.hpp"
  37 #include "classfile/moduleEntry.hpp"
  38 #include "classfile/systemDictionary.hpp"
  39 #include "classfile/systemDictionaryShared.hpp"
  40 #include "classfile/verifier.hpp"
  41 #include "classfile/vmClasses.hpp"
  42 #include "classfile/vmSymbols.hpp"
  43 #include "code/codeCache.hpp"
  44 #include "code/dependencyContext.hpp"
  45 #include "compiler/compilationPolicy.hpp"
  46 #include "compiler/compileBroker.hpp"
  47 #include "gc/shared/collectedHeap.inline.hpp"

  48 #include "interpreter/bytecodeStream.hpp"
  49 #include "interpreter/oopMapCache.hpp"
  50 #include "interpreter/rewriter.hpp"
  51 #include "jvm.h"
  52 #include "jvmtifiles/jvmti.h"
  53 #include "klass.inline.hpp"
  54 #include "logging/log.hpp"
  55 #include "logging/logMessage.hpp"
  56 #include "logging/logStream.hpp"
  57 #include "memory/allocation.inline.hpp"
  58 #include "memory/iterator.inline.hpp"
  59 #include "memory/metadataFactory.hpp"
  60 #include "memory/metaspaceClosure.hpp"
  61 #include "memory/oopFactory.hpp"
  62 #include "memory/resourceArea.hpp"
  63 #include "memory/universe.hpp"
  64 #include "oops/constantPool.hpp"
  65 #include "oops/fieldStreams.inline.hpp"
  66 #include "oops/instanceClassLoaderKlass.hpp"
  67 #include "oops/instanceKlass.inline.hpp"

  71 #include "oops/klass.inline.hpp"
  72 #include "oops/method.hpp"
  73 #include "oops/oop.inline.hpp"
  74 #include "oops/recordComponent.hpp"
  75 #include "oops/symbol.hpp"
  76 #include "prims/jvmtiExport.hpp"
  77 #include "prims/jvmtiRedefineClasses.hpp"
  78 #include "prims/jvmtiThreadState.hpp"
  79 #include "prims/methodComparator.hpp"
  80 #include "runtime/arguments.hpp"
  81 #include "runtime/atomic.hpp"
  82 #include "runtime/deoptimization.hpp"
  83 #include "runtime/fieldDescriptor.inline.hpp"
  84 #include "runtime/handles.inline.hpp"
  85 #include "runtime/javaCalls.hpp"
  86 #include "runtime/javaThread.inline.hpp"
  87 #include "runtime/mutexLocker.hpp"
  88 #include "runtime/orderAccess.hpp"
  89 #include "runtime/os.inline.hpp"
  90 #include "runtime/reflection.hpp"

  91 #include "runtime/synchronizer.hpp"
  92 #include "runtime/threads.hpp"
  93 #include "services/classLoadingService.hpp"
  94 #include "services/finalizerService.hpp"
  95 #include "services/threadService.hpp"
  96 #include "utilities/dtrace.hpp"
  97 #include "utilities/events.hpp"
  98 #include "utilities/macros.hpp"
  99 #include "utilities/nativeStackPrinter.hpp"
 100 #include "utilities/stringUtils.hpp"
 101 #ifdef COMPILER1
 102 #include "c1/c1_Compiler.hpp"
 103 #endif
 104 #if INCLUDE_JFR
 105 #include "jfr/jfrEvents.hpp"
 106 #endif
 107 
 108 #ifdef DTRACE_ENABLED
 109 
 110 

1067   return true;
1068 }
1069 
1070 // Rewrite the byte codes of all of the methods of a class.
1071 // The rewriter must be called exactly once. Rewriting must happen after
1072 // verification but before the first method of the class is executed.
1073 void InstanceKlass::rewrite_class(TRAPS) {
1074   assert(is_loaded(), "must be loaded");
1075   if (is_rewritten()) {
1076     assert(in_aot_cache(), "rewriting an unshared class?");
1077     return;
1078   }
1079   Rewriter::rewrite(this, CHECK);
1080   set_rewritten();
1081 }
1082 
1083 // Now relocate and link method entry points after class is rewritten.
1084 // This is outside is_rewritten flag. In case of an exception, it can be
1085 // executed more than once.
1086 void InstanceKlass::link_methods(TRAPS) {
1087   PerfTraceTime timer(ClassLoader::perf_ik_link_methods_time());
1088 
1089   int len = methods()->length();
1090   for (int i = len-1; i >= 0; i--) {
1091     methodHandle m(THREAD, methods()->at(i));

1092 
1093     // Set up method entry points for compiler and interpreter    .
1094     m->link_method(m, CHECK);
1095   }
1096 }
1097 
1098 // Eagerly initialize superinterfaces that declare default methods (concrete instance: any access)
1099 void InstanceKlass::initialize_super_interfaces(TRAPS) {
1100   assert (has_nonstatic_concrete_methods(), "caller should have checked this");
1101   for (int i = 0; i < local_interfaces()->length(); ++i) {
1102     InstanceKlass* ik = local_interfaces()->at(i);
1103 
1104     // Initialization is depth first search ie. we start with top of the inheritance tree
1105     // has_nonstatic_concrete_methods drives searching superinterfaces since it
1106     // means has_nonstatic_concrete_methods in its superinterface hierarchy
1107     if (ik->has_nonstatic_concrete_methods()) {
1108       ik->initialize_super_interfaces(CHECK);
1109     }
1110 
1111     // Only initialize() interfaces that "declare" concrete methods.

1176   assert_locked_or_safepoint(ClassInitError_lock);
1177   InitErrorTableCleaner cleaner;
1178   if (_initialization_error_table != nullptr) {
1179     _initialization_error_table->unlink(&cleaner);
1180   }
1181 }
1182 
1183 void InstanceKlass::initialize_impl(TRAPS) {
1184   HandleMark hm(THREAD);
1185 
1186   // Make sure klass is linked (verified) before initialization
1187   // A class could already be verified, since it has been reflected upon.
1188   link_class(CHECK);
1189 
1190   DTRACE_CLASSINIT_PROBE(required, -1);
1191 
1192   bool wait = false;
1193 
1194   JavaThread* jt = THREAD;
1195 















1196   bool debug_logging_enabled = log_is_enabled(Debug, class, init);
1197 
1198   // refer to the JVM book page 47 for description of steps
1199   // Step 1
1200   {
1201     Handle h_init_lock(THREAD, init_lock());
1202     ObjectLocker ol(h_init_lock, jt);
1203 
1204     // Step 2
1205     // If we were to use wait() instead of waitInterruptibly() then
1206     // we might end up throwing IE from link/symbol resolution sites
1207     // that aren't expected to throw.  This would wreak havoc.  See 6320309.
1208     while (is_being_initialized() && !is_reentrant_initialization(jt)) {
1209       if (debug_logging_enabled) {
1210         ResourceMark rm(jt);
1211         log_debug(class, init)("Thread \"%s\" waiting for initialization of %s by thread \"%s\"",
1212                                jt->name(), external_name(), init_thread_name());
1213       }
1214       wait = true;
1215       jt->set_class_to_be_initialized(this);

1345       add_initialization_error(THREAD, e);
1346       set_initialization_state_and_notify(initialization_error, THREAD);
1347       CLEAR_PENDING_EXCEPTION;   // ignore any exception thrown, class initialization error is thrown below
1348       // JVMTI has already reported the pending exception
1349       // JVMTI internal flag reset is needed in order to report ExceptionInInitializerError
1350       JvmtiExport::clear_detected_exception(jt);
1351     }
1352     DTRACE_CLASSINIT_PROBE_WAIT(error, -1, wait);
1353     if (e->is_a(vmClasses::Error_klass())) {
1354       THROW_OOP(e());
1355     } else {
1356       JavaCallArguments args(e);
1357       THROW_ARG(vmSymbols::java_lang_ExceptionInInitializerError(),
1358                 vmSymbols::throwable_void_signature(),
1359                 &args);
1360     }
1361   }
1362   DTRACE_CLASSINIT_PROBE_WAIT(end, -1, wait);
1363 }
1364 
1365 
1366 void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) {
1367   Handle h_init_lock(THREAD, init_lock());
1368   if (h_init_lock() != nullptr) {
1369     ObjectLocker ol(h_init_lock, THREAD);
1370     set_init_thread(nullptr); // reset _init_thread before changing _init_state
1371     set_init_state(state);
1372     fence_and_clear_init_lock();
1373     ol.notify_all(CHECK);
1374   } else {
1375     assert(h_init_lock() != nullptr, "The initialization state should never be set twice");
1376     set_init_thread(nullptr); // reset _init_thread before changing _init_state
1377     set_init_state(state);
1378   }
1379 }
1380 
1381 // Update hierarchy. This is done before the new klass has been added to the SystemDictionary. The Compile_lock
1382 // is grabbed, to ensure that the compiler is not using the class hierarchy.
1383 void InstanceKlass::add_to_hierarchy(JavaThread* current) {
1384   assert(!SafepointSynchronize::is_at_safepoint(), "must NOT be at safepoint");
1385 

1575     tty->print("Registered ");
1576     i->print_value_on(tty);
1577     tty->print_cr(" (" PTR_FORMAT ") as finalizable", p2i(i));
1578   }
1579   instanceHandle h_i(THREAD, i);
1580   // Pass the handle as argument, JavaCalls::call expects oop as jobjects
1581   JavaValue result(T_VOID);
1582   JavaCallArguments args(h_i);
1583   methodHandle mh(THREAD, Universe::finalizer_register_method());
1584   JavaCalls::call(&result, mh, &args, CHECK_NULL);
1585   MANAGEMENT_ONLY(FinalizerService::on_register(h_i(), THREAD);)
1586   return h_i();
1587 }
1588 
1589 instanceOop InstanceKlass::allocate_instance(TRAPS) {
1590   assert(!is_abstract() && !is_interface(), "Should not create this object");
1591   size_t size = size_helper();  // Query before forming handle.
1592   return (instanceOop)Universe::heap()->obj_allocate(this, size, CHECK_NULL);
1593 }
1594 
1595 instanceOop InstanceKlass::allocate_instance(oop java_class, TRAPS) {


1596   Klass* k = java_lang_Class::as_Klass(java_class);
1597   if (k == nullptr) {
1598     ResourceMark rm(THREAD);
1599     THROW_(vmSymbols::java_lang_InstantiationException(), nullptr);
1600   }
1601   InstanceKlass* ik = cast(k);
1602   ik->check_valid_for_instantiation(false, CHECK_NULL);
1603   ik->initialize(CHECK_NULL);
1604   return ik->allocate_instance(THREAD);
1605 }
1606 
1607 instanceHandle InstanceKlass::allocate_instance_handle(TRAPS) {
1608   return instanceHandle(THREAD, allocate_instance(THREAD));
1609 }
1610 
1611 void InstanceKlass::check_valid_for_instantiation(bool throwError, TRAPS) {
1612   if (is_interface() || is_abstract()) {
1613     ResourceMark rm(THREAD);
1614     THROW_MSG(throwError ? vmSymbols::java_lang_InstantiationError()
1615               : vmSymbols::java_lang_InstantiationException(), external_name());

1678     // Hide the existence of the initializer for the purpose of replaying the compile
1679     return;
1680   }
1681 
1682 #if INCLUDE_CDS
1683   // This is needed to ensure the consistency of the archived heap objects.
1684   if (has_aot_initialized_mirror() && CDSConfig::is_loading_heap()) {
1685     AOTClassInitializer::call_runtime_setup(THREAD, this);
1686     return;
1687   } else if (has_archived_enum_objs()) {
1688     assert(in_aot_cache(), "must be");
1689     bool initialized = CDSEnumKlass::initialize_enum_klass(this, CHECK);
1690     if (initialized) {
1691       return;
1692     }
1693   }
1694 #endif
1695 
1696   methodHandle h_method(THREAD, class_initializer());
1697   assert(!is_initialized(), "we cannot initialize twice");






















































1698   LogTarget(Info, class, init) lt;
1699   if (lt.is_enabled()) {
1700     ResourceMark rm(THREAD);
1701     LogStream ls(lt);
1702     ls.print("%d Initializing ", call_class_initializer_counter++);
1703     name()->print_value_on(&ls);
1704     ls.print_cr("%s (" PTR_FORMAT ") by thread \"%s\"",
1705                 h_method() == nullptr ? "(no method)" : "", p2i(this),
1706                 THREAD->name());
1707   }
1708   if (h_method() != nullptr) {
1709     ThreadInClassInitializer ticl(THREAD, this); // Track class being initialized
1710     JavaCallArguments args; // No arguments
1711     JavaValue result(T_VOID);
1712     JavaCalls::call(&result, h_method, &args, CHECK); // Static call (no args)
1713   }

1714 }
1715 
1716 // If a class that implements this interface is initialized, is the JVM required
1717 // to first execute a <clinit> method declared in this interface,
1718 // or (if also_check_supers==true) any of the super types of this interface?
1719 //
1720 // JVMS 5.5. Initialization, step 7: Next, if C is a class rather than
1721 // an interface, then let SC be its superclass and let SI1, ..., SIn
1722 // be all superinterfaces of C (whether direct or indirect) that
1723 // declare at least one non-abstract, non-static method.
1724 //
1725 // So when an interface is initialized, it does not look at its
1726 // supers. But a proper class will ensure that all of its supers have
1727 // run their <clinit> methods, except that it disregards interfaces
1728 // that lack a non-static concrete method (i.e., a default method).
1729 // Therefore, you should probably call this method only when the
1730 // current class is a super of some proper class, not an interface.
1731 bool InstanceKlass::interface_needs_clinit_execution_as_super(bool also_check_supers) const {
1732   assert(is_interface(), "must be");
1733 

2502         id == nullptr) {
2503       id = Method::make_jmethod_id(class_loader_data(), m);
2504       Atomic::release_store(&jmeths[idnum + 1], id);
2505     }
2506   }
2507 }
2508 
2509 // Lookup a jmethodID, null if not found.  Do no blocking, no allocations, no handles
2510 jmethodID InstanceKlass::jmethod_id_or_null(Method* method) {
2511   int idnum = method->method_idnum();
2512   jmethodID* jmeths = methods_jmethod_ids_acquire();
2513   return (jmeths != nullptr) ? jmeths[idnum + 1] : nullptr;
2514 }
2515 
2516 inline DependencyContext InstanceKlass::dependencies() {
2517   DependencyContext dep_context(&_dep_context, &_dep_context_last_cleaned);
2518   return dep_context;
2519 }
2520 
2521 void InstanceKlass::mark_dependent_nmethods(DeoptimizationScope* deopt_scope, KlassDepChange& changes) {
2522   dependencies().mark_dependent_nmethods(deopt_scope, changes);
2523 }
2524 
2525 void InstanceKlass::add_dependent_nmethod(nmethod* nm) {
2526   assert_lock_strong(CodeCache_lock);
2527   dependencies().add_dependent_nmethod(nm);
2528 }
2529 
2530 void InstanceKlass::clean_dependency_context() {
2531   dependencies().clean_unloading_dependents();
2532 }
2533 
2534 #ifndef PRODUCT
2535 void InstanceKlass::print_dependent_nmethods(bool verbose) {
2536   dependencies().print_dependent_nmethods(verbose);
2537 }
2538 
2539 bool InstanceKlass::is_dependent_nmethod(nmethod* nm) {
2540   return dependencies().is_dependent_nmethod(nm);
2541 }
2542 #endif //PRODUCT

2641     for (int i = 0; i < nof_interfaces; i ++, ioe ++) {
2642       if (ioe->interface_klass() != nullptr) {
2643         it->push(ioe->interface_klass_addr());
2644         itableMethodEntry* ime = ioe->first_method_entry(this);
2645         int n = klassItable::method_count_for_interface(ioe->interface_klass());
2646         for (int index = 0; index < n; index ++) {
2647           it->push(ime[index].method_addr());
2648         }
2649       }
2650     }
2651   }
2652 
2653   it->push(&_nest_host);
2654   it->push(&_nest_members);
2655   it->push(&_permitted_subclasses);
2656   it->push(&_record_components);
2657 }
2658 
2659 #if INCLUDE_CDS
2660 void InstanceKlass::remove_unshareable_info() {
2661 
2662   if (is_linked()) {
2663     assert(can_be_verified_at_dumptime(), "must be");
2664     // Remember this so we can avoid walking the hierarchy at runtime.
2665     set_verified_at_dump_time();
2666   }

2667 
2668   _misc_flags.set_has_init_deps_processed(false);
2669 
2670   Klass::remove_unshareable_info();
2671 
2672   if (SystemDictionaryShared::has_class_failed_verification(this)) {
2673     // Classes are attempted to link during dumping and may fail,
2674     // but these classes are still in the dictionary and class list in CLD.
2675     // If the class has failed verification, there is nothing else to remove.
2676     return;
2677   }
2678 
2679   // Reset to the 'allocated' state to prevent any premature accessing to
2680   // a shared class at runtime while the class is still being loaded and
2681   // restored. A class' init_state is set to 'loaded' at runtime when it's
2682   // being added to class hierarchy (see InstanceKlass:::add_to_hierarchy()).
2683   _init_state = allocated;
2684 
2685   { // Otherwise this needs to take out the Compile_lock.
2686     assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");

2822   constants()->restore_unshareable_info(CHECK);
2823 
2824   if (array_klasses() != nullptr) {
2825     // To get a consistent list of classes we need MultiArray_lock to ensure
2826     // array classes aren't observed while they are being restored.
2827     RecursiveLocker rl(MultiArray_lock, THREAD);
2828     assert(this == array_klasses()->bottom_klass(), "sanity");
2829     // Array classes have null protection domain.
2830     // --> see ArrayKlass::complete_create_array_klass()
2831     array_klasses()->restore_unshareable_info(class_loader_data(), Handle(), CHECK);
2832   }
2833 
2834   // Initialize @ValueBased class annotation if not already set in the archived klass.
2835   if (DiagnoseSyncOnValueBasedClasses && has_value_based_class_annotation() && !is_value_based()) {
2836     set_is_value_based();
2837   }
2838 
2839   DEBUG_ONLY(FieldInfoStream::validate_search_table(_constants, _fieldinfo_stream, _fieldinfo_search_table));
2840 }
2841 
2842 // Check if a class or any of its supertypes has a version older than 50.
2843 // CDS will not perform verification of old classes during dump time because
2844 // without changing the old verifier, the verification constraint cannot be
2845 // retrieved during dump time.
2846 // Verification of archived old classes will be performed during run time.
2847 bool InstanceKlass::can_be_verified_at_dumptime() const {




2848   if (AOTMetaspace::in_aot_cache(this)) {
2849     // This is a class that was dumped into the base archive, so we know
2850     // it was verified at dump time.
2851     return true;
2852   }






2853   if (major_version() < 50 /*JAVA_6_VERSION*/) {
2854     return false;
2855   }
2856   if (super() != nullptr && !super()->can_be_verified_at_dumptime()) {
2857     return false;
2858   }
2859   Array<InstanceKlass*>* interfaces = local_interfaces();
2860   int len = interfaces->length();
2861   for (int i = 0; i < len; i++) {
2862     if (!interfaces->at(i)->can_be_verified_at_dumptime()) {
2863       return false;
2864     }
2865   }
2866   return true;
2867 }
2868 
2869 #endif // INCLUDE_CDS
2870 
2871 #if INCLUDE_JVMTI
2872 static void clear_all_breakpoints(Method* m) {

3627 static void print_vtable(intptr_t* start, int len, outputStream* st) {
3628   for (int i = 0; i < len; i++) {
3629     intptr_t e = start[i];
3630     st->print("%d : " INTPTR_FORMAT, i, e);
3631     if (MetaspaceObj::is_valid((Metadata*)e)) {
3632       st->print(" ");
3633       ((Metadata*)e)->print_value_on(st);
3634     }
3635     st->cr();
3636   }
3637 }
3638 
3639 static void print_vtable(vtableEntry* start, int len, outputStream* st) {
3640   return print_vtable(reinterpret_cast<intptr_t*>(start), len, st);
3641 }
3642 
3643 const char* InstanceKlass::init_state_name() const {
3644   return state_names[init_state()];
3645 }
3646 




3647 void InstanceKlass::print_on(outputStream* st) const {
3648   assert(is_klass(), "must be klass");
3649   Klass::print_on(st);
3650 
3651   st->print(BULLET"instance size:     %d", size_helper());                        st->cr();
3652   st->print(BULLET"klass size:        %d", size());                               st->cr();
3653   st->print(BULLET"access:            "); access_flags().print_on(st);            st->cr();
3654   st->print(BULLET"flags:             "); _misc_flags.print_on(st);               st->cr();
3655   st->print(BULLET"state:             "); st->print_cr("%s", init_state_name());
3656   st->print(BULLET"name:              "); name()->print_value_on(st);             st->cr();
3657   st->print(BULLET"super:             "); Metadata::print_value_on_maybe_null(st, super()); st->cr();
3658   st->print(BULLET"sub:               ");
3659   Klass* sub = subklass();
3660   int n;
3661   for (n = 0; sub != nullptr; n++, sub = sub->next_sibling()) {
3662     if (n < MaxSubklassPrintSize) {
3663       sub->print_value_on(st);
3664       st->print("   ");
3665     }
3666   }

3961         nullptr;
3962       // caller can be null, for example, during a JVMTI VM_Init hook
3963       if (caller != nullptr) {
3964         info_stream.print(" source: instance of %s", caller->external_name());
3965       } else {
3966         // source is unknown
3967       }
3968     } else {
3969       oop class_loader = loader_data->class_loader();
3970       info_stream.print(" source: %s", class_loader->klass()->external_name());
3971     }
3972   } else {
3973     assert(this->in_aot_cache(), "must be");
3974     if (AOTMetaspace::in_aot_cache_dynamic_region((void*)this)) {
3975       info_stream.print(" source: shared objects file (top)");
3976     } else {
3977       info_stream.print(" source: shared objects file");
3978     }
3979   }
3980 

















3981   msg.info("%s", info_stream.as_string());
3982 
3983   if (log_is_enabled(Debug, class, load)) {
3984     stringStream debug_stream;
3985 
3986     // Class hierarchy info
3987     debug_stream.print(" klass: " PTR_FORMAT " super: " PTR_FORMAT,
3988                        p2i(this),  p2i(super()));
3989 
3990     // Interfaces
3991     if (local_interfaces() != nullptr && local_interfaces()->length() > 0) {
3992       debug_stream.print(" interfaces:");
3993       int length = local_interfaces()->length();
3994       for (int i = 0; i < length; i++) {
3995         debug_stream.print(" " PTR_FORMAT,
3996                            p2i(local_interfaces()->at(i)));
3997       }
3998     }
3999 
4000     // Class loader

  28 #include "cds/cdsConfig.hpp"
  29 #include "cds/cdsEnumKlass.hpp"
  30 #include "cds/classListWriter.hpp"
  31 #include "cds/heapShared.hpp"
  32 #include "classfile/classFileParser.hpp"
  33 #include "classfile/classFileStream.hpp"
  34 #include "classfile/classLoader.hpp"
  35 #include "classfile/classLoaderData.inline.hpp"
  36 #include "classfile/javaClasses.hpp"
  37 #include "classfile/moduleEntry.hpp"
  38 #include "classfile/systemDictionary.hpp"
  39 #include "classfile/systemDictionaryShared.hpp"
  40 #include "classfile/verifier.hpp"
  41 #include "classfile/vmClasses.hpp"
  42 #include "classfile/vmSymbols.hpp"
  43 #include "code/codeCache.hpp"
  44 #include "code/dependencyContext.hpp"
  45 #include "compiler/compilationPolicy.hpp"
  46 #include "compiler/compileBroker.hpp"
  47 #include "gc/shared/collectedHeap.inline.hpp"
  48 #include "interpreter/bytecodeHistogram.hpp"
  49 #include "interpreter/bytecodeStream.hpp"
  50 #include "interpreter/oopMapCache.hpp"
  51 #include "interpreter/rewriter.hpp"
  52 #include "jvm.h"
  53 #include "jvmtifiles/jvmti.h"
  54 #include "klass.inline.hpp"
  55 #include "logging/log.hpp"
  56 #include "logging/logMessage.hpp"
  57 #include "logging/logStream.hpp"
  58 #include "memory/allocation.inline.hpp"
  59 #include "memory/iterator.inline.hpp"
  60 #include "memory/metadataFactory.hpp"
  61 #include "memory/metaspaceClosure.hpp"
  62 #include "memory/oopFactory.hpp"
  63 #include "memory/resourceArea.hpp"
  64 #include "memory/universe.hpp"
  65 #include "oops/constantPool.hpp"
  66 #include "oops/fieldStreams.inline.hpp"
  67 #include "oops/instanceClassLoaderKlass.hpp"
  68 #include "oops/instanceKlass.inline.hpp"

  72 #include "oops/klass.inline.hpp"
  73 #include "oops/method.hpp"
  74 #include "oops/oop.inline.hpp"
  75 #include "oops/recordComponent.hpp"
  76 #include "oops/symbol.hpp"
  77 #include "prims/jvmtiExport.hpp"
  78 #include "prims/jvmtiRedefineClasses.hpp"
  79 #include "prims/jvmtiThreadState.hpp"
  80 #include "prims/methodComparator.hpp"
  81 #include "runtime/arguments.hpp"
  82 #include "runtime/atomic.hpp"
  83 #include "runtime/deoptimization.hpp"
  84 #include "runtime/fieldDescriptor.inline.hpp"
  85 #include "runtime/handles.inline.hpp"
  86 #include "runtime/javaCalls.hpp"
  87 #include "runtime/javaThread.inline.hpp"
  88 #include "runtime/mutexLocker.hpp"
  89 #include "runtime/orderAccess.hpp"
  90 #include "runtime/os.inline.hpp"
  91 #include "runtime/reflection.hpp"
  92 #include "runtime/runtimeUpcalls.hpp"
  93 #include "runtime/synchronizer.hpp"
  94 #include "runtime/threads.hpp"
  95 #include "services/classLoadingService.hpp"
  96 #include "services/finalizerService.hpp"
  97 #include "services/threadService.hpp"
  98 #include "utilities/dtrace.hpp"
  99 #include "utilities/events.hpp"
 100 #include "utilities/macros.hpp"
 101 #include "utilities/nativeStackPrinter.hpp"
 102 #include "utilities/stringUtils.hpp"
 103 #ifdef COMPILER1
 104 #include "c1/c1_Compiler.hpp"
 105 #endif
 106 #if INCLUDE_JFR
 107 #include "jfr/jfrEvents.hpp"
 108 #endif
 109 
 110 #ifdef DTRACE_ENABLED
 111 
 112 

1069   return true;
1070 }
1071 
1072 // Rewrite the byte codes of all of the methods of a class.
1073 // The rewriter must be called exactly once. Rewriting must happen after
1074 // verification but before the first method of the class is executed.
1075 void InstanceKlass::rewrite_class(TRAPS) {
1076   assert(is_loaded(), "must be loaded");
1077   if (is_rewritten()) {
1078     assert(in_aot_cache(), "rewriting an unshared class?");
1079     return;
1080   }
1081   Rewriter::rewrite(this, CHECK);
1082   set_rewritten();
1083 }
1084 
1085 // Now relocate and link method entry points after class is rewritten.
1086 // This is outside is_rewritten flag. In case of an exception, it can be
1087 // executed more than once.
1088 void InstanceKlass::link_methods(TRAPS) {
1089   PerfTraceElapsedTime timer(ClassLoader::perf_ik_link_methods_time());
1090 
1091   int len = methods()->length();
1092   for (int i = len-1; i >= 0; i--) {
1093     methodHandle m(THREAD, methods()->at(i));
1094     RuntimeUpcalls::install_upcalls(m);
1095 
1096     // Set up method entry points for compiler and interpreter    .
1097     m->link_method(m, CHECK);
1098   }
1099 }
1100 
1101 // Eagerly initialize superinterfaces that declare default methods (concrete instance: any access)
1102 void InstanceKlass::initialize_super_interfaces(TRAPS) {
1103   assert (has_nonstatic_concrete_methods(), "caller should have checked this");
1104   for (int i = 0; i < local_interfaces()->length(); ++i) {
1105     InstanceKlass* ik = local_interfaces()->at(i);
1106 
1107     // Initialization is depth first search ie. we start with top of the inheritance tree
1108     // has_nonstatic_concrete_methods drives searching superinterfaces since it
1109     // means has_nonstatic_concrete_methods in its superinterface hierarchy
1110     if (ik->has_nonstatic_concrete_methods()) {
1111       ik->initialize_super_interfaces(CHECK);
1112     }
1113 
1114     // Only initialize() interfaces that "declare" concrete methods.

1179   assert_locked_or_safepoint(ClassInitError_lock);
1180   InitErrorTableCleaner cleaner;
1181   if (_initialization_error_table != nullptr) {
1182     _initialization_error_table->unlink(&cleaner);
1183   }
1184 }
1185 
1186 void InstanceKlass::initialize_impl(TRAPS) {
1187   HandleMark hm(THREAD);
1188 
1189   // Make sure klass is linked (verified) before initialization
1190   // A class could already be verified, since it has been reflected upon.
1191   link_class(CHECK);
1192 
1193   DTRACE_CLASSINIT_PROBE(required, -1);
1194 
1195   bool wait = false;
1196 
1197   JavaThread* jt = THREAD;
1198 
1199   if (ForceProfiling) {
1200     // Preallocate MDOs.
1201     for (int i = 0; i < methods()->length(); i++) {
1202       assert(!HAS_PENDING_EXCEPTION, "");
1203       methodHandle m(THREAD, methods()->at(i));
1204       Method::build_profiling_method_data(m, THREAD);
1205       if (HAS_PENDING_EXCEPTION) {
1206         ResourceMark rm;
1207         log_warning(cds)("MDO preallocation failed for %s", external_name());
1208         CLEAR_PENDING_EXCEPTION;
1209         break;
1210       }
1211     }
1212   }
1213 
1214   bool debug_logging_enabled = log_is_enabled(Debug, class, init);
1215 
1216   // refer to the JVM book page 47 for description of steps
1217   // Step 1
1218   {
1219     Handle h_init_lock(THREAD, init_lock());
1220     ObjectLocker ol(h_init_lock, jt);
1221 
1222     // Step 2
1223     // If we were to use wait() instead of waitInterruptibly() then
1224     // we might end up throwing IE from link/symbol resolution sites
1225     // that aren't expected to throw.  This would wreak havoc.  See 6320309.
1226     while (is_being_initialized() && !is_reentrant_initialization(jt)) {
1227       if (debug_logging_enabled) {
1228         ResourceMark rm(jt);
1229         log_debug(class, init)("Thread \"%s\" waiting for initialization of %s by thread \"%s\"",
1230                                jt->name(), external_name(), init_thread_name());
1231       }
1232       wait = true;
1233       jt->set_class_to_be_initialized(this);

1363       add_initialization_error(THREAD, e);
1364       set_initialization_state_and_notify(initialization_error, THREAD);
1365       CLEAR_PENDING_EXCEPTION;   // ignore any exception thrown, class initialization error is thrown below
1366       // JVMTI has already reported the pending exception
1367       // JVMTI internal flag reset is needed in order to report ExceptionInInitializerError
1368       JvmtiExport::clear_detected_exception(jt);
1369     }
1370     DTRACE_CLASSINIT_PROBE_WAIT(error, -1, wait);
1371     if (e->is_a(vmClasses::Error_klass())) {
1372       THROW_OOP(e());
1373     } else {
1374       JavaCallArguments args(e);
1375       THROW_ARG(vmSymbols::java_lang_ExceptionInInitializerError(),
1376                 vmSymbols::throwable_void_signature(),
1377                 &args);
1378     }
1379   }
1380   DTRACE_CLASSINIT_PROBE_WAIT(end, -1, wait);
1381 }
1382 

1383 void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) {
1384   Handle h_init_lock(THREAD, init_lock());
1385   if (h_init_lock() != nullptr) {
1386     ObjectLocker ol(h_init_lock, THREAD);
1387     set_init_thread(nullptr); // reset _init_thread before changing _init_state
1388     set_init_state(state);
1389     fence_and_clear_init_lock();
1390     ol.notify_all(CHECK);
1391   } else {
1392     assert(h_init_lock() != nullptr, "The initialization state should never be set twice");
1393     set_init_thread(nullptr); // reset _init_thread before changing _init_state
1394     set_init_state(state);
1395   }
1396 }
1397 
1398 // Update hierarchy. This is done before the new klass has been added to the SystemDictionary. The Compile_lock
1399 // is grabbed, to ensure that the compiler is not using the class hierarchy.
1400 void InstanceKlass::add_to_hierarchy(JavaThread* current) {
1401   assert(!SafepointSynchronize::is_at_safepoint(), "must NOT be at safepoint");
1402 

1592     tty->print("Registered ");
1593     i->print_value_on(tty);
1594     tty->print_cr(" (" PTR_FORMAT ") as finalizable", p2i(i));
1595   }
1596   instanceHandle h_i(THREAD, i);
1597   // Pass the handle as argument, JavaCalls::call expects oop as jobjects
1598   JavaValue result(T_VOID);
1599   JavaCallArguments args(h_i);
1600   methodHandle mh(THREAD, Universe::finalizer_register_method());
1601   JavaCalls::call(&result, mh, &args, CHECK_NULL);
1602   MANAGEMENT_ONLY(FinalizerService::on_register(h_i(), THREAD);)
1603   return h_i();
1604 }
1605 
1606 instanceOop InstanceKlass::allocate_instance(TRAPS) {
1607   assert(!is_abstract() && !is_interface(), "Should not create this object");
1608   size_t size = size_helper();  // Query before forming handle.
1609   return (instanceOop)Universe::heap()->obj_allocate(this, size, CHECK_NULL);
1610 }
1611 
1612 instanceOop InstanceKlass::allocate_instance(oop java_class,
1613                                              const char* who,
1614                                              TRAPS) {
1615   Klass* k = java_lang_Class::as_Klass(java_class);
1616   if (k == nullptr) {
1617     ResourceMark rm(THREAD);
1618     THROW_(vmSymbols::java_lang_InstantiationException(), nullptr);
1619   }
1620   InstanceKlass* ik = cast(k);
1621   ik->check_valid_for_instantiation(false, CHECK_NULL);
1622   ik->initialize(CHECK_NULL);
1623   return ik->allocate_instance(THREAD);
1624 }
1625 
1626 instanceHandle InstanceKlass::allocate_instance_handle(TRAPS) {
1627   return instanceHandle(THREAD, allocate_instance(THREAD));
1628 }
1629 
1630 void InstanceKlass::check_valid_for_instantiation(bool throwError, TRAPS) {
1631   if (is_interface() || is_abstract()) {
1632     ResourceMark rm(THREAD);
1633     THROW_MSG(throwError ? vmSymbols::java_lang_InstantiationError()
1634               : vmSymbols::java_lang_InstantiationException(), external_name());

1697     // Hide the existence of the initializer for the purpose of replaying the compile
1698     return;
1699   }
1700 
1701 #if INCLUDE_CDS
1702   // This is needed to ensure the consistency of the archived heap objects.
1703   if (has_aot_initialized_mirror() && CDSConfig::is_loading_heap()) {
1704     AOTClassInitializer::call_runtime_setup(THREAD, this);
1705     return;
1706   } else if (has_archived_enum_objs()) {
1707     assert(in_aot_cache(), "must be");
1708     bool initialized = CDSEnumKlass::initialize_enum_klass(this, CHECK);
1709     if (initialized) {
1710       return;
1711     }
1712   }
1713 #endif
1714 
1715   methodHandle h_method(THREAD, class_initializer());
1716   assert(!is_initialized(), "we cannot initialize twice");
1717 
1718 #if 0
1719   // FIXME -- revive this code added to leyden/premain for <clinit> profiling
1720   int init_id = log_class_init(THREAD, this);
1721   if (h_method() != nullptr) {
1722     JavaCallArguments args; // No arguments
1723     JavaValue result(T_VOID);
1724     InstanceKlass* outer = THREAD->set_class_being_initialized(this);
1725     jlong bc_start = (CountBytecodesPerThread ? THREAD->bc_counter_value() : BytecodeCounter::counter_value());
1726 
1727     elapsedTimer timer;
1728     {
1729       PerfPauseTimer pt(THREAD->current_rt_call_timer(), THREAD->profile_rt_calls());
1730       PauseRuntimeCallProfiling prcp(THREAD, THREAD->profile_rt_calls());
1731 
1732       timer.start();
1733       JavaCalls::call(&result, h_method, &args, THREAD); // Static call (no args)
1734       timer.stop();
1735     }
1736 
1737     jlong bc_end = (CountBytecodesPerThread ? THREAD->bc_counter_value() : BytecodeCounter::counter_value());
1738 
1739     jlong bc_executed = (bc_end - bc_start);
1740     if (UsePerfData && outer == nullptr) { // outermost clinit
1741       THREAD->inc_clinit_bc_counter_value(bc_executed);
1742       ClassLoader::perf_class_init_bytecodes_count()->inc(bc_executed);
1743     }
1744 
1745     THREAD->set_class_being_initialized(outer);
1746 
1747     LogStreamHandle(Debug, init) log;
1748     if (log.is_enabled()) {
1749       ResourceMark rm(THREAD);
1750       log.print("%d Initialized in %.3fms (total: " JLONG_FORMAT "ms); ",
1751                 init_id, timer.seconds() * 1000.0, ClassLoader::class_init_time_ms());
1752       if (CountBytecodes || CountBytecodesPerThread) {
1753         log.print("executed " JLONG_FORMAT " bytecodes; ", bc_executed);
1754       }
1755       name()->print_value_on(&log);
1756       log.print_cr(" by thread " PTR_FORMAT " \"%s\" (" PTR_FORMAT ")",
1757                    p2i(THREAD), THREAD->name(), p2i(this));
1758     }
1759   }
1760   LogTarget(Info, class, init) lt;
1761   if (lt.is_enabled()) {
1762     ResourceMark rm(THREAD);
1763     LogStream ls(lt);
1764     ls.print("%d Initialized ", init_id);
1765     name()->print_value_on(&ls);
1766     ls.print_cr("%s (" PTR_FORMAT ") by thread \"%s\"",
1767                 h_method() == nullptr ? "(no method)" : "", p2i(this),
1768                 THREAD->name());
1769   }
1770 #else
1771   LogTarget(Info, class, init) lt;
1772   if (lt.is_enabled()) {
1773     ResourceMark rm(THREAD);
1774     LogStream ls(lt);
1775     ls.print("%d Initializing ", call_class_initializer_counter++);
1776     name()->print_value_on(&ls);
1777     ls.print_cr("%s (" PTR_FORMAT ") by thread \"%s\"",
1778                 h_method() == nullptr ? "(no method)" : "", p2i(this),
1779                 THREAD->name());
1780   }
1781   if (h_method() != nullptr) {
1782     ThreadInClassInitializer ticl(THREAD, this); // Track class being initialized
1783     JavaCallArguments args; // No arguments
1784     JavaValue result(T_VOID);
1785     JavaCalls::call(&result, h_method, &args, CHECK); // Static call (no args)
1786   }
1787 #endif
1788 }
1789 
1790 // If a class that implements this interface is initialized, is the JVM required
1791 // to first execute a <clinit> method declared in this interface,
1792 // or (if also_check_supers==true) any of the super types of this interface?
1793 //
1794 // JVMS 5.5. Initialization, step 7: Next, if C is a class rather than
1795 // an interface, then let SC be its superclass and let SI1, ..., SIn
1796 // be all superinterfaces of C (whether direct or indirect) that
1797 // declare at least one non-abstract, non-static method.
1798 //
1799 // So when an interface is initialized, it does not look at its
1800 // supers. But a proper class will ensure that all of its supers have
1801 // run their <clinit> methods, except that it disregards interfaces
1802 // that lack a non-static concrete method (i.e., a default method).
1803 // Therefore, you should probably call this method only when the
1804 // current class is a super of some proper class, not an interface.
1805 bool InstanceKlass::interface_needs_clinit_execution_as_super(bool also_check_supers) const {
1806   assert(is_interface(), "must be");
1807 

2576         id == nullptr) {
2577       id = Method::make_jmethod_id(class_loader_data(), m);
2578       Atomic::release_store(&jmeths[idnum + 1], id);
2579     }
2580   }
2581 }
2582 
2583 // Lookup a jmethodID, null if not found.  Do no blocking, no allocations, no handles
2584 jmethodID InstanceKlass::jmethod_id_or_null(Method* method) {
2585   int idnum = method->method_idnum();
2586   jmethodID* jmeths = methods_jmethod_ids_acquire();
2587   return (jmeths != nullptr) ? jmeths[idnum + 1] : nullptr;
2588 }
2589 
2590 inline DependencyContext InstanceKlass::dependencies() {
2591   DependencyContext dep_context(&_dep_context, &_dep_context_last_cleaned);
2592   return dep_context;
2593 }
2594 
2595 void InstanceKlass::mark_dependent_nmethods(DeoptimizationScope* deopt_scope, KlassDepChange& changes) {
2596   dependencies().mark_dependent_nmethods(deopt_scope, changes, this);
2597 }
2598 
2599 void InstanceKlass::add_dependent_nmethod(nmethod* nm) {
2600   assert_lock_strong(CodeCache_lock);
2601   dependencies().add_dependent_nmethod(nm);
2602 }
2603 
2604 void InstanceKlass::clean_dependency_context() {
2605   dependencies().clean_unloading_dependents();
2606 }
2607 
2608 #ifndef PRODUCT
2609 void InstanceKlass::print_dependent_nmethods(bool verbose) {
2610   dependencies().print_dependent_nmethods(verbose);
2611 }
2612 
2613 bool InstanceKlass::is_dependent_nmethod(nmethod* nm) {
2614   return dependencies().is_dependent_nmethod(nm);
2615 }
2616 #endif //PRODUCT

2715     for (int i = 0; i < nof_interfaces; i ++, ioe ++) {
2716       if (ioe->interface_klass() != nullptr) {
2717         it->push(ioe->interface_klass_addr());
2718         itableMethodEntry* ime = ioe->first_method_entry(this);
2719         int n = klassItable::method_count_for_interface(ioe->interface_klass());
2720         for (int index = 0; index < n; index ++) {
2721           it->push(ime[index].method_addr());
2722         }
2723       }
2724     }
2725   }
2726 
2727   it->push(&_nest_host);
2728   it->push(&_nest_members);
2729   it->push(&_permitted_subclasses);
2730   it->push(&_record_components);
2731 }
2732 
2733 #if INCLUDE_CDS
2734 void InstanceKlass::remove_unshareable_info() {

2735   if (is_linked()) {
2736     assert(can_be_verified_at_dumptime(), "must be");
2737     // Remember this so we can avoid walking the hierarchy at runtime.
2738     set_verified_at_dump_time();
2739   }
2740   _misc_flags.set_has_init_deps_processed(false);
2741 
2742   _misc_flags.set_has_init_deps_processed(false);
2743 
2744   Klass::remove_unshareable_info();
2745 
2746   if (SystemDictionaryShared::has_class_failed_verification(this)) {
2747     // Classes are attempted to link during dumping and may fail,
2748     // but these classes are still in the dictionary and class list in CLD.
2749     // If the class has failed verification, there is nothing else to remove.
2750     return;
2751   }
2752 
2753   // Reset to the 'allocated' state to prevent any premature accessing to
2754   // a shared class at runtime while the class is still being loaded and
2755   // restored. A class' init_state is set to 'loaded' at runtime when it's
2756   // being added to class hierarchy (see InstanceKlass:::add_to_hierarchy()).
2757   _init_state = allocated;
2758 
2759   { // Otherwise this needs to take out the Compile_lock.
2760     assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");

2896   constants()->restore_unshareable_info(CHECK);
2897 
2898   if (array_klasses() != nullptr) {
2899     // To get a consistent list of classes we need MultiArray_lock to ensure
2900     // array classes aren't observed while they are being restored.
2901     RecursiveLocker rl(MultiArray_lock, THREAD);
2902     assert(this == array_klasses()->bottom_klass(), "sanity");
2903     // Array classes have null protection domain.
2904     // --> see ArrayKlass::complete_create_array_klass()
2905     array_klasses()->restore_unshareable_info(class_loader_data(), Handle(), CHECK);
2906   }
2907 
2908   // Initialize @ValueBased class annotation if not already set in the archived klass.
2909   if (DiagnoseSyncOnValueBasedClasses && has_value_based_class_annotation() && !is_value_based()) {
2910     set_is_value_based();
2911   }
2912 
2913   DEBUG_ONLY(FieldInfoStream::validate_search_table(_constants, _fieldinfo_stream, _fieldinfo_search_table));
2914 }
2915 





2916 bool InstanceKlass::can_be_verified_at_dumptime() const {
2917   if (CDSConfig::preserve_all_dumptime_verification_states(this)) {
2918     return true;
2919   }
2920 
2921   if (AOTMetaspace::in_aot_cache(this)) {
2922     // This is a class that was dumped into the base archive, so we know
2923     // it was verified at dump time.
2924     return true;
2925   }
2926 
2927   // Check if a class or any of its supertypes has a version older than 50.
2928   // CDS will not perform verification of old classes during dump time because
2929   // without changing the old verifier, the verification constraint cannot be
2930   // retrieved during dump time.
2931   // Verification of archived old classes will be performed during run time.
2932   if (major_version() < 50 /*JAVA_6_VERSION*/) {
2933     return false;
2934   }
2935   if (super() != nullptr && !super()->can_be_verified_at_dumptime()) {
2936     return false;
2937   }
2938   Array<InstanceKlass*>* interfaces = local_interfaces();
2939   int len = interfaces->length();
2940   for (int i = 0; i < len; i++) {
2941     if (!interfaces->at(i)->can_be_verified_at_dumptime()) {
2942       return false;
2943     }
2944   }
2945   return true;
2946 }
2947 
2948 #endif // INCLUDE_CDS
2949 
2950 #if INCLUDE_JVMTI
2951 static void clear_all_breakpoints(Method* m) {

3706 static void print_vtable(intptr_t* start, int len, outputStream* st) {
3707   for (int i = 0; i < len; i++) {
3708     intptr_t e = start[i];
3709     st->print("%d : " INTPTR_FORMAT, i, e);
3710     if (MetaspaceObj::is_valid((Metadata*)e)) {
3711       st->print(" ");
3712       ((Metadata*)e)->print_value_on(st);
3713     }
3714     st->cr();
3715   }
3716 }
3717 
3718 static void print_vtable(vtableEntry* start, int len, outputStream* st) {
3719   return print_vtable(reinterpret_cast<intptr_t*>(start), len, st);
3720 }
3721 
3722 const char* InstanceKlass::init_state_name() const {
3723   return state_names[init_state()];
3724 }
3725 
3726 const char* InstanceKlass::state2name(ClassState s) {
3727   return state_names[s];
3728 }
3729 
3730 void InstanceKlass::print_on(outputStream* st) const {
3731   assert(is_klass(), "must be klass");
3732   Klass::print_on(st);
3733 
3734   st->print(BULLET"instance size:     %d", size_helper());                        st->cr();
3735   st->print(BULLET"klass size:        %d", size());                               st->cr();
3736   st->print(BULLET"access:            "); access_flags().print_on(st);            st->cr();
3737   st->print(BULLET"flags:             "); _misc_flags.print_on(st);               st->cr();
3738   st->print(BULLET"state:             "); st->print_cr("%s", init_state_name());
3739   st->print(BULLET"name:              "); name()->print_value_on(st);             st->cr();
3740   st->print(BULLET"super:             "); Metadata::print_value_on_maybe_null(st, super()); st->cr();
3741   st->print(BULLET"sub:               ");
3742   Klass* sub = subklass();
3743   int n;
3744   for (n = 0; sub != nullptr; n++, sub = sub->next_sibling()) {
3745     if (n < MaxSubklassPrintSize) {
3746       sub->print_value_on(st);
3747       st->print("   ");
3748     }
3749   }

4044         nullptr;
4045       // caller can be null, for example, during a JVMTI VM_Init hook
4046       if (caller != nullptr) {
4047         info_stream.print(" source: instance of %s", caller->external_name());
4048       } else {
4049         // source is unknown
4050       }
4051     } else {
4052       oop class_loader = loader_data->class_loader();
4053       info_stream.print(" source: %s", class_loader->klass()->external_name());
4054     }
4055   } else {
4056     assert(this->in_aot_cache(), "must be");
4057     if (AOTMetaspace::in_aot_cache_dynamic_region((void*)this)) {
4058       info_stream.print(" source: shared objects file (top)");
4059     } else {
4060       info_stream.print(" source: shared objects file");
4061     }
4062   }
4063 
4064   info_stream.print(" loader:");
4065   if (in_aot_cache()) {
4066     info_stream.print(" %s", SystemDictionaryShared::loader_type_for_shared_class((Klass*)this));
4067   } else if (loader_data == ClassLoaderData::the_null_class_loader_data()) {
4068     info_stream.print(" boot_loader");
4069   } else {
4070     oop class_loader = loader_data->class_loader();
4071     if (class_loader != nullptr) {
4072       info_stream.print(" %s", class_loader->klass()->external_name());
4073       oop cl_name_and_id = java_lang_ClassLoader::nameAndId(class_loader);
4074       if (cl_name_and_id != nullptr) {
4075         info_stream.print(" %s", java_lang_String::as_utf8_string(cl_name_and_id));
4076       }
4077     } else {
4078       info_stream.print(" null");
4079     }
4080   }
4081   msg.info("%s", info_stream.as_string());
4082 
4083   if (log_is_enabled(Debug, class, load)) {
4084     stringStream debug_stream;
4085 
4086     // Class hierarchy info
4087     debug_stream.print(" klass: " PTR_FORMAT " super: " PTR_FORMAT,
4088                        p2i(this),  p2i(super()));
4089 
4090     // Interfaces
4091     if (local_interfaces() != nullptr && local_interfaces()->length() > 0) {
4092       debug_stream.print(" interfaces:");
4093       int length = local_interfaces()->length();
4094       for (int i = 0; i < length; i++) {
4095         debug_stream.print(" " PTR_FORMAT,
4096                            p2i(local_interfaces()->at(i)));
4097       }
4098     }
4099 
4100     // Class loader
< prev index next >