On Tue, 18 Jan 2022 02:50:06 GMT, Yi Yang <yy...@openjdk.org> wrote: >> Add VM.classes to print details of all classes, output looks like: >> >> 1. jcmd VM.classes >> >> KlassAddr Size State Flags LoaderName ClassName >> 0x0000000800c0b400 62 inited W bootstrap >> java.lang.invoke.LambdaForm$MH/0x0000000800c0b400 >> 0x0000000800c0b000 62 inited W bootstrap >> java.lang.invoke.LambdaForm$DMH/0x0000000800c0b000 >> 0x0000000800c0ac00 62 inited W bootstrap >> java.lang.invoke.LambdaForm$MH/0x0000000800c0ac00 >> ... >> >> 2. jcmd VM.classes verbose >> >> KlassAddr Size State Flags LoaderName ClassName >> 0x0000000800c0b400 62 inited W bootstrap >> java.lang.invoke.LambdaForm$MH/0x0000000800c0b400 >> java.lang.invoke.LambdaForm$MH/0x0000000800c0b400 {0x0000000800c0b400} >> - instance size: 2 >> - klass size: 62 >> - access: final synchronized >> - state: inited >> - name: 'java/lang/invoke/LambdaForm$MH+0x0000000800c0b400' >> - super: 'java/lang/Object' >> - sub: >> - arrays: NULL >> - methods: Array<T>(0x00007f620841f210) >> - method ordering: Array<T>(0x0000000800a7e5a8) >> - default_methods: Array<T>(0x0000000000000000) >> - local interfaces: Array<T>(0x00000008005af748) >> - trans. interfaces: Array<T>(0x00000008005af748) >> - constants: constant pool [41] {0x00007f620841f030} for >> 'java/lang/invoke/LambdaForm$MH+0x0000000800c0b400' cache=0x00007f620841f380 >> - class loader data: loader data: 0x00007f61c804a690 of 'bootstrap' has a >> class holder >> - source file: 'LambdaForm$MH' >> - class annotations: Array<T>(0x0000000000000000) >> - class type annotations: Array<T>(0x0000000000000000) >> - field annotations: Array<T>(0x0000000000000000) >> - field type annotations: Array<T>(0x0000000000000000) >> - inner classes: Array<T>(0x00000008005af6d8) >> - nest members: Array<T>(0x00000008005af6d8) >> - permitted subclasses: Array<T>(0x00000008005af6d8) >> - java mirror: a 'java/lang/Class'{0x000000011f4b3968} = >> 'java/lang/invoke/LambdaForm$MH+0x0000000800c0b400' >> - vtable length 5 (start addr: 0x0000000800c0b5b8) >> - itable length 2 (start addr: 0x0000000800c0b5e0) >> - ---- static fields (1 words): >> - static final '_D_0' 'Ljava/lang/invoke/LambdaForm;' @112 >> - ---- non-static fields (0 words): >> - non-static oop maps: >> 0x0000000800c0b000 62 inited W bootstrap >> java.lang.invoke.LambdaForm$DMH/0x0000000800c0b000 >> java.lang.invoke.LambdaForm$DMH/0x0000000800c0b000 {0x0000000800c0b000} >> - instance size: 2 >> - klass size: 62 >> - access: final synchronized >> - state: inited >> - name: 'java/lang/invoke/LambdaForm$DMH+0x0000000800c0b000' >> - super: 'java/lang/Object' >> - sub: >> - arrays: NULL >> - methods: Array<T>(0x00007f620841ea68) >> - method ordering: Array<T>(0x0000000800a7e5a8) >> - default_methods: Array<T>(0x0000000000000000) >> - local interfaces: Array<T>(0x00000008005af748) >> - trans. interfaces: Array<T>(0x00000008005af748) >> - constants: constant pool [49] {0x00007f620841e838} for >> 'java/lang/invoke/LambdaForm$DMH+0x0000000800c0b000' cache=0x00007f620841ebe0 >> - class loader data: loader data: 0x00007f61c804a750 of 'bootstrap' has a >> class holder >> - source file: 'LambdaForm$DMH' >> - class annotations: Array<T>(0x0000000000000000) >> - class type annotations: Array<T>(0x0000000000000000) >> - field annotations: Array<T>(0x0000000000000000) >> - field type annotations: Array<T>(0x0000000000000000) >> - inner classes: Array<T>(0x00000008005af6d8) >> - nest members: Array<T>(0x00000008005af6d8) >> - permitted subclasses: Array<T>(0x00000008005af6d8) >> - java mirror: a 'java/lang/Class'{0x000000011f4b0968} = >> 'java/lang/invoke/LambdaForm$DMH+0x0000000800c0b000' >> - vtable length 5 (start addr: 0x0000000800c0b1b8) >> - itable length 2 (start addr: 0x0000000800c0b1e0) >> - ---- static fields (1 words): >> - static final '_D_0' 'Ljava/lang/invoke/LambdaForm;' @112 >> - ---- non-static fields (0 words): >> ... > > Yi Yang has refreshed the contents of this pull request, and previous commits > have been removed. The incremental views will show differences compared to > the previous content of the PR. The pull request contains one new commit > since the last revision: > > 8275775 Add VM.classes to print details of all classes
Hi, This seems reasonable in general but a few details to work through - see comments below. Thanks, David src/hotspot/share/oops/instanceKlass.cpp line 2069: > 2067: ResourceMark rm; > 2068: _st->print("%-18s", "KlassAddr"); > 2069: _st->print(" "); Can't you just print the two spaces in the previous line: _st->print("%-18s ", "KlassAddr"); and save all the additional print calls. This applies throughout where you have " ". src/hotspot/share/oops/instanceKlass.cpp line 2085: > 2083: ResourceMark rm; > 2084: // klass pointer > 2085: _st->print("" INTPTR_FORMAT "", p2i(k)); Why do you need the two empty string literals ?? src/hotspot/share/oops/instanceKlass.cpp line 2100: > 2098: char buf[10]; > 2099: int i = 0; > 2100: if (k->has_finalizer()) buf[i++] = 'F'; Where is the meaning of these flags documented? src/hotspot/share/oops/instanceKlass.cpp line 2103: > 2101: if (k->has_final_method()) buf[i++] = 'f'; > 2102: if (k->has_vanilla_constructor()) buf[i++] = 'V'; > 2103: if (k->is_instance_klass()) { Don't the properties queried in L2100 to L2102 only apply to instance classes? src/hotspot/share/oops/instanceKlass.cpp line 3425: > 3423: > 3424: static const char* state_names[] = { > 3425: "alloc", "load", "link", "initing", "inited", "init_err" I don't like these short forms - they are mostly computerese not real words. Why can't we print the original full names? (Though I'd prefer "initializing" and "initialized" to "being_initialized" and "fully_initialized".) src/hotspot/share/services/diagnosticCommand.hpp line 870: > 868: } > 869: static const char* description() { > 870: return "Prints list of all loaded java classes"; s/java/Java/ src/hotspot/share/services/diagnosticCommand.hpp line 873: > 871: } > 872: static const char* impact() { > 873: return "Medium: Depends on Java content."; I would think impact is High due to the number of classes. ------------- Changes requested by dholmes (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/7105