Bug in String.lastIndexOf

Peter Graves peter at armedbear.org
Sat Oct 28 20:39:29 PDT 2000


There's a bug in java.lang.String lastIndexOf(String, int).

Here's a short test program that illustrates the problem:

class t
{
    public static void main(String[] args)
    {
        String s1 = "this is a test yes it is";
        String s2 = "yet another test";
        String s3 = s2.substring(12); // "test"
        for (int i = 0; i < s1.length(); i++)
            System.err.println("i = " + i + " index = " + s1.lastIndexOf(s3, i));
    }
}

If you run this program with kaffe (current CVS), the
lastIndexOf call returns 10 for -all- values of i.

It should return -1 for i < 10 (and does so with IBM 1.3, for
example).

-Peter


More information about the kaffe mailing list