src/share/vm/oops/instanceKlass.cpp

Print this page
rev 9245 : [mq]: class_loading_log

*** 31,40 **** --- 31,41 ---- #include "gc/shared/collectedHeap.inline.hpp" #include "gc/shared/specialized_oop_closures.hpp" #include "interpreter/oopMapCache.hpp" #include "interpreter/rewriter.hpp" #include "jvmtifiles/jvmti.h" + #include "logging/log.hpp" #include "memory/heapInspection.hpp" #include "memory/iterator.inline.hpp" #include "memory/metadataFactory.hpp" #include "memory/oopFactory.hpp" #include "oops/fieldStreams.hpp"
*** 3028,3037 **** --- 3029,3104 ---- const char* InstanceKlass::internal_name() const { return external_name(); } + void InstanceKlass::print_loading_log(LogLevel::type type, ClassLoaderData* loader_data, ClassFileStream* cfs) const { + ResourceMark rm; + outputStream* log; + + assert(type == LogLevel::Debug || type == LogLevel::Trace, "sanity"); + + if (type == LogLevel::Debug) { + log = LogHandle(classload)::debug_stream(); + } else { + assert(type == LogLevel::Trace, "print_loading_log supports only Debug and Trace levels"); + log = LogHandle(classload)::trace_stream(); + } + + // Name and class hierarchy info + log->print("%s", external_name()); + + // Source + if (cfs != NULL) { + if (cfs->source() != NULL) { + log->print(" source: %s", cfs->source()); + } else if (loader_data == ClassLoaderData::the_null_class_loader_data()) { + Thread* THREAD = Thread::current(); + Klass* caller = + THREAD->is_Java_thread() + ? ((JavaThread*)THREAD)->security_get_caller_class(1) + : NULL; + // caller can be NULL, for example, during a JVMTI VM_Init hook + if (caller != NULL) { + tty->print(" source: instance of %s", caller->external_name()); + } else { + // source is unknown + } + } else { + Handle class_loader(loader_data->class_loader()); + tty->print(" source: %s", class_loader->klass()->external_name()); + } + } else { + log->print(" source: shared objects file"); + } + + if (type == LogLevel::Trace) { + // Class hierarchy info + log->print(" klass: " INTPTR_FORMAT " super: " INTPTR_FORMAT, + p2i(this), p2i(superklass())); + + if (local_interfaces() != NULL && local_interfaces()->length() > 0) { + log->print(" interfaces:"); + int length = local_interfaces()->length(); + for (int i = 0; i < length; i++) { + log->print(" " INTPTR_FORMAT, p2i(InstanceKlass::cast(local_interfaces()->at(i)))); + } + } + + // Class loader + log->print(" loader: ["); + loader_data->print_value_on(log); + log->print("]"); + + // Classfile checksum + if (cfs) { + log->print(" bytes: %d checksum: %08x", cfs->length(), ClassLoader::crc32(0, (const char*)cfs->buffer(), cfs->length())); + } + } + log->cr(); + } + #if INCLUDE_SERVICES // Size Statistics void InstanceKlass::collect_statistics(KlassSizeStats *sz) const { Klass::collect_statistics(sz);