Good catch!
Additionally consider my additional twiddling on indexOf.

-Ulf


Am 20.03.2010 19:36, schrieb Martin Buchholz:
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



Reply via email to