< prev index next >

test/hotspot/jtreg/runtime/cds/DumpSymbolAndStringTable.java

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8059510
  27  * @summary Test jcmd VM.symboltable, VM.stringtable and VM.systemdictionary options
  28  * @library /test/lib
  29  * @run main/othervm -XX:+UnlockDiagnosticVMOptions DumpSymbolAndStringTable
  30  */
  31 import jdk.test.lib.cds.CDSTestUtils;
  32 import jdk.test.lib.process.ProcessTools;
  33 import jdk.test.lib.process.OutputAnalyzer;
  34 import jdk.test.lib.JDKToolFinder;
  35 
  36 public class DumpSymbolAndStringTable {

  37     public static void main(String[] args) throws Exception {
  38         // Grab my own PID
  39         String pid = Long.toString(ProcessTools.getProcessId());
  40 
  41         ProcessBuilder pb = new ProcessBuilder();
  42         pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.symboltable", "-verbose"});
  43         OutputAnalyzer output = CDSTestUtils.executeAndLog(pb, "jcmd-symboltable");
  44         try {
  45             output.shouldContain("24 2: DumpSymbolAndStringTable\n");
  46         } catch (RuntimeException e) {
  47             output.shouldContain("Unknown diagnostic command");
  48         }
  49 
  50         pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.stringtable", "-verbose"});
  51         output = CDSTestUtils.executeAndLog(pb, "jcmd-stringtable");
  52         try {
  53             output.shouldContain("16: java.lang.String\n");
  54         } catch (RuntimeException e) {
  55             output.shouldContain("Unknown diagnostic command");
  56         }
  57 
  58         pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.systemdictionary"});
  59         output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary");
  60         try {
  61             output.shouldContain("System Dictionary for 'app' class loader statistics:");
  62             output.shouldContain("Number of buckets");
  63             output.shouldContain("Number of entries");
  64             output.shouldContain("Maximum bucket size");
  65         } catch (RuntimeException e) {
  66             output.shouldContain("Unknown diagnostic command");
  67         }
  68 
  69         pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.systemdictionary", "-verbose"});
  70         output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary");
  71         try {
  72             output.shouldContain("Dictionary for loader data: 0x");
  73             output.shouldContain("^java.lang.String");


  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8059510
  27  * @summary Test jcmd VM.symboltable, VM.stringtable and VM.systemdictionary options
  28  * @library /test/lib
  29  * @run main/othervm -XX:+UnlockDiagnosticVMOptions DumpSymbolAndStringTable
  30  */
  31 import jdk.test.lib.cds.CDSTestUtils;
  32 import jdk.test.lib.process.ProcessTools;
  33 import jdk.test.lib.process.OutputAnalyzer;
  34 import jdk.test.lib.JDKToolFinder;
  35 
  36 public class DumpSymbolAndStringTable {
  37     private static final String my_string = "DumpSymbolAndStringTable";
  38     public static void main(String[] args) throws Exception {
  39         // Grab my own PID
  40         String pid = Long.toString(ProcessTools.getProcessId());
  41 
  42         ProcessBuilder pb = new ProcessBuilder();
  43         pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.symboltable", "-verbose"});
  44         OutputAnalyzer output = CDSTestUtils.executeAndLog(pb, "jcmd-symboltable");
  45         try {
  46             output.shouldContain("24 2: DumpSymbolAndStringTable\n");
  47         } catch (RuntimeException e) {
  48             output.shouldContain("Unknown diagnostic command");
  49         }
  50 
  51         pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.stringtable", "-verbose"});
  52         output = CDSTestUtils.executeAndLog(pb, "jcmd-stringtable");
  53         try {
  54             output.shouldContain("24: DumpSymbolAndStringTable");
  55         } catch (RuntimeException e) {
  56             output.shouldContain("Unknown diagnostic command");
  57         }
  58 
  59         pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.systemdictionary"});
  60         output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary");
  61         try {
  62             output.shouldContain("System Dictionary for 'app' class loader statistics:");
  63             output.shouldContain("Number of buckets");
  64             output.shouldContain("Number of entries");
  65             output.shouldContain("Maximum bucket size");
  66         } catch (RuntimeException e) {
  67             output.shouldContain("Unknown diagnostic command");
  68         }
  69 
  70         pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.systemdictionary", "-verbose"});
  71         output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary");
  72         try {
  73             output.shouldContain("Dictionary for loader data: 0x");
  74             output.shouldContain("^java.lang.String");
< prev index next >