Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/serial/HeapChangeLogging.java
40942 views
1
/*
2
* Copyright (c) 2013, 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
package gc.serial;
25
26
/*
27
* @test HeapChangeLogging.java
28
* @bug 8027440
29
* @requires vm.gc.Serial
30
* @library /test/lib
31
* @modules java.base/jdk.internal.misc
32
* @summary Allocate to get a promotion failure and verify that that heap change logging is present.
33
* @run driver gc.serial.HeapChangeLogging
34
*/
35
36
import java.util.regex.Matcher;
37
import java.util.regex.Pattern;
38
39
import jdk.test.lib.process.ProcessTools;
40
import jdk.test.lib.process.OutputAnalyzer;
41
42
public class HeapChangeLogging {
43
public static void main(String[] args) throws Exception {
44
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-Xlog:gc", HeapFiller.class.getName());
45
OutputAnalyzer output = new OutputAnalyzer(pb.start());
46
String stdout = output.getStdout();
47
System.out.println(stdout);
48
Matcher stdoutMatcher = Pattern.compile(".*\\(Allocation Failure\\) [0-9]+[KMG]->[0-9]+[KMG]\\([0-9]+[KMG]\\)", Pattern.MULTILINE).matcher(stdout);
49
if (!stdoutMatcher.find()) {
50
throw new RuntimeException("No proper GC log line found");
51
}
52
output.shouldHaveExitValue(0);
53
}
54
}
55
56
class HeapFiller {
57
public static Entry root;
58
private static final int PAYLOAD_SIZE = 1000;
59
60
public static void main(String[] args) {
61
root = new Entry(PAYLOAD_SIZE, null);
62
Entry current = root;
63
try {
64
while (true) {
65
Entry newEntry = new Entry(PAYLOAD_SIZE, current);
66
current = newEntry;
67
}
68
} catch (OutOfMemoryError e) {
69
root = null;
70
}
71
72
}
73
}
74
75
class Entry {
76
public Entry previous;
77
public byte[] payload;
78
79
Entry(int payloadSize, Entry previous) {
80
payload = new byte[payloadSize];
81
this.previous = previous;
82
}
83
}
84
85