Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/blackhole/BlackholeNonVoidWarningTest.java
41149 views
1
/*
2
* Copyright (c) 2021, Red Hat, Inc. 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
* @library /test/lib /
27
* @requires vm.flagless
28
* @run driver compiler.blackhole.BlackholeNonVoidWarningTest
29
*/
30
31
package compiler.blackhole;
32
33
import java.io.IOException;
34
import java.util.List;
35
import java.util.Arrays;
36
import java.util.ArrayList;
37
import jdk.test.lib.process.ProcessTools;
38
import jdk.test.lib.process.OutputAnalyzer;
39
40
public class BlackholeNonVoidWarningTest {
41
42
private static final int CYCLES = 100_000;
43
private static final int TRIES = 10;
44
45
public static void main(String[] args) throws IOException {
46
if (args.length == 0) {
47
driver();
48
} else {
49
runner();
50
}
51
}
52
53
private static final String MSG = "Blackhole compile option only works for methods with void type: compiler.blackhole.BlackholeTarget.bh_sr_int(I)I";
54
55
private static List<String> cmdline(String[] args) {
56
List<String> r = new ArrayList();
57
r.add("-Xmx128m");
58
r.add("-Xbatch");
59
r.addAll(Arrays.asList(args));
60
r.add("compiler.blackhole.BlackholeNonVoidWarningTest");
61
r.add("run");
62
return r;
63
}
64
65
public static void shouldFail(String... args) throws IOException {
66
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
67
OutputAnalyzer output = new OutputAnalyzer(pb.start());
68
output.shouldHaveExitValue(0);
69
output.shouldContain(MSG);
70
}
71
72
public static void shouldPass(String... args) throws IOException {
73
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
74
OutputAnalyzer output = new OutputAnalyzer(pb.start());
75
output.shouldHaveExitValue(0);
76
output.shouldNotContain(MSG);
77
}
78
79
public static void driver() throws IOException {
80
// Should print the warning
81
shouldFail(
82
"-XX:+UnlockExperimentalVMOptions",
83
"-XX:CompileCommand=quiet",
84
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
85
);
86
shouldFail(
87
"-XX:+UnlockExperimentalVMOptions",
88
"-XX:CompileCommand=quiet",
89
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
90
);
91
92
// Should be able to shun the warning
93
shouldPass(
94
"-XX:-PrintWarnings",
95
"-XX:+UnlockExperimentalVMOptions",
96
"-XX:CompileCommand=quiet",
97
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
98
);
99
shouldPass(
100
"-XX:-PrintWarnings",
101
"-XX:+UnlockExperimentalVMOptions",
102
"-XX:CompileCommand=quiet",
103
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
104
);
105
}
106
107
public static void runner() {
108
for (int t = 0; t < TRIES; t++) {
109
run();
110
}
111
}
112
113
public static void run() {
114
for (int c = 0; c < CYCLES; c++) {
115
if (BlackholeTarget.bh_sr_int(c) != 0) {
116
throw new AssertionError("Return value error");
117
}
118
}
119
}
120
121
}
122
123