hotspot/src/share/vm/prims/jvmtiGetLoadedClasses.cpp
changeset 14488 ab48109f7d1b
parent 13728 882756847a04
child 21183 e148e499e5cd
equal deleted inserted replaced
14486:7d079e0eedef 14488:ab48109f7d1b
   167 
   167 
   168   // Finally, the static methods that are the callbacks
   168   // Finally, the static methods that are the callbacks
   169   static void increment(Klass* k) {
   169   static void increment(Klass* k) {
   170     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   170     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   171     if (that->get_initiatingLoader() == NULL) {
   171     if (that->get_initiatingLoader() == NULL) {
   172       for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
   172       for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
   173         that->set_count(that->get_count() + 1);
   173         that->set_count(that->get_count() + 1);
   174       }
   174       }
   175     } else if (k != NULL) {
   175     } else if (k != NULL) {
   176       // if initiating loader not null, just include the instance with 1 dimension
   176       // if initiating loader not null, just include the instance with 1 dimension
   177       that->set_count(that->get_count() + 1);
   177       that->set_count(that->get_count() + 1);
   180 
   180 
   181   static void increment_with_loader(Klass* k, ClassLoaderData* loader_data) {
   181   static void increment_with_loader(Klass* k, ClassLoaderData* loader_data) {
   182     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   182     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   183     oop class_loader = loader_data->class_loader();
   183     oop class_loader = loader_data->class_loader();
   184     if (class_loader == JNIHandles::resolve(that->get_initiatingLoader())) {
   184     if (class_loader == JNIHandles::resolve(that->get_initiatingLoader())) {
   185       for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
   185       for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
   186         that->set_count(that->get_count() + 1);
   186         that->set_count(that->get_count() + 1);
   187       }
   187       }
   188     }
   188     }
   189   }
   189   }
   190 
   190 
   198 
   198 
   199   static void add(Klass* k) {
   199   static void add(Klass* k) {
   200     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   200     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   201     if (that->available()) {
   201     if (that->available()) {
   202       if (that->get_initiatingLoader() == NULL) {
   202       if (that->get_initiatingLoader() == NULL) {
   203         for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
   203         for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
   204           oop mirror = Klass::cast(l)->java_mirror();
   204           oop mirror = l->java_mirror();
   205           that->set_element(that->get_index(), mirror);
   205           that->set_element(that->get_index(), mirror);
   206           that->set_index(that->get_index() + 1);
   206           that->set_index(that->get_index() + 1);
   207         }
   207         }
   208       } else if (k != NULL) {
   208       } else if (k != NULL) {
   209         // if initiating loader not null, just include the instance with 1 dimension
   209         // if initiating loader not null, just include the instance with 1 dimension
   210         oop mirror = Klass::cast(k)->java_mirror();
   210         oop mirror = k->java_mirror();
   211         that->set_element(that->get_index(), mirror);
   211         that->set_element(that->get_index(), mirror);
   212         that->set_index(that->get_index() + 1);
   212         that->set_index(that->get_index() + 1);
   213       }
   213       }
   214     }
   214     }
   215   }
   215   }
   217   static void add_with_loader(Klass* k, ClassLoaderData* loader_data) {
   217   static void add_with_loader(Klass* k, ClassLoaderData* loader_data) {
   218     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   218     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   219     if (that->available()) {
   219     if (that->available()) {
   220       oop class_loader = loader_data->class_loader();
   220       oop class_loader = loader_data->class_loader();
   221       if (class_loader == JNIHandles::resolve(that->get_initiatingLoader())) {
   221       if (class_loader == JNIHandles::resolve(that->get_initiatingLoader())) {
   222         for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
   222         for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
   223           oop mirror = Klass::cast(l)->java_mirror();
   223           oop mirror = l->java_mirror();
   224           that->set_element(that->get_index(), mirror);
   224           that->set_element(that->get_index(), mirror);
   225           that->set_index(that->get_index() + 1);
   225           that->set_index(that->get_index() + 1);
   226         }
   226         }
   227       }
   227       }
   228     }
   228     }
   232   // multi-dimensional arrays). For example, for [B we check for
   232   // multi-dimensional arrays). For example, for [B we check for
   233   // [[B, [[[B, .. and the count is incremented for each one that exists.
   233   // [[B, [[[B, .. and the count is incremented for each one that exists.
   234   static void increment_for_basic_type_arrays(Klass* k) {
   234   static void increment_for_basic_type_arrays(Klass* k) {
   235     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   235     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   236     assert(that != NULL, "no JvmtiGetLoadedClassesClosure");
   236     assert(that != NULL, "no JvmtiGetLoadedClassesClosure");
   237     for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
   237     for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
   238       that->set_count(that->get_count() + 1);
   238       that->set_count(that->get_count() + 1);
   239     }
   239     }
   240   }
   240   }
   241 
   241 
   242   // add the basic type array class and its multi-dimensional array classes to the list
   242   // add the basic type array class and its multi-dimensional array classes to the list
   243   static void add_for_basic_type_arrays(Klass* k) {
   243   static void add_for_basic_type_arrays(Klass* k) {
   244     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   244     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
   245     assert(that != NULL, "no JvmtiGetLoadedClassesClosure");
   245     assert(that != NULL, "no JvmtiGetLoadedClassesClosure");
   246     assert(that->available(), "no list");
   246     assert(that->available(), "no list");
   247     for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
   247     for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
   248       oop mirror = Klass::cast(l)->java_mirror();
   248       oop mirror = l->java_mirror();
   249       that->set_element(that->get_index(), mirror);
   249       that->set_element(that->get_index(), mirror);
   250       that->set_index(that->get_index() + 1);
   250       that->set_index(that->get_index() + 1);
   251     }
   251     }
   252   }
   252   }
   253 };
   253 };