< prev index next >

src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp

Print this page
rev 50565 : [mq]: 8203343-VM.metaspace-show-reflection-invocation-targets


  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #include "precompiled.hpp"
  27 
  28 #include "classfile/classLoaderData.inline.hpp"
  29 #include "classfile/classLoaderHierarchyDCmd.hpp"
  30 #include "memory/allocation.hpp"
  31 #include "memory/resourceArea.hpp"
  32 #include "runtime/safepoint.hpp"

  33 #include "utilities/globalDefinitions.hpp"
  34 #include "utilities/ostream.hpp"
  35 
  36 
  37 ClassLoaderHierarchyDCmd::ClassLoaderHierarchyDCmd(outputStream* output, bool heap)
  38   : DCmdWithParser(output, heap)
  39   , _show_classes("show-classes", "Print loaded classes.", "BOOLEAN", false, "false")
  40   , _verbose("verbose", "Print detailed information.", "BOOLEAN", false, "false") {
  41   _dcmdparser.add_dcmd_option(&_show_classes);
  42   _dcmdparser.add_dcmd_option(&_verbose);
  43 }
  44 
  45 
  46 int ClassLoaderHierarchyDCmd::num_arguments() {
  47   ResourceMark rm;
  48   ClassLoaderHierarchyDCmd* dcmd = new ClassLoaderHierarchyDCmd(NULL, false);
  49   if (dcmd != NULL) {
  50     DCmdMark mark(dcmd);
  51     return dcmd->_dcmdparser.num_arguments();
  52   } else {


 185       BranchTracker::Mark trm(branchtracker, have_child);
 186 
 187       // Empty line
 188       branchtracker.print(st);
 189       st->cr();
 190 
 191       const int indentation = 18;
 192 
 193       if (verbose) {
 194         branchtracker.print(st);
 195         st->print_cr("%*s " PTR_FORMAT, indentation, "Loader Data:", p2i(_cld));
 196         branchtracker.print(st);
 197         st->print_cr("%*s " PTR_FORMAT, indentation, "Loader Klass:", p2i(loader_klass));
 198 
 199         // Empty line
 200         branchtracker.print(st);
 201         st->cr();
 202       }
 203 
 204       if (print_classes) {
 205 
 206         if (_classes != NULL) {
 207           for (LoadedClassInfo* lci = _classes; lci; lci = lci->_next) {



 208             branchtracker.print(st);
 209             if (lci == _classes) { // first iteration
 210               st->print("%*s ", indentation, "Classes:");
 211             } else {
 212               st->print("%*s ", indentation, "");
 213             }
 214             st->print("%s", lci->_klass->external_name());








 215             st->cr();
 216             // Non-anonymous classes should live in the primary CLD of its loader
 217             assert(lci->_cld == _cld, "must be");
 218           }
 219           branchtracker.print(st);
 220           st->print("%*s ", indentation, "");
 221           st->print_cr("(%u class%s)", _num_classes, (_num_classes == 1) ? "" : "es");
 222 
 223           // Empty line
 224           branchtracker.print(st);
 225           st->cr();
 226         }
 227 
 228         if (_anon_classes != NULL) {
 229           for (LoadedClassInfo* lci = _anon_classes; lci; lci = lci->_next) {
 230             branchtracker.print(st);
 231             if (lci == _anon_classes) { // first iteration
 232               st->print("%*s ", indentation, "Anonymous Classes:");
 233             } else {
 234               st->print("%*s ", indentation, "");
 235             }
 236             st->print("%s", lci->_klass->external_name());
 237             // For anonymous classes, also print CLD if verbose. Should be a different one than the primary CLD.




  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #include "precompiled.hpp"
  27 
  28 #include "classfile/classLoaderData.inline.hpp"
  29 #include "classfile/classLoaderHierarchyDCmd.hpp"
  30 #include "memory/allocation.hpp"
  31 #include "memory/resourceArea.hpp"
  32 #include "runtime/safepoint.hpp"
  33 #include "oops/reflectionAccessorImplKlassHelper.hpp"
  34 #include "utilities/globalDefinitions.hpp"
  35 #include "utilities/ostream.hpp"
  36 
  37 
  38 ClassLoaderHierarchyDCmd::ClassLoaderHierarchyDCmd(outputStream* output, bool heap)
  39   : DCmdWithParser(output, heap)
  40   , _show_classes("show-classes", "Print loaded classes.", "BOOLEAN", false, "false")
  41   , _verbose("verbose", "Print detailed information.", "BOOLEAN", false, "false") {
  42   _dcmdparser.add_dcmd_option(&_show_classes);
  43   _dcmdparser.add_dcmd_option(&_verbose);
  44 }
  45 
  46 
  47 int ClassLoaderHierarchyDCmd::num_arguments() {
  48   ResourceMark rm;
  49   ClassLoaderHierarchyDCmd* dcmd = new ClassLoaderHierarchyDCmd(NULL, false);
  50   if (dcmd != NULL) {
  51     DCmdMark mark(dcmd);
  52     return dcmd->_dcmdparser.num_arguments();
  53   } else {


 186       BranchTracker::Mark trm(branchtracker, have_child);
 187 
 188       // Empty line
 189       branchtracker.print(st);
 190       st->cr();
 191 
 192       const int indentation = 18;
 193 
 194       if (verbose) {
 195         branchtracker.print(st);
 196         st->print_cr("%*s " PTR_FORMAT, indentation, "Loader Data:", p2i(_cld));
 197         branchtracker.print(st);
 198         st->print_cr("%*s " PTR_FORMAT, indentation, "Loader Klass:", p2i(loader_klass));
 199 
 200         // Empty line
 201         branchtracker.print(st);
 202         st->cr();
 203       }
 204 
 205       if (print_classes) {

 206         if (_classes != NULL) {
 207           for (LoadedClassInfo* lci = _classes; lci; lci = lci->_next) {
 208             // Non-anonymous classes should live in the primary CLD of its loader
 209             assert(lci->_cld == _cld, "must be");
 210 
 211             branchtracker.print(st);
 212             if (lci == _classes) { // first iteration
 213               st->print("%*s ", indentation, "Classes:");
 214             } else {
 215               st->print("%*s ", indentation, "");
 216             }
 217             st->print("%s", lci->_klass->external_name());
 218 
 219             // Special treatment for generated core reflection accessor classes: print invocation target.
 220             if (ReflectionAccessorImplKlassHelper::is_generated_accessor(lci->_klass)) {
 221               st->print(" (invokes: ");
 222               ReflectionAccessorImplKlassHelper::print_invocation_target(st, lci->_klass);
 223               st->print(")");
 224             }
 225 
 226             st->cr();


 227           }
 228           branchtracker.print(st);
 229           st->print("%*s ", indentation, "");
 230           st->print_cr("(%u class%s)", _num_classes, (_num_classes == 1) ? "" : "es");
 231 
 232           // Empty line
 233           branchtracker.print(st);
 234           st->cr();
 235         }
 236 
 237         if (_anon_classes != NULL) {
 238           for (LoadedClassInfo* lci = _anon_classes; lci; lci = lci->_next) {
 239             branchtracker.print(st);
 240             if (lci == _anon_classes) { // first iteration
 241               st->print("%*s ", indentation, "Anonymous Classes:");
 242             } else {
 243               st->print("%*s ", indentation, "");
 244             }
 245             st->print("%s", lci->_klass->external_name());
 246             // For anonymous classes, also print CLD if verbose. Should be a different one than the primary CLD.


< prev index next >