Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java
41152 views
1
/*
2
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
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 8204308
27
* @summary Test the jhsdb jmap -clstats command with CDS enabled
28
* @requires vm.hasSA & vm.cds
29
* @library /test/lib
30
* @run main/othervm/timeout=2400 CDSJMapClstats
31
*/
32
33
import java.util.stream.Collectors;
34
35
import jdk.test.lib.Utils;
36
import jdk.test.lib.cds.CDSTestUtils;
37
import jdk.test.lib.cds.CDSOptions;
38
import jdk.test.lib.apps.LingeredApp;
39
import jdk.test.lib.process.OutputAnalyzer;
40
import jdk.test.lib.process.ProcessTools;
41
import jdk.test.lib.JDKToolLauncher;
42
import jdk.test.lib.SA.SATestUtils;
43
44
public class CDSJMapClstats {
45
46
private static void runClstats(long lingeredAppPid) throws Exception {
47
48
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
49
launcher.addVMArgs(Utils.getTestJavaOpts());
50
launcher.addToolArg("jmap");
51
launcher.addToolArg("--clstats");
52
launcher.addToolArg("--pid");
53
launcher.addToolArg(Long.toString(lingeredAppPid));
54
55
ProcessBuilder processBuilder = SATestUtils.createProcessBuilder(launcher);
56
System.out.println(
57
processBuilder.command().stream().collect(Collectors.joining(" ")));
58
59
OutputAnalyzer SAOutput = ProcessTools.executeProcess(processBuilder);
60
System.out.println(SAOutput.getOutput());
61
SAOutput.shouldHaveExitValue(0);
62
SAOutput.shouldContain("BootClassLoader");
63
}
64
65
66
public static void main(String[] args) throws Exception {
67
System.out.println("Starting CDSJMapClstats test");
68
SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work.
69
String sharedArchiveName = "ArchiveForCDSJMapClstats.jsa";
70
LingeredApp theApp = null;
71
72
try {
73
CDSOptions opts = (new CDSOptions()).setArchiveName(sharedArchiveName);
74
CDSTestUtils.createArchiveAndCheck(opts);
75
76
theApp = LingeredApp.startApp(
77
"-XX:+UnlockDiagnosticVMOptions",
78
"-XX:SharedArchiveFile=" + sharedArchiveName,
79
"-Xshare:auto");
80
System.out.println("Started LingeredApp with pid " + theApp.getPid());
81
runClstats(theApp.getPid());
82
} catch (Exception ex) {
83
throw new RuntimeException("Test ERROR " + ex, ex);
84
} finally {
85
LingeredApp.stopApp(theApp);
86
}
87
System.out.println("Test PASSED");
88
}
89
}
90
91