-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
8
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
This method is in tools.jar of jdk1.8.0_301.
This exception can be avoided by replacing args[i].charAt(0) == '-' with args[i].startsWith("-").
This change can also be seen in the previous commit such as https://github.com/openjdk/jdk/commit/e341e35276315a5140ddec11a7e659d57328e9a0
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The unit test case is:
@Test
public void test_parseArguments() throws com.sun.tools.internal.xjc.BadCommandLineException {
String[] stringArray1 = {"a ", "^[1]([3-9])[0-9]{9}$", "", ".\\a.txt"};
com.sun.tools.internal.jxc.ap.Options options0 = new com.sun.tools.internal.jxc.ap.Options();
options0.parseArguments(stringArray1);
}
ACTUAL -
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at com.sun.tools.internal.jxc.ap.Options.parseArguments(Options.java:60)
---------- BEGIN SOURCE ----------
public void parseArguments(String[] args) throws BadCommandLineException {
for(int i = 0; i < args.length; ++i) {
if (args[i].charAt(0) == '-') {
int j = this.parseArgument(args, i);
if (j == 0) {
throw new BadCommandLineException(Messages.UNRECOGNIZED_PARAMETER.format(new Object[]{args[i]}));
}
i += j;
} else {
this.arguments.add(args[i]);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
replace args[i].charAt(0) == '-' with args[i].startsWith("-")
This method is in tools.jar of jdk1.8.0_301.
This exception can be avoided by replacing args[i].charAt(0) == '-' with args[i].startsWith("-").
This change can also be seen in the previous commit such as https://github.com/openjdk/jdk/commit/e341e35276315a5140ddec11a7e659d57328e9a0
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The unit test case is:
@Test
public void test_parseArguments() throws com.sun.tools.internal.xjc.BadCommandLineException {
String[] stringArray1 = {"a ", "^[1]([3-9])[0-9]{9}$", "", ".\\a.txt"};
com.sun.tools.internal.jxc.ap.Options options0 = new com.sun.tools.internal.jxc.ap.Options();
options0.parseArguments(stringArray1);
}
ACTUAL -
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at com.sun.tools.internal.jxc.ap.Options.parseArguments(Options.java:60)
---------- BEGIN SOURCE ----------
public void parseArguments(String[] args) throws BadCommandLineException {
for(int i = 0; i < args.length; ++i) {
if (args[i].charAt(0) == '-') {
int j = this.parseArgument(args, i);
if (j == 0) {
throw new BadCommandLineException(Messages.UNRECOGNIZED_PARAMETER.format(new Object[]{args[i]}));
}
i += j;
} else {
this.arguments.add(args[i]);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
replace args[i].charAt(0) == '-' with args[i].startsWith("-")