Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/runtime/CommandLine/PrintTouchedMethods.java
40942 views
1
/*
2
* Copyright (c) 2015, 2016, 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 8025692
27
* @modules java.base/jdk.internal.misc
28
* java.management
29
* @library /test/lib
30
* @compile TestLogTouchedMethods.java PrintTouchedMethods.java
31
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+LogTouchedMethods PrintTouchedMethods
32
*/
33
34
import java.io.File;
35
import java.util.List;
36
import jdk.test.lib.process.ProcessTools;
37
import jdk.test.lib.process.OutputAnalyzer;
38
import jdk.test.lib.JDKToolFinder;
39
40
public class PrintTouchedMethods {
41
42
public static void main(String args[]) throws Exception {
43
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
44
"-XX:-UnlockDiagnosticVMOptions",
45
"-XX:+LogTouchedMethods",
46
"-XX:+PrintTouchedMethodsAtExit",
47
"TestLogTouchedMethods");
48
49
// UnlockDiagnostic turned off, should fail
50
OutputAnalyzer output = new OutputAnalyzer(pb.start());
51
output.shouldContain("Error: VM option 'LogTouchedMethods' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.");
52
output.shouldContain("Error: Could not create the Java Virtual Machine.");
53
54
pb = ProcessTools.createJavaProcessBuilder(
55
"-XX:+UnlockDiagnosticVMOptions",
56
"-XX:+LogTouchedMethods",
57
"-XX:+PrintTouchedMethodsAtExit",
58
"TestLogTouchedMethods");
59
output = new OutputAnalyzer(pb.start());
60
// check order:
61
// 1 "# Method::print_touched_methods version 1" is the first in first line
62
// 2 should contain TestLogMethods.methodA:()V
63
// 3 should not contain TestLogMethods.methodB:()V
64
// Repeat above for another run with -Xint
65
List<String> lines = output.asLines();
66
67
if (lines.size() < 1) {
68
throw new Exception("Empty output");
69
}
70
71
String first = lines.get(0);
72
if (!first.equals("# Method::print_touched_methods version 1")) {
73
throw new Exception("First line mismatch");
74
}
75
76
output.shouldContain("TestLogTouchedMethods.methodA:()V");
77
output.shouldNotContain("TestLogTouchedMethods.methodB:()V");
78
output.shouldHaveExitValue(0);
79
80
pb = ProcessTools.createJavaProcessBuilder(
81
"-XX:+UnlockDiagnosticVMOptions",
82
"-Xint",
83
"-XX:+LogTouchedMethods",
84
"-XX:+PrintTouchedMethodsAtExit",
85
"TestLogTouchedMethods");
86
output = new OutputAnalyzer(pb.start());
87
lines = output.asLines();
88
89
if (lines.size() < 1) {
90
throw new Exception("Empty output");
91
}
92
93
first = lines.get(0);
94
if (!first.equals("# Method::print_touched_methods version 1")) {
95
throw new Exception("First line mismatch");
96
}
97
98
output.shouldContain("TestLogTouchedMethods.methodA:()V");
99
output.shouldNotContain("TestLogTouchedMethods.methodB:()V");
100
output.shouldHaveExitValue(0);
101
102
pb = ProcessTools.createJavaProcessBuilder(
103
"-XX:+UnlockDiagnosticVMOptions",
104
"-Xint",
105
"-XX:+LogTouchedMethods",
106
"-XX:+PrintTouchedMethodsAtExit",
107
"-XX:-TieredCompilation",
108
"TestLogTouchedMethods");
109
output = new OutputAnalyzer(pb.start());
110
lines = output.asLines();
111
112
if (lines.size() < 1) {
113
throw new Exception("Empty output");
114
}
115
116
first = lines.get(0);
117
if (!first.equals("# Method::print_touched_methods version 1")) {
118
throw new Exception("First line mismatch");
119
}
120
121
output.shouldContain("TestLogTouchedMethods.methodA:()V");
122
output.shouldNotContain("TestLogTouchedMethods.methodB:()V");
123
output.shouldHaveExitValue(0);
124
125
// Test jcmd PrintTouchedMethods VM.print_touched_methods
126
String pid = Long.toString(ProcessTools.getProcessId());
127
pb = new ProcessBuilder();
128
pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.print_touched_methods"});
129
output = new OutputAnalyzer(pb.start());
130
try {
131
output.shouldContain("PrintTouchedMethods.main:([Ljava/lang/String;)V");
132
} catch (RuntimeException e) {
133
output.shouldContain("Unknown diagnostic command");
134
}
135
}
136
}
137
138