本文整理汇总了C++中KlassInfoEntry::set_do_print方法的典型用法代码示例。如果您正苦于以下问题:C++ KlassInfoEntry::set_do_print方法的具体用法?C++ KlassInfoEntry::set_do_print怎么用?C++ KlassInfoEntry::set_do_print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KlassInfoEntry
的用法示例。
在下文中一共展示了KlassInfoEntry::set_do_print方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_class_hierarchy
void KlassHierarchy::print_class_hierarchy(outputStream* st, bool print_interfaces,
bool print_subclasses, char* classname) {
ResourceMark rm;
Stack <KlassInfoEntry*, mtClass> class_stack;
GrowableArray<KlassInfoEntry*> elements;
// Add all classes to the KlassInfoTable, which allows for quick lookup.
// A KlassInfoEntry will be created for each class.
KlassInfoTable cit(true);
if (cit.allocation_failed()) {
st->print_cr("ERROR: Ran out of C-heap; hierarchy not generated");
return;
}
// Add all created KlassInfoEntry instances to the elements array for easy
// iteration, and to allow each KlassInfoEntry instance to have a unique index.
HierarchyClosure hc(&elements);
cit.iterate(&hc);
for(int i = 0; i < elements.length(); i++) {
KlassInfoEntry* cie = elements.at(i);
const InstanceKlass* k = (InstanceKlass*)cie->klass();
Klass* super = ((InstanceKlass*)k)->java_super();
// Set the index for the class.
cie->set_index(i + 1);
// Add the class to the subclass array of its superclass.
if (super != NULL) {
KlassInfoEntry* super_cie = cit.lookup(super);
assert(super_cie != NULL, "could not lookup superclass");
super_cie->add_subclass(cie);
}
}
// Set the do_print flag for each class that should be printed.
for(int i = 0; i < elements.length(); i++) {
KlassInfoEntry* cie = elements.at(i);
if (classname == NULL) {
// We are printing all classes.
cie->set_do_print(true);
} else {
// We are only printing the hierarchy of a specific class.
if (strcmp(classname, cie->klass()->external_name()) == 0) {
KlassHierarchy::set_do_print_for_class_hierarchy(cie, &cit, print_subclasses);
}
}
}
// Now we do a depth first traversal of the class hierachry. The class_stack will
// maintain the list of classes we still need to process. Start things off
// by priming it with java.lang.Object.
KlassInfoEntry* jlo_cie = cit.lookup(SystemDictionary::Object_klass());
assert(jlo_cie != NULL, "could not lookup java.lang.Object");
class_stack.push(jlo_cie);
// Repeatedly pop the top item off the stack, print its class info,
// and push all of its subclasses on to the stack. Do this until there
// are no classes left on the stack.
while (!class_stack.is_empty()) {
KlassInfoEntry* curr_cie = class_stack.pop();
if (curr_cie->do_print()) {
print_class(st, curr_cie, print_interfaces);
if (curr_cie->subclasses() != NULL) {
// Current class has subclasses, so push all of them onto the stack.
for (int i = 0; i < curr_cie->subclasses()->length(); i++) {
KlassInfoEntry* cie = curr_cie->subclasses()->at(i);
if (cie->do_print()) {
class_stack.push(cie);
}
}
}
}
}
st->flush();
}