Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GC.java
41161 views
1
/*
2
* Copyright (c) 2005, 2018, 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 nsk.share.gc;
25
26
import nsk.share.test.*;
27
import nsk.share.runner.*;
28
import nsk.share.gc.gp.GarbageProducer;
29
import nsk.share.gc.gp.GarbageProducerAware;
30
import nsk.share.gc.gp.GarbageProducer1Aware;
31
import nsk.share.gc.gp.MemoryStrategy;
32
import nsk.share.gc.gp.MemoryStrategyAware;
33
import nsk.share.gc.gp.GarbageUtils;
34
import nsk.share.gc.lock.Lockers;
35
import nsk.share.gc.lock.LockersAware;
36
import nsk.share.gc.lock.LockerUtils;
37
38
/**
39
* Utility methods for GC tests.
40
*/
41
public class GC extends nsk.share.test.Tests {
42
protected static class GCTestRunner extends TestRunner {
43
private GCParams gcParams;
44
private GarbageProducer garbageProducer;
45
private GarbageProducer garbageProducer1;
46
private MemoryStrategy memoryStrategy;
47
private Lockers lockers;
48
49
public GCTestRunner(Test test, String[] args) {
50
super(test, args);
51
}
52
53
private GCParams getGCParams(String[] args) {
54
if (gcParams == null) {
55
gcParams = GCParams.getInstance();
56
gcParams.parseCommandLine(args);
57
}
58
return gcParams;
59
}
60
61
private GarbageProducer getGarbageProducer(String[] args) {
62
if (garbageProducer == null) {
63
garbageProducer = GarbageUtils.getGarbageProducer(getGCParams(args).getGarbageProducerId());
64
configure(garbageProducer);
65
}
66
return garbageProducer;
67
}
68
69
private GarbageProducer getGarbageProducer1(String[] args) {
70
if (garbageProducer1 == null) {
71
garbageProducer1 = GarbageUtils.getGarbageProducer(getGCParams(args).getGarbageProducer1Id());
72
configure(garbageProducer1);
73
}
74
return garbageProducer1;
75
}
76
77
private MemoryStrategy getMemoryStrategy(String[] args) {
78
if (memoryStrategy == null) {
79
memoryStrategy = MemoryStrategy.fromString(getGCParams(args).getMemoryStrategyId());
80
configure(memoryStrategy);
81
}
82
return memoryStrategy;
83
}
84
85
private Lockers getLockers(String[] args) {
86
if (lockers == null) {
87
lockers = LockerUtils.getLockers(getGCParams(args).getLockersId());
88
configure(lockers);
89
}
90
return lockers;
91
}
92
93
public void configure(Object test) {
94
super.configure(test);
95
if (test instanceof GCParamsAware)
96
((GCParamsAware) test).setGCParams(getGCParams(args));
97
if (test instanceof GarbageProducerAware)
98
((GarbageProducerAware) test).setGarbageProducer(getGarbageProducer(args));
99
if (test instanceof GarbageProducer1Aware)
100
((GarbageProducer1Aware) test).setGarbageProducer1(getGarbageProducer1(args));
101
if (test instanceof MemoryStrategyAware)
102
((MemoryStrategyAware) test).setMemoryStrategy(getMemoryStrategy(args));
103
if (test instanceof LockersAware)
104
((LockersAware) test).setLockers(getLockers(args));
105
}
106
107
108
}
109
110
private GC() {
111
}
112
113
public static void runTest(Test test, String[] args) {
114
new GCTestRunner(test, args).run();
115
}
116
}
117
118