Skip to content

Commit 55c282b

Browse files
committed
8253878: clean up nsk/share/jvmti/ArgumentHandler
Reviewed-by: cjplummer
1 parent 776acfd commit 55c282b

File tree

1 file changed

+18
-42
lines changed

1 file changed

+18
-42
lines changed

test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/ArgumentHandler.java

+18-42
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323

2424
package nsk.share.jvmti;
2525

26-
import nsk.share.*;
26+
import nsk.share.ArgumentParser;
27+
import nsk.share.Failure;
2728

28-
import java.io.*;
29-
import java.util.*;
29+
import java.util.StringTokenizer;
3030

3131
/**
3232
* Parser for JVMTI test's specific command-line arguments.
@@ -37,16 +37,14 @@
3737
* form agent option string. These options are added to the options list
3838
* and can be found using <i>FindOption*Value()</i> methods.
3939
* <p>
40-
* Currently no specific options are recognized by <code>AgrumentHandler</code>.
40+
* Currently no specific options are recognized by <code>ArgumentHandler</code>.
4141
* <p>
4242
* See description of <code>ArgumentParser</code> to know which general options
4343
* are recognized and how to get them.
4444
*
4545
* @see ArgumentParser
46-
*
4746
* @see #findOptionValue(String)
48-
* @see #findOptionStringValue(String,String)
49-
* @see #findOptionIntValue(String,int)
47+
* @see #findOptionIntValue(String, int)
5048
*/
5149
public class ArgumentHandler extends ArgumentParser {
5250

@@ -55,15 +53,13 @@ public class ArgumentHandler extends ArgumentParser {
5553
* but throw an exception on parsing error; and also add options
5654
* obtained from agent options string.
5755
*
58-
* @param args Array of the raw command-line arguments.
59-
*
60-
* @throws NullPointerException If <code>args==null</code>.
61-
* @throws IllegalArgumentException If Binder or Log options
62-
* are set incorrectly.
63-
*
56+
* @param args Array of the raw command-line arguments.
57+
* @throws NullPointerException If <code>args==null</code>.
58+
* @throws IllegalArgumentException If Binder or Log options
59+
* are set incorrectly.
6460
* @see #setRawArguments(String[])
6561
*/
66-
public ArgumentHandler(String args[]) {
62+
public ArgumentHandler(String[] args) {
6763
super(args);
6864
String agentOptions = getAgentOptionsString();
6965
if (agentOptions == null) {
@@ -76,25 +72,7 @@ public ArgumentHandler(String args[]) {
7672
* Return value of given option if specified; or <i>null</i> otherwise.
7773
*/
7874
public String findOptionValue(String name) {
79-
String value = options.getProperty(name);
80-
return value;
81-
}
82-
83-
/**
84-
* Return string value of given option if specified; or <i>defaultValue</i> otherwise.
85-
*
86-
* @throws BadOption if option is specified but has empty value.
87-
*/
88-
public String findOptionStringValue(String name, String defaultValue) {
89-
String value = options.getProperty(name);
90-
if (value == null) {
91-
return defaultValue;
92-
}
93-
94-
if (value.length() <= 0) {
95-
throw new BadOption("Empty value of option: " + name + "=" + value);
96-
}
97-
return value;
75+
return options.getProperty(name);
9876
}
9977

10078
/**
@@ -120,13 +98,11 @@ public int findOptionIntValue(String name, int defaultValue) {
12098
* This method is invoked by <code>parseArguments()</code>.
12199
*
122100
* @param option option name
123-
* @param value string representation of value (could be an empty string);
124-
* or null if this option has no value
101+
* @param value string representation of value (could be an empty string);
102+
* or null if this option has no value
125103
* @return <i>true</i> if option is admissible and has proper value;
126-
* <i>false</i> if otion is not admissible
127-
*
128-
* @throws <i>BadOption</i> if admissible option has illegal value
129-
*
104+
* <i>false</i> if option is not admissible
105+
* @throws BadOption if admissible option has illegal value
130106
* @see #parseArguments()
131107
*/
132108
protected boolean checkOption(String option, String value) {
@@ -147,8 +123,8 @@ protected void checkOptions() {
147123
* Parse options string and add all recognized options and their values.
148124
* If optionString is <i>null</i> this method just does nothing.
149125
*
150-
* @throws BadOption if known option has illegel value
151-
* or all options are inconsistent
126+
* @throws BadOption if known option has illegal value
127+
* or all options are inconsistent
152128
*/
153129
protected void parseOptionString(String optionString) {
154130
if (optionString == null)
@@ -157,7 +133,7 @@ protected void parseOptionString(String optionString) {
157133
StringTokenizer st = new StringTokenizer(optionString, " ,~");
158134
while (st.hasMoreTokens()) {
159135
String token = st.nextToken();
160-
int start = token.startsWith("-")? 1 : 0;
136+
int start = token.startsWith("-") ? 1 : 0;
161137
String name, value;
162138
int k = token.indexOf('=');
163139
if (k < 0) {

0 commit comments

Comments
 (0)