[kaffe] ARM: unable to load .class files

Thomas Winkler tom at qwws.net
Mon Oct 11 06:08:00 PDT 2004


Hello,

I'm currently trying to get Kaffe working on an XScale cpu (big endian mode).
By using libffi I managed to compile kaffe 1.1.4 but I still have some 
problems with it.

The first thing I tried was running a simple Hello World program:

root at IXDP425:/mnt/winkler# ls *.class
HelloWorld.class
root at IXDP425:/mnt/winkler# java -cp . HelloWorld
java.lang.ClassNotFoundException: HelloWorld
   at kaffe.lang.AppClassLoader.findClass (AppClassLoader.java:328)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:142)
root at IXDP425:/mnt/winkler#

I initially thought that this might be related to an incorrect classpath or 
something. But later on i found out that when I put the HelloWorld.class into 
jar file, say test.jar, and then run it like this it works:

root at IXDP425:/mnt/winkler# java -cp test.jar  HelloWorld
Hello World!

I tried to investigate the problem a little further. I extracted the content 
of rt.jar and replaced the kaffe/lang/AppClassLoader.class file with a 
version with some extra debug outputs.

I tracked the problem down to DirSource::findClass. There the following for 
loop can be found:

for (int j=0; j<length; j+=in.read (buf, j, length-j));

I replaced it with the following code:

        for (int j = 0; j < length; ) {
          System.out.println("length: " + length + " j: " + j );
          int tmp = in.read(buf, j, length-j);
          j += tmp;
        }

When executing the HelloWorld class using the modified AppClassLoader.class it 
looks like this:

root at IXDP425:/mnt/winkler# java -cp . HelloWorld
length: 821272 j: 0
DirSource exception... java.io.IOException: Bad file descriptor
java.lang.ClassNotFoundException: HelloWorld
   at kaffe.lang.AppClassLoader.findClass (AppClassLoader.java:328)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:142)
root at IXDP425:/mnt/winkler#

The "DirSource exception" message was also added by me in the catch block at 
the very end of the function (it was empty before). It seems that file.length 
is reporting a wrong file length (the HelloWorld.class actually has 479 
bytes).
 

In addition to that I noticed that javac also isn't working correctly on the 
XScale:

root at IXDP425:/mnt/winkler# javac HelloWorld.java
HelloWorld.java:1: error:I/O Exception on file "HelloWorld.java": Bad file
descriptor

I'm not sure if there is something wrong with the file I/O or maybe this is an 
endianes issue such that the file size is reported incorrectly.

Thanks for your help,
--
Thomas Winkler
e-mail: tom at qwws.net



More information about the kaffe mailing list