[Kaffe] bug in Class.getResourceAsStream() method.

Moses DeJong dejong at cs.umn.edu
Mon Dec 21 16:13:53 PST 1998

Hello again.

I posted a message about a kaffe bug but I did not hear from
anyone about a fix. This makes me think that perhaps I was
not very clear in my first message so I am going to ask again.
Here is a short bit of code that works under a Sun JVM but fails
under kaffe.

import java.io.*;

public class easy {
  public static void main(String[] argv) throws Exception {
    InputStream stream = Class.class.getResourceAsStream("/easy/easy.msg");

    if (stream == null) {
      System.out.println("resource not found");

Under a Sun JVM this code will find a resource on the CLASSPATH even if it
is in a .jar or .zip file. Kaffe will fail to find the resource if it is
in a .jar of .zip file. The problem is in the implementation of the
getResourceAsStream method. In case other folks want to try out this code
I have a .zip file that you can grab here:


To see the problem you will just need to run the following commands.

jar -xf kaffe_bug.zip
cd kaffe_bug
setenv CLASSPATH .:easy.zip
java easy

I have run this code on a Solaris box and a Linux box with the exact same
results (works under Sun JDK but not kaffe). I was using Kaffe-1.0.b3.
If this is a known bug could someone drop me a note so I do not waste time
working on something that has already been fixed.

I hope that helps
mo dejong
dejong at cs.umn.edu

More information about the kaffe mailing list