-
Bug
-
Resolution: Fixed
-
P3
-
1.1
-
1.2fcs
-
sparc
-
solaris_2.5
-
Not verified
Methods works wrong under jdk1.1. Result is correct under jdk1.0.2
==== Here is the minimized test demonstrating the bug ====
class java_lang_String_RegionMatches {
public static void main (String args[]) {
String s1="s1";
String s2="s2";
// should print "true"
System.out.println(s1.regionMatches(0,s2,0,Integer.MIN_VALUE));
}
}
==== Here is the output of the test under jdk1.1 ====
false
==== Here is the output of the test under jdk1.0.2 ====
true
==== Here is the part of Java language specification v 1.0 ====
20.12.18 public boolean regionMatches(int toffset,
String other, int ooffset, int len)
throws NullPointerException
A substring of this String object is compared to a substring of the argument
other. The result is true if these substrings represent identical character
sequences. The substring of this String object to be compared begins at index
toffset and has length len. The substring of other to be compared begins at
index ooffset and has length len. The result is false if and only if at least
one of the following is true:
toffset is negative.
ooffset is negative.
toffset+len is greater than the length of this String object.
ooffset+len is greater than the length of the other argument.
There is some nonnegative integer k less than len such that:
this.charAt(toffset+k) != other.charAt(ooffset+k)
If other is null, then a NullPointerException is thrown.
==== Here is the minimized test demonstrating the bug ====
class java_lang_String_RegionMatches {
public static void main (String args[]) {
String s1="s1";
String s2="s2";
// should print "true"
System.out.println(s1.regionMatches(0,s2,0,Integer.MIN_VALUE));
}
}
==== Here is the output of the test under jdk1.1 ====
false
==== Here is the output of the test under jdk1.0.2 ====
true
==== Here is the part of Java language specification v 1.0 ====
20.12.18 public boolean regionMatches(int toffset,
String other, int ooffset, int len)
throws NullPointerException
A substring of this String object is compared to a substring of the argument
other. The result is true if these substrings represent identical character
sequences. The substring of this String object to be compared begins at index
toffset and has length len. The substring of other to be compared begins at
index ooffset and has length len. The result is false if and only if at least
one of the following is true:
toffset is negative.
ooffset is negative.
toffset+len is greater than the length of this String object.
ooffset+len is greater than the length of the other argument.
There is some nonnegative integer k less than len such that:
this.charAt(toffset+k) != other.charAt(ooffset+k)
If other is null, then a NullPointerException is thrown.