Kaffe-1.0.b1 for SunOS4 (was: Re: Which platform kaffe works?)

Raffaele Sena raff at aromatic.com
Sun Jul 19 10:01:53 PDT 1998


On Sun, 19 Jul 1998, Kiyo Inaba wrote:

> 1. Compiler pizza.compiler.Main does not work.
> On SunOS 4.1.4/gcc-2.8.1
> 	Kaffe sun.tools.javac.Main HelloWorldApp.java
> works fine, but
> 	Kaffe pizza.compiler.Main HelloWorldApp.java
> produces error as,
> 	HelloWorldApp.java:2: cannot access class String; bad class file (java.lang.NullPointerException: null)
> 		public static void main (String args[]) {
> 					 ^
> 	1 error
> 

This is exactly the error I was getting on my arm/linux port.
And it ended up to be a wrong cast from Java int to Java char
(cutting off the top 8 bits).

The error was only in the interpreter ( intrp/icode.h: cvt_int_char ),
while the translator ( jit/icode.c: cvt_int_char ) seems to do the
right thing, unless sizeof(jchar) is not 2.

And the SunOS port, looking at the config directory, seems to use the jit.

Anyway, pizza was failing because it's full of casts from 2 bytes into char
into integer and viceversa, so it was widely using the I2C instruction code.

You can try the following test program to see if you really have the
same problem, or you should put some traces in pizza/v39/classreader.pizza
(unfortunately, without a working jdb...)

Another way to see if you have the same error is to try to compile
a program the uses different classes. I was getting error for classes
bigger than 4K (i.e. Object, Short, Integer will compile - String, 
awt.Component will not)

Hope this help,

	Raffaele

------------------------------- 8< CUT HERE >8 -------------------------

import java.util.zip.*;
import java.io.*;

class z {
    private static char getChar(byte[] buf, int bp) {
	return
	    (char)(((buf[bp] & 0xFF) << 8) +
		   (buf[bp+1] & 0xFF));
    }


    private static void fileGet(String dirname, String filename) 
				throws Exception {
	ZipFile zdir = new ZipFile(dirname);
	ZipEntry entry = zdir.getEntry(filename);

	System.out.println("zipEntry - size: " + entry.getSize() +
			   " crc: " + Long.toHexString(entry.getCrc()));

	InputStream is = zdir.getInputStream(entry);

	int len = is.available();
	byte[] buf = new byte[len];
	is.read(buf);

	CRC32 cs = new CRC32();
	cs.reset();
	cs.update(buf);

	System.out.println("computed - size: " + len +
			   " crc: " + Long.toHexString(cs.getValue()));

	/*
	 * If everything is fine you shoul obtain: 2400/24-00/2400
	 */
	System.out.println(">>> " + 
			Integer.toHexString((int)getChar(buf, 32)) + "/" + 
			Integer.toHexString((buf[32]&0xFF)) + "-" + 
			Integer.toHexString((buf[33]&0xFF)) + "/" +
			Integer.toHexString(((buf[32]&0xFF)<<8) + (buf[33]&0xFF)));
    }

    public static void main (String args[])
				throws Exception {
	fileGet("/usr/local/share/kaffe/Klasses.jar",
		"java/lang/String.class");
    }
}



More information about the kaffe mailing list