author | goetz |
Thu, 03 Aug 2017 10:24:34 +0200 | |
changeset 46779 | d80ca591ae48 |
parent 46747 | 7b6570052b58 |
child 46782 | 0405d7196df4 |
permissions | -rw-r--r-- |
46747
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
1 |
/* |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
4 |
* |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
8 |
* |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
14 |
* |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
18 |
* |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
21 |
* questions. |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
22 |
*/ |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
23 |
|
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
24 |
/* |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
25 |
* @test |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
26 |
* @bug 8130072 |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
27 |
* @summary Check that Shared Dictionary is printed out with jcmd |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
28 |
* Feature support: compressed oops/kptrs, 64-bit os, not on windows |
46779
d80ca591ae48
8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents:
46747
diff
changeset
|
29 |
* @requires vm.cds |
46747
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
30 |
* @requires (sun.arch.data.model != "32") & (os.family != "windows") |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
31 |
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true) |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
32 |
* @library /test/lib |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
33 |
* @modules java.base/jdk.internal.misc |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
34 |
* @run main DumpSharedDictionary |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
35 |
*/ |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
36 |
|
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
37 |
import jdk.test.lib.cds.CDSTestUtils; |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
38 |
import jdk.test.lib.process.ProcessTools; |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
39 |
import jdk.test.lib.process.OutputAnalyzer; |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
40 |
import jdk.test.lib.JDKToolFinder; |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
41 |
|
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
42 |
public class DumpSharedDictionary { |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
43 |
|
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
44 |
public static void main(String[] args) throws Exception { |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
45 |
if (args.length == 0) { |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
46 |
// Start this process |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
47 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
48 |
"-XX:+UnlockDiagnosticVMOptions", |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
49 |
"-XX:SharedArchiveFile=./DumpSharedDictionary.jsa", |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
50 |
"-XX:+UseCompressedOops", |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
51 |
"-Xshare:dump"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
52 |
|
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
53 |
OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "dump"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
54 |
out.shouldHaveExitValue(0); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
55 |
|
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
56 |
String testjdkPath = System.getProperty("test.jdk"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
57 |
|
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
58 |
pb = ProcessTools.createJavaProcessBuilder( |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
59 |
"-XX:+UnlockDiagnosticVMOptions", |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
60 |
"-XX:SharedArchiveFile=./DumpSharedDictionary.jsa", |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
61 |
"-XX:+UseCompressedOops", |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
62 |
"-Dtest.jdk=" + testjdkPath, |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
63 |
"-Xshare:on", "DumpSharedDictionary", "test"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
64 |
|
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
65 |
out = CDSTestUtils.executeAndLog(pb, "exec"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
66 |
out.shouldHaveExitValue(0); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
67 |
} else { |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
68 |
// Grab my own PID |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
69 |
String pid = Long.toString(ProcessTools.getProcessId()); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
70 |
|
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
71 |
ProcessBuilder pb = new ProcessBuilder(); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
72 |
pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.systemdictionary"}); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
73 |
OutputAnalyzer output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
74 |
try { |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
75 |
output.shouldContain("Shared Dictionary statistics:"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
76 |
output.shouldContain("Number of buckets"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
77 |
output.shouldContain("Number of entries"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
78 |
output.shouldContain("Maximum bucket size"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
79 |
} catch (RuntimeException e) { |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
80 |
output.shouldContain("Unknown diagnostic command"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
81 |
} |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
82 |
|
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
83 |
pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.systemdictionary", "-verbose"}); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
84 |
output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary-verbose"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
85 |
try { |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
86 |
output.shouldContain("Shared Dictionary"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
87 |
output.shouldContain("Dictionary for class loader 0x"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
88 |
output.shouldContain("^java.lang.String"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
89 |
} catch (RuntimeException e) { |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
90 |
output.shouldContain("Unknown diagnostic command"); |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
91 |
} |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
92 |
} |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
93 |
} |
7b6570052b58
8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff
changeset
|
94 |
} |