test/hotspot/jtreg/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java
author coleenp
Tue, 06 Mar 2018 17:15:16 -0500
changeset 49348 fde3feaaa4ed
parent 47216 71c04702a3d5
child 50634 c349d409262a
permissions -rw-r--r--
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles Summary: Move dependency creation and cleaned up logging Reviewed-by: hseigel, jiangli
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
     1
/*
49348
fde3feaaa4ed 8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
     4
 *
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
     7
 * published by the Free Software Foundation.
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
     8
 *
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    13
 * accompanied this code).
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    14
 *
41705
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    18
 *
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    21
 * questions.
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    22
 */
41705
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    23
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    24
/*
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    25
 * @test
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    26
 * @bug 8059510
46747
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents: 46742
diff changeset
    27
 * @summary Test jcmd VM.symboltable, VM.stringtable and VM.systemdictionary options
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38089
diff changeset
    28
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 30604
diff changeset
    29
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28363
diff changeset
    30
 *          java.management
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    31
 * @run main/othervm -XX:+UnlockDiagnosticVMOptions DumpSymbolAndStringTable
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    32
 */
46491
e43953993af3 8180631: [TESTBUG] CDS tests should use CDSTestUtils.executeAndLog whenever spawning sub processes
mseledtsov
parents: 41705
diff changeset
    33
import jdk.test.lib.cds.CDSTestUtils;
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38089
diff changeset
    34
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38089
diff changeset
    35
import jdk.test.lib.process.OutputAnalyzer;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38089
diff changeset
    36
import jdk.test.lib.JDKToolFinder;
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    37
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    38
public class DumpSymbolAndStringTable {
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    39
    public static void main(String[] args) throws Exception {
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    40
        // Grab my own PID
38089
9e58203ef0e2 8153992: Some hotspot tests fail on compact2 due to an unnecessary test library dependency
akulyakh
parents: 36851
diff changeset
    41
        String pid = Long.toString(ProcessTools.getProcessId());
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    42
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    43
        ProcessBuilder pb = new ProcessBuilder();
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    44
        pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.symboltable", "-verbose"});
46491
e43953993af3 8180631: [TESTBUG] CDS tests should use CDSTestUtils.executeAndLog whenever spawning sub processes
mseledtsov
parents: 41705
diff changeset
    45
        OutputAnalyzer output = CDSTestUtils.executeAndLog(pb, "jcmd-symboltable");
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    46
        try {
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    47
            output.shouldContain("24 2: DumpSymbolAndStringTable\n");
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    48
        } catch (RuntimeException e) {
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    49
            output.shouldContain("Unknown diagnostic command");
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    50
        }
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    51
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    52
        pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.stringtable", "-verbose"});
46491
e43953993af3 8180631: [TESTBUG] CDS tests should use CDSTestUtils.executeAndLog whenever spawning sub processes
mseledtsov
parents: 41705
diff changeset
    53
        output = CDSTestUtils.executeAndLog(pb, "jcmd-stringtable");
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    54
        try {
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    55
            output.shouldContain("16: java.lang.String\n");
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    56
        } catch (RuntimeException e) {
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    57
            output.shouldContain("Unknown diagnostic command");
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    58
        }
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    59
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    60
        pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.systemdictionary"});
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    61
        output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    62
        try {
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    63
            output.shouldContain("System Dictionary for jdk/internal/loader/ClassLoaders$AppClassLoader statistics:");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    64
            output.shouldContain("Number of buckets");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    65
            output.shouldContain("Number of entries");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    66
            output.shouldContain("Maximum bucket size");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    67
        } catch (RuntimeException e) {
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    68
            output.shouldContain("Unknown diagnostic command");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    69
        }
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    70
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    71
        pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.systemdictionary", "-verbose"});
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    72
        output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    73
        try {
49348
fde3feaaa4ed 8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents: 47216
diff changeset
    74
            output.shouldContain("Dictionary for loader data: 0x");
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    75
            output.shouldContain("^java.lang.String");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    76
        } catch (RuntimeException e) {
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    77
            output.shouldContain("Unknown diagnostic command");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46491
diff changeset
    78
        }
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    79
    }
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff changeset
    80
}