Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbClasses.java
41152 views
1
/*
2
* Copyright (c) 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
import java.util.HashMap;
25
import java.util.List;
26
import java.util.Map;
27
28
import jdk.test.lib.apps.LingeredApp;
29
import jtreg.SkippedException;
30
31
/**
32
* @test
33
* @bug 8242142
34
* @summary Test clhsdb class and classes commands
35
* @requires vm.hasSA
36
* @library /test/lib
37
* @run main/othervm ClhsdbClasses
38
*/
39
40
public class ClhsdbClasses {
41
static final String APP_DOT_CLASSNAME = LingeredApp.class.getName();
42
static final String APP_SLASH_CLASSNAME = APP_DOT_CLASSNAME.replace('.', '/');
43
44
public static void main(String[] args) throws Exception {
45
System.out.println("Starting ClhsdbClasses test");
46
47
LingeredApp theApp = null;
48
try {
49
ClhsdbLauncher test = new ClhsdbLauncher();
50
String classCmdOutput;
51
52
theApp = LingeredApp.startApp();
53
System.out.println("Started LingeredApp with pid " + theApp.getPid());
54
55
// Run "class jdk/test/lib/apps/LingeredApp"
56
{
57
String cmd = "class " + APP_SLASH_CLASSNAME;
58
List<String> cmds = List.of(cmd);
59
Map<String, List<String>> expStrMap = new HashMap<>();
60
expStrMap.put(cmd, List.of(APP_SLASH_CLASSNAME + " @0x"));
61
classCmdOutput = test.run(theApp.getPid(), cmds, expStrMap, null);
62
}
63
64
// Run "print <addr>" on the address printed above for LingeredApp. Also
65
// run "classes" command to verify LingeredApp and java.lang.Class are
66
// in the list of classes. Note we can't do the above "class LingeredApp"
67
// command as part of this command because then we won't have the address
68
// for the LingeredApp class, which we need for the print command and also
69
// to verify it matches the address in the classes commands.
70
{
71
String classAddress = classCmdOutput.substring(classCmdOutput.indexOf("@0x")+1);
72
String[] lines = classAddress.split("\\R");
73
classAddress = lines[0];
74
String printCmd = "print " + classAddress;
75
String classesCmd = "classes";
76
List<String> cmds = List.of(printCmd, classesCmd);
77
Map<String, List<String>> expStrMap = new HashMap<>();
78
expStrMap.put(printCmd,
79
List.of("public class " + APP_DOT_CLASSNAME + " @" + classAddress));
80
expStrMap.put(classesCmd, List.of(
81
APP_SLASH_CLASSNAME + " @" + classAddress, // check for app class at right address
82
"java/lang/Class @0x", // check for java/lang/Class
83
"java/lang/Object @0x", // check for java/lang/Object
84
"java/lang/Cloneable @0x", // check for an interface type
85
"\\[Ljava/lang/String; @0x", // check for array type
86
"\\[J @0x", "\\[I @0x", "\\[Z @0x")); // check for array of a few pimitive types
87
test.run(theApp.getPid(), cmds, expStrMap, null);
88
}
89
} catch (SkippedException se) {
90
throw se;
91
} catch (Exception ex) {
92
throw new RuntimeException("Test ERROR " + ex, ex);
93
} finally {
94
LingeredApp.stopApp(theApp);
95
}
96
System.out.println("Test PASSED");
97
}
98
}
99
100