summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorgreen <green@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-17 13:53:11 +0000
committergreen <green@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-17 13:53:11 +0000
commit3c444749be61508dd505edbd635ecb386a1c0df3 (patch)
tree515152a9de25a8f25f7eb4063674565497511b6f /libjava
parentf1d4bfad011aea70822d967d4b6cfa4deab7bbbc (diff)
downloadgcc-3c444749be61508dd505edbd635ecb386a1c0df3.tar.gz
ZipFile.getInputStream returns null if entry not found.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83293 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog3
-rw-r--r--libjava/java/util/zip/ZipFile.java14
2 files changed, 15 insertions, 2 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 1ff76e27d72..8c9abb7e127 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,8 @@
2004-06-17 Anthony Green <green@redhat.com>
+ * java/util/zip/ZipFile.java (getInputStream): Return null if
+ entry not found.
+
* gnu/gcj/runtime/VMClassLoader.java (init): Add extension
directory contents to the class path.
diff --git a/libjava/java/util/zip/ZipFile.java b/libjava/java/util/zip/ZipFile.java
index 50f489fdb5b..25b5785432a 100644
--- a/libjava/java/util/zip/ZipFile.java
+++ b/libjava/java/util/zip/ZipFile.java
@@ -408,8 +408,18 @@ public class ZipFile implements ZipConstants
* uncompressed data. Normally zip entry should be an entry
* returned by getEntry() or entries().
*
+ * This implementation returns null if the requested entry does not
+ * exist. This decision is not obviously correct, however, it does
+ * appear to mirror Sun's implementation, and it is consistant with
+ * their javadoc. On the other hand, the old JCL book, 2nd Edition,
+ * claims that this should return a "non-null ZIP entry". We have
+ * chosen for now ignore the old book, as modern versions of Ant (an
+ * important application) depend on this behaviour. See discussion
+ * in this thread:
+ * http://gcc.gnu.org/ml/java-patches/2004-q2/msg00602.html
+ *
* @param entry the entry to create an InputStream for.
- * @return the input stream.
+ * @return the input stream, or null if the requested entry does not exist.
*
* @exception IOException if a i/o error occured.
* @exception ZipException if the Zip archive is malformed.
@@ -420,7 +430,7 @@ public class ZipFile implements ZipConstants
String name = entry.getName();
ZipEntry zipEntry = (ZipEntry) entries.get(name);
if (zipEntry == null)
- throw new NoSuchElementException(name);
+ return null;
long start = checkLocalHeader(zipEntry);
int method = zipEntry.getMethod();