Bug 7766 - ZipInputStream.available returns 0 immediately after construction
Summary: ZipInputStream.available returns 0 immediately after construction
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 3.3
: P3 normal
Target Milestone: ---
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-08-29 16:36 UTC by jmr
Modified: 2003-07-25 17:33 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jmr 2002-08-29 16:36:00 UTC
	Immediately after construction of a ZipInputStream, available()
        will return 0.  Sun's javadoc states, "Returns 0 after EOF has
        reached for the current entry data, otherwise always return 1."
        My interpretation is there is no current entry, so EOF hasn't
        been reached on it yet, so return 1.

Release:
3.3 20020828 (experimental)

Environment:
System: Linux churchill 2.4.3-12 #1 Fri Jun 8 15:05:56 EDT 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --prefix=/home/user/jmr/app/gcc --enable-langs=c++,java --enable-shared --enable-threads=posix --with-as=/home/user/jmr/app/binutils/bin/as --with-ld=/home/user/jmr/app/binutils/bin/ld : (reconfigured)

How-To-Repeat:
; cat ZISAvailTest.java
import java.net.URL;
import java.util.zip.ZipInputStream;

public class ZISAvailTest {
    public static void main(String[] s) throws Exception {
        URL u = new URL("http://www.xwt.org/dist/xwt-0258.jar");
        System.err.println(new ZipInputStream(u.openStream()).available());
    }
}

; gcj ZISAvailTest.java --main=ZISAvailTest      
; ./a.out
0

Whereas Sun's jdk gives:
; javac ZISAvailTest.java
; java ZISAvailTest
1
Comment 1 Tom Tromey 2002-09-25 13:10:04 UTC
Responsible-Changed-From-To: unassigned->tromey
Responsible-Changed-Why: I'm handling the administrivia
Comment 2 Tom Tromey 2002-09-25 13:10:04 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Thanks, I'm checking in your patch.
Comment 3 Tom Tromey 2002-09-25 20:10:42 UTC
From: tromey@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: libgcj/7766
Date: 25 Sep 2002 20:10:42 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	tromey@gcc.gnu.org	2002-09-25 13:10:42
 
 Modified files:
 	libjava        : ChangeLog 
 	libjava/java/util/zip: ZipInputStream.java 
 
 Log message:
 	2002-09-25  Jesse Rosenstock  <jmr@ugcs.caltech.edu>
 	
 	Fix for PR libgcj/7766:
 	* java/util/zip/ZipInputStream.java (entryAtEOF): New field.
 	(getNextEntry): Set it.
 	(closeEntry): Likewise.
 	(read): Likewise.
 	(close): Likewise.
 	(available): Use it.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.1452&r2=1.1453
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/util/zip/ZipInputStream.java.diff?cvsroot=gcc&r1=1.14&r2=1.15