[Kaffe] bug in pizza compiler.

Moses DeJong dejong at cs.umn.edu
Wed Feb 3 22:33:22 PST 1999


Hello all.

I ran into a bug while running a program in Kaffe but
after some searching I found that the bug is actually
in the pizza compile used by Kaffe. Apparently pizza
thinks the string "\0" is really the empty string.
Here is a small bit of code that shows the problem.

public class EmptyString {

    public static void main(String[] argv) throws Exception {
	String s = "\0";
	char c = s.charAt(0);

	if (c != '\0') {
	    throw new Exception("bad char (" + ((int) c) + ")");
	} else {
	    System.out.println("OK");
	}
    }
}




Kaffe output when compiled with JDK's javac

% kaffe EmptyString
OK


Kaffe output when compiled kaffe's javac (Pizza)

% kaffe EmptyString
java.lang.StringIndexOutOfBoundsException
        at java/lang/Throwable.<init>(31)
        at java/lang/Exception.<init>(17)
        at java/lang/RuntimeException.<init>(17)
        at java/lang/IndexOutOfBoundsException.<init>(17)
        at java/lang/StringIndexOutOfBoundsException.<init>(17)
        at java/lang/String.charAt(110)
        at EmptyString.main(5)




JDK output when compiled with JDK's javac

% java EmptyString
OK



JDK output when compiled with Kaffe's javac

% java EmptyString
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(String.java)
        at EmptyString.main(EmptyString.java:5)



JDK output when compiled with Pizza under the JDK

% java EmptyString
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(String.java)
        at EmptyString.main(EmptyString.java:5)




So the problem is in the way that pizza stores the string
at compile time. You can verify this by running this file
which does not produce the error as the string is created
at runtime.


public class ScanString {
    public static void main(String[] argv) throws Exception {
	String s = String.valueOf('\0');
	if ('\0' != s.charAt(0)) {
	    throw new Exception("char not 0");
	}
    }
}


Where should I report this pizza bug? Are there any pizza folks
lurking on this list? Could anyone point me in the right direction?


Mo DeJong
dejong at cs.umn.edu



More information about the kaffe mailing list