[kaffe] Bug Report: String.indexOf() gives incorrect result

Fitz Elliott fge7z at virginia.edu
Fri May 13 10:49:56 PDT 2005


Hello,
	I have noticed some strange behavior with String.indexOf().
Sometimes, indexOf() returns -1 even though the argument String is
definitely in the calling String.  The necessary conditions seem to be:

where:
  String t,s;
  t.indexOf(s);
then:
  s must end with '.\r\n'  (in perl: m/.\r\n$/)
  t must be at least 128 characters long
  s must be at the end of t

Example code:

----- BEGIN CODE -----

public class test {

    public static void main(String args[]) {

	String end = "a\r\n";

	String text =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n";
	String text2 =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n";

	int iend = text.indexOf(end);
	int iend2 = text2.indexOf(end);
	System.err.println("Text1: length: "+text.length()+" iend:
"+iend);
	System.err.println("Text2: length: "+text2.length()+" iend:
"+iend2);
    }

}

----- END CODE -----

Kaffe reports an index of -1 for text1, but an index of 124 for text2.
Blackdown Java, SableVM, and JamVM all give the correct answer.

I am running Debian unstable, with kaffe version 1.1.5-3 and classpath
version 0.14-2.

If I can offer any other information please let me know.

Cheers,
Fitz





More information about the kaffe mailing list