[Kaffe] bug in InputStream.available() method (fwd)
    Moses DeJong 
    dejong at cs.umn.edu
       
    Mon Dec 28 19:02:45 PST 1998
    
    
  
Confirmed. The XMas patch fixes the InputStream.available() bug.
Mo DeJong
dejong at cs.umn.edu
---------- Forwarded message ----------
To: kaffe at rufus.w3.org
Subject: [Kaffe] bug in InputStream.available() method
Here is a simple "echo" type of program that fails under
kaffe (off a fresh CVS tree). The System.in.available()
method seems to be returning -1 when there are 0 bytes
available. This same code works just find under a Sun JDK.
I was running under solaris-sparc2.6 and I compiled with gcc.
public class echo {
    public static void main(String[] argv) throws Exception {
	System.out.println("Please begin typing");
	
	while (true) {
	    int avail = System.in.available();
	    if (avail == 0) {
		Thread.currentThread().sleep(100);
	    } else {
		byte[] buff = new byte[avail];
		System.in.read(buff);
		
		//echo back what was just typed
		System.out.println();
		System.out.println("-----ECHO BEGIN-----");
		System.out.write(buff);
		System.out.println("-----ECHO END-----");
	    }
	}
    }
}
mo(/tmp/mo/kaffe_bug)% /tmp/mo/install_kaffe/bin/kaffe echo
Please begin typing
java.lang.NegativeArraySizeException
        at echo.main(13)
    
    
More information about the kaffe
mailing list