[kaffe] bug in Class.getResourceAsStream()

Moses DeJong dejong at cs.umn.edu
Sat Dec 26 20:06:11 PST 1998


I have posted this message about getResourceAsStream() a couple of
times now. Some people mentioned that they tested the code in the
CVS and it worked for them. I just downloaded the latest CVS tree
(last changelog entry dated Sat Dec 26), and tested the code again.
The bug is still in the kaffe code. I am thinking that perhaps people
were not using the .zip file that I put on my web page. If you run
this code on a resource that is in a file on the CLASSPATH it will
work just fine. It only breaks when the resource to be found is
inside a .zip or .jar file. Did anyone get these same results?
I ran this code on a solaris-sparc 2.6 system and got the error.

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");

(all the code you need is in the zip file)


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 hope that helps
mo dejong
dejong at cs.umn.edu

More information about the kaffe mailing list