42 //
43 // Instances of java.lang.ClassLoader holds a pointer to a ClassLoaderData that
44 // that represent the loader's "linking domain" in the JVM.
45 //
46 // The bootstrap loader (represented by NULL) also has a ClassLoaderData,
47 // the singleton class the_null_class_loader_data().
48
49 #include "precompiled.hpp"
50 #include "classfile/classLoaderData.inline.hpp"
51 #include "classfile/classLoaderDataGraph.inline.hpp"
52 #include "classfile/dictionary.hpp"
53 #include "classfile/javaClasses.hpp"
54 #include "classfile/moduleEntry.hpp"
55 #include "classfile/packageEntry.hpp"
56 #include "classfile/symbolTable.hpp"
57 #include "classfile/systemDictionary.hpp"
58 #include "logging/log.hpp"
59 #include "logging/logStream.hpp"
60 #include "memory/allocation.inline.hpp"
61 #include "memory/metadataFactory.hpp"
62 #include "memory/resourceArea.hpp"
63 #include "memory/universe.hpp"
64 #include "oops/access.inline.hpp"
65 #include "oops/oop.inline.hpp"
66 #include "oops/oopHandle.inline.hpp"
67 #include "oops/weakHandle.inline.hpp"
68 #include "runtime/atomic.hpp"
69 #include "runtime/handles.inline.hpp"
70 #include "runtime/mutex.hpp"
71 #include "runtime/safepoint.hpp"
72 #include "utilities/growableArray.hpp"
73 #include "utilities/macros.hpp"
74 #include "utilities/ostream.hpp"
75
76 ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
77
78 void ClassLoaderData::init_null_class_loader_data() {
79 assert(_the_null_class_loader_data == NULL, "cannot initialize twice");
80 assert(ClassLoaderDataGraph::_head == NULL, "cannot initialize twice");
81
933
934 if (_jmethod_ids != NULL) {
935 Method::print_jmethod_ids(this, out);
936 }
937 out->print(" handles count %d", _handles.count());
938 out->print(" dependencies %d", _dependency_count);
939 out->print_cr("}");
940 }
941 #endif // PRODUCT
942
943 void ClassLoaderData::print() const { print_on(tty); }
944
945 void ClassLoaderData::verify() {
946 assert_locked_or_safepoint(_metaspace_lock);
947 oop cl = class_loader();
948
949 guarantee(this == class_loader_data(cl) || has_class_mirror_holder(), "Must be the same");
950 guarantee(cl != NULL || this == ClassLoaderData::the_null_class_loader_data() || has_class_mirror_holder(), "must be");
951
952 // Verify the integrity of the allocated space.
953 if (metaspace_or_null() != NULL) {
954 metaspace_or_null()->verify();
955 }
956
957 for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
958 guarantee(k->class_loader_data() == this, "Must be the same");
959 k->verify();
960 assert(k != k->next_link(), "no loops!");
961 }
962 }
963
964 bool ClassLoaderData::contains_klass(Klass* klass) {
965 // Lock-free access requires load_acquire
966 for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
967 if (k == klass) return true;
968 }
969 return false;
970 }
|
42 //
43 // Instances of java.lang.ClassLoader holds a pointer to a ClassLoaderData that
44 // that represent the loader's "linking domain" in the JVM.
45 //
46 // The bootstrap loader (represented by NULL) also has a ClassLoaderData,
47 // the singleton class the_null_class_loader_data().
48
49 #include "precompiled.hpp"
50 #include "classfile/classLoaderData.inline.hpp"
51 #include "classfile/classLoaderDataGraph.inline.hpp"
52 #include "classfile/dictionary.hpp"
53 #include "classfile/javaClasses.hpp"
54 #include "classfile/moduleEntry.hpp"
55 #include "classfile/packageEntry.hpp"
56 #include "classfile/symbolTable.hpp"
57 #include "classfile/systemDictionary.hpp"
58 #include "logging/log.hpp"
59 #include "logging/logStream.hpp"
60 #include "memory/allocation.inline.hpp"
61 #include "memory/metadataFactory.hpp"
62 #include "memory/metaspace.hpp"
63 #include "memory/resourceArea.hpp"
64 #include "memory/universe.hpp"
65 #include "oops/access.inline.hpp"
66 #include "oops/oop.inline.hpp"
67 #include "oops/oopHandle.inline.hpp"
68 #include "oops/weakHandle.inline.hpp"
69 #include "runtime/atomic.hpp"
70 #include "runtime/handles.inline.hpp"
71 #include "runtime/mutex.hpp"
72 #include "runtime/safepoint.hpp"
73 #include "utilities/growableArray.hpp"
74 #include "utilities/macros.hpp"
75 #include "utilities/ostream.hpp"
76
77 ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
78
79 void ClassLoaderData::init_null_class_loader_data() {
80 assert(_the_null_class_loader_data == NULL, "cannot initialize twice");
81 assert(ClassLoaderDataGraph::_head == NULL, "cannot initialize twice");
82
934
935 if (_jmethod_ids != NULL) {
936 Method::print_jmethod_ids(this, out);
937 }
938 out->print(" handles count %d", _handles.count());
939 out->print(" dependencies %d", _dependency_count);
940 out->print_cr("}");
941 }
942 #endif // PRODUCT
943
944 void ClassLoaderData::print() const { print_on(tty); }
945
946 void ClassLoaderData::verify() {
947 assert_locked_or_safepoint(_metaspace_lock);
948 oop cl = class_loader();
949
950 guarantee(this == class_loader_data(cl) || has_class_mirror_holder(), "Must be the same");
951 guarantee(cl != NULL || this == ClassLoaderData::the_null_class_loader_data() || has_class_mirror_holder(), "must be");
952
953 // Verify the integrity of the allocated space.
954 #ifdef ASSERT
955 if (metaspace_or_null() != NULL) {
956 metaspace_or_null()->verify();
957 }
958 #endif
959
960 for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
961 guarantee(k->class_loader_data() == this, "Must be the same");
962 k->verify();
963 assert(k != k->next_link(), "no loops!");
964 }
965 }
966
967 bool ClassLoaderData::contains_klass(Klass* klass) {
968 // Lock-free access requires load_acquire
969 for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
970 if (k == klass) return true;
971 }
972 return false;
973 }
|