Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/epsilon/TestDieWithOnError.java
40943 views
1
/*
2
* Copyright (c) 2017, 2018, 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
package gc.epsilon;
25
26
/**
27
* @test TestDieWithOnError
28
* @requires vm.gc.Epsilon
29
* @summary Epsilon GC should die on heap exhaustion with error handler attached
30
* @library /test/lib
31
* @run driver gc.epsilon.TestDieWithOnError
32
*/
33
34
import jdk.test.lib.process.OutputAnalyzer;
35
import jdk.test.lib.process.ProcessTools;
36
37
public class TestDieWithOnError {
38
39
static String ON_ERR_MSG = "Epsilon error handler message";
40
41
public static void passWith(String... args) throws Exception {
42
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
43
OutputAnalyzer out = new OutputAnalyzer(pb.start());
44
out.shouldNotContain("OutOfMemoryError");
45
out.stdoutShouldNotMatch("^" + ON_ERR_MSG);
46
out.shouldHaveExitValue(0);
47
}
48
49
public static void failWith(String... args) throws Exception {
50
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
51
OutputAnalyzer out = new OutputAnalyzer(pb.start());
52
out.shouldContain("OutOfMemoryError");
53
if (out.getExitValue() == 0) {
54
throw new IllegalStateException("Should have failed with non-zero exit code");
55
}
56
out.stdoutShouldMatch("^" + ON_ERR_MSG);
57
}
58
59
public static void main(String[] args) throws Exception {
60
passWith("-Xmx128m",
61
"-XX:+UnlockExperimentalVMOptions",
62
"-XX:+UseEpsilonGC",
63
"-Dcount=1",
64
"-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
65
TestDieWithOnError.Workload.class.getName());
66
67
failWith("-Xmx128m",
68
"-XX:+UnlockExperimentalVMOptions",
69
"-XX:+UseEpsilonGC",
70
"-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
71
TestDieWithOnError.Workload.class.getName());
72
73
failWith("-Xmx128m",
74
"-Xint",
75
"-XX:+UnlockExperimentalVMOptions",
76
"-XX:+UseEpsilonGC",
77
"-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
78
TestDieWithOnError.Workload.class.getName());
79
80
failWith("-Xmx128m",
81
"-Xbatch",
82
"-Xcomp",
83
"-XX:+UnlockExperimentalVMOptions",
84
"-XX:+UseEpsilonGC",
85
"-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
86
TestDieWithOnError.Workload.class.getName());
87
88
failWith("-Xmx128m",
89
"-Xbatch",
90
"-Xcomp",
91
"-XX:TieredStopAtLevel=1",
92
"-XX:+UnlockExperimentalVMOptions",
93
"-XX:+UseEpsilonGC",
94
"-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
95
TestDieWithOnError.Workload.class.getName());
96
97
failWith("-Xmx128m",
98
"-Xbatch",
99
"-Xcomp",
100
"-XX:-TieredCompilation",
101
"-XX:+UnlockExperimentalVMOptions",
102
"-XX:+UseEpsilonGC",
103
"-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
104
TestDieWithOnError.Workload.class.getName());
105
}
106
107
public static class Workload {
108
static int COUNT = Integer.getInteger("count", 1_000_000_000); // ~24 GB allocation
109
110
static volatile Object sink;
111
112
public static void main(String... args) {
113
for (int c = 0; c < COUNT; c++) {
114
sink = new Object();
115
}
116
}
117
}
118
119
}
120
121