[kaffe] CVS kaffe (guilhem): Fix for FileChannelImpl + fixed some problems with zip classes.
Kaffe CVS
cvs-commits at kaffe.org
Sun May 30 09:51:02 PDT 2004
PatchSet 4795
Date: 2004/05/30 16:30:42
Author: guilhem
Branch: HEAD
Tag: (none)
Log:
Fix for FileChannelImpl + fixed some problems with zip classes.
* libraries/javalib/java/util/ZipInputStream.java
(getNextEntry): Reopen the byte stream.
(closeEntry): Close the byte stream.
(close): Close completely the byte stream.
* libraries/javalib/java/util/Inflater.java:
(inflate0): Made private.
* libraries/javalib/java/util/InflaterInputStream.java:
(read): Check whether the stream is closed.
(skip): Improved exception message.
* libraries/clib/nio/FileChannelImpl.c
(Java_gnu_java_nio_channels_FileChannelImpl_read__): Fixed
one byte reading. We have to use 'uint8' for the reading and
then cast it to jint.
(Java_gnu_java_nio_channels_FileChannelImpl_write__I): Fixed
one byte writing. We have to cast jint to uint8 and then write
this byte.
Members:
ChangeLog:1.2364->1.2365
libraries/clib/nio/FileChannelImpl.c:1.5->1.6
libraries/javalib/java/util/zip/Inflater.java:1.7->1.8
libraries/javalib/java/util/zip/InflaterInputStream.java:1.10->1.11
libraries/javalib/java/util/zip/ZipInputStream.java:1.19->1.20
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2364 kaffe/ChangeLog:1.2365
--- kaffe/ChangeLog:1.2364 Sun May 30 10:35:15 2004
+++ kaffe/ChangeLog Sun May 30 16:30:42 2004
@@ -1,3 +1,25 @@
+2004-05-30 Guilhem Lavaux <guilhem at kaffe.org>
+
+ * libraries/javalib/java/util/ZipInputStream.java
+ (getNextEntry): Reopen the byte stream.
+ (closeEntry): Close the byte stream.
+ (close): Close completely the byte stream.
+
+ * libraries/javalib/java/util/Inflater.java:
+ (inflate0): Made private.
+
+ * libraries/javalib/java/util/InflaterInputStream.java:
+ (read): Check whether the stream is closed.
+ (skip): Improved exception message.
+
+ * libraries/clib/nio/FileChannelImpl.c
+ (Java_gnu_java_nio_channels_FileChannelImpl_read__): Fixed
+ one byte reading. We have to use 'uint8' for the reading and
+ then cast it to jint.
+ (Java_gnu_java_nio_channels_FileChannelImpl_write__I): Fixed
+ one byte writing. We have to cast jint to uint8 and then write
+ this byte.
+
2004-05-29 Guilhem Lavaux <guilhem at kaffe.org>
* configure.ac: Check for mprotect. If the host is an HPUX disable
Index: kaffe/libraries/clib/nio/FileChannelImpl.c
diff -u kaffe/libraries/clib/nio/FileChannelImpl.c:1.5 kaffe/libraries/clib/nio/FileChannelImpl.c:1.6
--- kaffe/libraries/clib/nio/FileChannelImpl.c:1.5 Fri May 28 13:40:13 2004
+++ kaffe/libraries/clib/nio/FileChannelImpl.c Sun May 30 16:30:49 2004
@@ -390,7 +390,7 @@
Java_gnu_java_nio_channels_FileChannelImpl_read__(JNIEnv *env, jobject filechannel)
{
int rc;
- jbyte one_byte;
+ uint8 one_byte;
int nativeFd = (int)getFD(env, filechannel);
int ret;
@@ -445,10 +445,11 @@
{
int rc;
int nativeFd = (int)getFD(env, filechannel);
+ uint8 real_byte = byte;
int ret;
do {
- rc = KWRITE(nativeFd, &byte, 1, &ret);
+ rc = KWRITE(nativeFd, &real_byte, 1, &ret);
if (rc != 0 && rc != EINTR)
{
throwIOException(env, rc);
Index: kaffe/libraries/javalib/java/util/zip/Inflater.java
diff -u kaffe/libraries/javalib/java/util/zip/Inflater.java:1.7 kaffe/libraries/javalib/java/util/zip/Inflater.java:1.8
--- kaffe/libraries/javalib/java/util/zip/Inflater.java:1.7 Fri Aug 16 18:04:31 2002
+++ kaffe/libraries/javalib/java/util/zip/Inflater.java Sun May 30 16:30:49 2004
@@ -100,7 +100,7 @@
}
public native synchronized void setDictionary(byte b[], int off, int len);
- public native synchronized int inflate0(byte b[], int off, int len) throws DataFormatException;
+ private native synchronized int inflate0(byte b[], int off, int len) throws DataFormatException;
public native synchronized int getAdler();
public native synchronized int getTotalIn();
public native synchronized int getTotalOut();
Index: kaffe/libraries/javalib/java/util/zip/InflaterInputStream.java
diff -u kaffe/libraries/javalib/java/util/zip/InflaterInputStream.java:1.10 kaffe/libraries/javalib/java/util/zip/InflaterInputStream.java:1.11
--- kaffe/libraries/javalib/java/util/zip/InflaterInputStream.java:1.10 Sat May 1 16:52:49 2004
+++ kaffe/libraries/javalib/java/util/zip/InflaterInputStream.java Sun May 30 16:30:49 2004
@@ -150,7 +150,7 @@
{
if (in == null)
throw new ZipException ("InflaterInputStream is closed");
-
+
len = in.read(buf, 0, buf.length);
if (len < 0)
@@ -183,6 +183,9 @@
*/
public int read(byte[] b, int off, int len) throws IOException
{
+ if (in == null)
+ throw new ZipException ("InflaterInputStream is closed");
+
if (len == 0)
return 0;
@@ -220,7 +223,7 @@
public long skip(long n) throws IOException
{
if (n < 0)
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Argument must be positive");
if (n == 0)
return 0;
Index: kaffe/libraries/javalib/java/util/zip/ZipInputStream.java
diff -u kaffe/libraries/javalib/java/util/zip/ZipInputStream.java:1.19 kaffe/libraries/javalib/java/util/zip/ZipInputStream.java:1.20
--- kaffe/libraries/javalib/java/util/zip/ZipInputStream.java:1.19 Mon Mar 22 11:25:13 2004
+++ kaffe/libraries/javalib/java/util/zip/ZipInputStream.java Sun May 30 16:30:49 2004
@@ -41,6 +41,9 @@
synchronized (this) {
+ // First, open the stream.
+ sinf.setLength(Integer.MAX_VALUE);
+
// Read next signature
int sig = readSig();
switch (sig) {
@@ -149,6 +152,9 @@
// + ", meth=" + entry.method + ", size=" + entry.size
// + ", csize=" + entry.csize + ", crc=" + entry.crc);
}
+
+ // Close the input stream for the rest of the world.
+ sinf.setLength(0);
} finally {
entry = null;
}
@@ -166,6 +172,9 @@
public void close() throws IOException {
closeEntry();
super.close();
+ // Now completely close the byte stream. There may be some
+ // bytes left in the buffer.
+ sinf.setInput(null, 0, 0);
}
private int get16(byte[] buf, int base) {
More information about the kaffe
mailing list