Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/runtime/CommandLine/PrintTouchedMethods.java
64474 views
1
/*
2
* Copyright (c) 2015, 2021, 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 8273333
27
* @requires vm.flavor != "zero"
28
* @modules java.base/jdk.internal.misc
29
* java.management
30
* @library /test/lib
31
* @run driver 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.class.getName());
48
49
// UnlockDiagnostic turned off, should fail
50
OutputAnalyzer output = new OutputAnalyzer(pb.start());
51
output.shouldNotHaveExitValue(0);
52
output.shouldContain("Error: VM option 'LogTouchedMethods' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.");
53
output.shouldContain("Error: Could not create the Java Virtual Machine.");
54
55
pb = ProcessTools.createJavaProcessBuilder(
56
"-XX:+UnlockDiagnosticVMOptions",
57
"-XX:+LogTouchedMethods",
58
"-XX:+PrintTouchedMethodsAtExit",
59
TestLogTouchedMethods.class.getName());
60
output = new OutputAnalyzer(pb.start());
61
// check order:
62
// 1 "# Method::print_touched_methods version 1" is the first in first line
63
// 2 should contain TestLogMethods.methodA:()V
64
// 3 should not contain TestLogMethods.methodB:()V
65
// Repeat above for another run with -Xint
66
List<String> lines = output.asLines();
67
68
if (lines.size() < 1) {
69
throw new Exception("Empty output");
70
}
71
72
String first = lines.get(0);
73
if (!first.equals("# Method::print_touched_methods version 1")) {
74
throw new Exception("First line mismatch");
75
}
76
77
output.shouldContain("TestLogTouchedMethods.methodA:()V");
78
output.shouldNotContain("TestLogTouchedMethods.methodB:()V");
79
output.shouldHaveExitValue(0);
80
81
pb = ProcessTools.createJavaProcessBuilder(
82
"-XX:+UnlockDiagnosticVMOptions",
83
"-Xint",
84
"-XX:+LogTouchedMethods",
85
"-XX:+PrintTouchedMethodsAtExit",
86
TestLogTouchedMethods.class.getName());
87
output = new OutputAnalyzer(pb.start());
88
lines = output.asLines();
89
90
if (lines.size() < 1) {
91
throw new Exception("Empty output");
92
}
93
94
first = lines.get(0);
95
if (!first.equals("# Method::print_touched_methods version 1")) {
96
throw new Exception("First line mismatch");
97
}
98
99
output.shouldContain("TestLogTouchedMethods.methodA:()V");
100
output.shouldNotContain("TestLogTouchedMethods.methodB:()V");
101
output.shouldHaveExitValue(0);
102
103
pb = ProcessTools.createJavaProcessBuilder(
104
"-XX:+UnlockDiagnosticVMOptions",
105
"-Xint",
106
"-XX:+LogTouchedMethods",
107
"-XX:+PrintTouchedMethodsAtExit",
108
"-XX:-TieredCompilation",
109
TestLogTouchedMethods.class.getName());
110
output = new OutputAnalyzer(pb.start());
111
lines = output.asLines();
112
113
if (lines.size() < 1) {
114
throw new Exception("Empty output");
115
}
116
117
first = lines.get(0);
118
if (!first.equals("# Method::print_touched_methods version 1")) {
119
throw new Exception("First line mismatch");
120
}
121
122
output.shouldContain("TestLogTouchedMethods.methodA:()V");
123
output.shouldNotContain("TestLogTouchedMethods.methodB:()V");
124
output.shouldHaveExitValue(0);
125
}
126
}
127
128