Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/arguments/TestArrayAllocatorMallocLimit.java
40942 views
1
/*
2
* Copyright (c) 2014, 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.arguments;
25
26
/*
27
* @test TestArrayAllocatorMallocLimit
28
* @summary Sanity check that the ArrayAllocatorMallocLimit flag can be set.
29
* The test helps verifying that size_t flags can be set/read.
30
* @bug 8054823
31
* @library /test/lib
32
* @library /
33
* @modules java.base/jdk.internal.misc
34
* java.management
35
* @run driver gc.arguments.TestArrayAllocatorMallocLimit
36
*/
37
38
import jdk.test.lib.Asserts;
39
import jdk.test.lib.process.OutputAnalyzer;
40
import jdk.test.lib.process.ProcessTools;
41
import java.math.BigInteger;
42
43
public class TestArrayAllocatorMallocLimit {
44
public static void main(String [] args) throws Exception {
45
testDefaultValue();
46
testSetValue();
47
}
48
49
private static final String flagName = "ArrayAllocatorMallocLimit";
50
51
// size_t ArrayAllocatorMallocLimit = 18446744073709551615{experimental}
52
private static final String printFlagsFinalPattern = " *size_t *" + flagName + " *:?= *(\\d+) *\\{experimental\\} *";
53
54
public static void testDefaultValue() throws Exception {
55
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(
56
"-XX:+UnlockExperimentalVMOptions", "-XX:+PrintFlagsFinal", "-version");
57
58
OutputAnalyzer output = new OutputAnalyzer(pb.start());
59
String value = output.firstMatch(printFlagsFinalPattern, 1);
60
61
try {
62
Asserts.assertNotNull(value, "Couldn't find size_t flag " + flagName);
63
64
// A size_t is not always parseable with Long.parseValue,
65
// use BigInteger instead.
66
BigInteger biValue = new BigInteger(value);
67
68
// Sanity check that we got a non-zero value.
69
Asserts.assertNotEquals(biValue, "0");
70
71
output.shouldHaveExitValue(0);
72
} catch (Exception e) {
73
System.err.println(output.getOutput());
74
throw e;
75
}
76
}
77
78
public static void testSetValue() throws Exception {
79
long flagValue = 2048;
80
81
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(
82
"-XX:+UnlockExperimentalVMOptions", "-XX:" + flagName + "=" + flagValue, "-XX:+PrintFlagsFinal", "-version");
83
84
OutputAnalyzer output = new OutputAnalyzer(pb.start());
85
String value = output.firstMatch(printFlagsFinalPattern, 1);
86
87
try {
88
Asserts.assertNotNull("Couldn't find size_t flag " + flagName);
89
90
long longValue = Long.parseLong(value);
91
92
Asserts.assertEquals(longValue, flagValue);
93
94
output.shouldHaveExitValue(0);
95
} catch (Exception e) {
96
System.err.println(output.getOutput());
97
throw e;
98
}
99
}
100
101
}
102
103