Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/vm/gc/containers/ContainerDescription.java
41155 views
1
/*
2
* Copyright (c) 2010, 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
package vm.gc.containers;
24
25
import nsk.share.TestBug;
26
import nsk.share.gc.gp.GarbageProducer;
27
import nsk.share.gc.gp.GarbageUtils;
28
import nsk.share.gc.gp.MemoryStrategy;
29
30
/**
31
* This is a description which is parsed from command-line string.
32
* It contains the container type, garbage producer, memory strategy,
33
* speed of objects renovations and count of threads to work with
34
* container. The conatainer should be MT safe if threadsCount more then 1.
35
*/
36
public class ContainerDescription {
37
38
/*
39
* The container description is next:
40
* containerName(garbageProucer,numberOfThreads,speed,MemoryStrategy)
41
* all parameters except containerName are optional
42
* containerName is the Name of class from java.util or java.util.concurrent
43
*/
44
static ContainerDescription parseFromString(String string) {
45
int params = string.indexOf('(');
46
String gp;
47
Speed speed = Speed.MEDIUM;
48
MemoryStrategy ms = null;
49
int count = 1;
50
51
if (params == -1) {
52
ContainerDescription descr = new ContainerDescription(string);
53
descr.setSpeed(speed);
54
descr.setThreadsCount(count);
55
return descr;
56
}
57
if (!string.endsWith(")")) {
58
throw new TestBug("Incorrect syntax of container description.");
59
}
60
String name = string.substring(0, string.indexOf('('));
61
String parameters = string.substring(string.indexOf("(") + 1, string.length() - 1);
62
final int closedBracket = parameters.lastIndexOf(')');
63
int del = parameters.indexOf(',', closedBracket + 1);
64
if (del == -1) {
65
gp = parameters;
66
} else {
67
gp = parameters.substring(0, del).trim();
68
String[] other = parameters.substring(del + 1).split(",");
69
switch (other.length) {
70
case 3:
71
ms = MemoryStrategy.fromString(other[2].trim());
72
case 2:
73
speed = Speed.fromString(other[1].trim());
74
case 1:
75
count = Integer.parseInt(other[0].trim());
76
break;
77
default:
78
throw new TestBug("Unexpected size of parameters: " + other.length + 1);
79
}
80
}
81
ContainerDescription descr = new ContainerDescription(name);
82
descr.setGarbageProducer(GarbageUtils.getGarbageProducer(gp));
83
descr.setSpeed(speed);
84
descr.setThreadsCount(count);
85
descr.setMemoryStrategy(ms);
86
return descr;
87
}
88
89
protected ContainerDescription(String name) {
90
this.name = name;
91
}
92
protected GarbageProducer garbageProducer;
93
94
/**
95
* Get the value of garbageProducer
96
*
97
* @return the value of garbageProducer
98
*/
99
public GarbageProducer getGarbageProducer() {
100
return garbageProducer;
101
}
102
103
/**
104
* Set the value of garbageProducer
105
*
106
* @param garbageProducer new value of garbageProducer
107
*/
108
public void setGarbageProducer(GarbageProducer garbageProducer) {
109
this.garbageProducer = garbageProducer;
110
}
111
protected MemoryStrategy memoryStrategy;
112
113
/**
114
* Get the value of memoryStrategy
115
*
116
* @return the value of memoryStrategy
117
*/
118
public MemoryStrategy getMemoryStrategy() {
119
return memoryStrategy;
120
}
121
122
/**
123
* Set the value of memoryStrategy
124
*
125
* @param memoryStrategy new value of memoryStrategy
126
*/
127
public void setMemoryStrategy(MemoryStrategy memoryStrategy) {
128
this.memoryStrategy = memoryStrategy;
129
}
130
protected String name;
131
132
/**
133
* Get the value of Type
134
*
135
* @return the value of Type
136
*/
137
public String getName() {
138
return name;
139
}
140
protected Speed speed = Speed.MEDIUM;
141
142
/**
143
* Get the value of speed
144
*
145
* @return the value of speed
146
*/
147
public Speed getSpeed() {
148
return speed;
149
}
150
151
/**
152
* Set the value of speed
153
*
154
* @param speed new value of speed
155
*/
156
public void setSpeed(Speed speed) {
157
this.speed = speed;
158
}
159
protected int threadsCount;
160
161
/**
162
* Get the value of threadsCount
163
*
164
* @return the value of threadsCount
165
*/
166
public int getThreadsCount() {
167
return threadsCount;
168
}
169
170
/**
171
* Set the value of threadsCount
172
*
173
* @param threadsCount new value of threadsCount
174
*/
175
public void setThreadsCount(int threadsCount) {
176
this.threadsCount = threadsCount;
177
}
178
}
179
180