Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODRunnerArgParser.java
41161 views
1
/*
2
* Copyright (c) 2008, 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 nsk.share.aod;
25
26
import nsk.share.ArgumentParser;
27
import nsk.share.TestBug;
28
29
import java.util.ArrayList;
30
import java.util.List;
31
import java.util.Set;
32
33
public class AODRunnerArgParser extends ArgumentParser {
34
private static final String JAR_AGENT_PARAM = "ja";
35
private static final String NATIVE_AGENT_PARAM = "na";
36
private static final String TARGET_APP_PARAM = "target";
37
private static final String JAVA_OPTS_PARAM = "javaOpts";
38
private static final String TESTED_JDK_PARAM = "jdk";
39
private static final Set<String> SUPPORTED_OPTIONS = Set.of(
40
JAR_AGENT_PARAM,
41
NATIVE_AGENT_PARAM,
42
TARGET_APP_PARAM,
43
JAVA_OPTS_PARAM,
44
TESTED_JDK_PARAM);
45
46
private List<AgentInformation> agents;
47
48
public AODRunnerArgParser(String[] args) {
49
super(args);
50
}
51
52
protected boolean checkOption(String option, String value) {
53
if (super.checkOption(option, value)) {
54
return true;
55
}
56
57
if (!SUPPORTED_OPTIONS.contains(option)) {
58
return false;
59
}
60
61
if (option.equals(JAR_AGENT_PARAM)) {
62
addAgentInfo(true, value);
63
}
64
65
if (option.equals(NATIVE_AGENT_PARAM)) {
66
addAgentInfo(false, value);
67
}
68
69
return true;
70
}
71
72
protected void checkOptions() {
73
if (agents == null) {
74
agents = new ArrayList<>();
75
}
76
}
77
78
private void addAgentInfo(boolean jarAgent, String unsplittedAgentsString) {
79
if (agents == null) {
80
agents = new ArrayList<>();
81
}
82
83
String[] agentStrings;
84
85
if (unsplittedAgentsString.contains(",")) {
86
agentStrings = unsplittedAgentsString.split(",");
87
} else {
88
agentStrings = new String[]{ unsplittedAgentsString };
89
}
90
91
for (String agentString : agentStrings) {
92
int index = agentString.indexOf('=');
93
94
if (index > 0) {
95
String pathToAgent = agentString.substring(0, index);
96
String options = agentString.substring(index + 1);
97
agents.add(new AgentInformation(jarAgent, pathToAgent, options));
98
} else {
99
agents.add(new AgentInformation(jarAgent, agentString, null));
100
}
101
}
102
}
103
104
public String getTargetApp() {
105
if (!options.containsKey(TARGET_APP_PARAM)) {
106
throw new TestBug("Target application isn't specified");
107
}
108
109
return options.getProperty(TARGET_APP_PARAM);
110
}
111
112
public String getTestedJDK() {
113
if (!options.containsKey(TESTED_JDK_PARAM)) {
114
throw new TestBug("Tested JDK isn't specified");
115
}
116
117
return options.getProperty(TESTED_JDK_PARAM);
118
}
119
120
public String getJavaOpts() {
121
var value = options.getProperty(JAVA_OPTS_PARAM, "");
122
if (value.length() > 1 && value.startsWith("\"") && value.endsWith("\"")) {
123
value = value.substring(1, value.length() - 1);
124
}
125
return value.trim();
126
}
127
128
public List<AgentInformation> getAgents() {
129
return agents;
130
}
131
}
132
133