String.lastIndexOf confused by unpaired trailing surrogate
Martin Buchholz
martinrb at google.com
Sat Mar 20 18:36:22 UTC 2010
For a change, here's an actual plain old "incorrect result" bug fix
for String.lastIndexOf
Sherman, please file a bug and review.
http://cr.openjdk.java.net/~martin/webrevs/openjdk7/lastIndexOf/
Also includes our usual performance-oriented fiddling.
public class LastIndexOf {
public static void main(String[] args) {
int ch = 0x10042;
char[] bug = new char[3];
Character.toChars(ch, bug, 0);
bug[2] = bug[0];
System.out.println(new String(bug).lastIndexOf(ch));
bug[2] = '!';
System.out.println(new String(bug).lastIndexOf(ch));
}
}
==> javac -source 1.6 -Xlint:all LastIndexOf.java
==> java -esa -ea LastIndexOf
-1
0
More information about the core-libs-dev
mailing list