harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r391073 - in /incubator/harmony/enhanced/classlib/trunk: modules/archive/src/main/java/java/util/zip/ modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/ modules/archive/src/test/java/tests/api/java/util/zip/ native-src/li...
Date Mon, 03 Apr 2006 15:43:02 GMT
Author: gharley
Date: Mon Apr  3 08:42:55 2006
New Revision: 391073

URL: http://svn.apache.org/viewcvs?rev=391073&view=rev
Log:
Fixes for HARMONY-158 and HARMONY-159.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/InflaterTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/DeflaterTest.java
    incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/include/jclprots.h
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/deflater.c
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/inflater.c
    incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/inflater.h
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/include/jclprots.h

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java?rev=391073&r1=391072&r2=391073&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java
Mon Apr  3 08:42:55 2006
@@ -177,10 +177,10 @@
 		if (streamHandle == -1)
 			throw new IllegalStateException();
 
-		return getTotalInImpl(streamHandle);
+		return (int)getTotalInImpl(streamHandle);
 	}
 
-	private native synchronized int getTotalInImpl(long handle);
+	private native synchronized long getTotalInImpl(long handle);
 
 	/**
 	 * Returns the total number of compressed bytes output nby this Deflater.
@@ -191,10 +191,10 @@
 		if (streamHandle == -1)
 			throw new IllegalStateException();
 
-		return getTotalOutImpl(streamHandle);
+		return (int)getTotalOutImpl(streamHandle);
 	}
 
-	private synchronized native int getTotalOutImpl(long handle);
+	private synchronized native long getTotalOutImpl(long handle);
 
 	/**
 	 * Indicates whether or not all bytes of uncompressed input have been
@@ -371,6 +371,30 @@
 	public Deflater(int level) {
 		this(level, false);
 	}
+	
+    /**
+     * return a long int instead of int
+     * @see getTotalIn
+     * @return bytes exactly read by deflater
+     */
+    public synchronized long getBytesRead() {
+        // Throw NPE here
+        if (streamHandle == -1)
+            throw new NullPointerException();
+        return getTotalInImpl(streamHandle);
+    }
+
+    /**
+     * return a long int instead of int
+     * @see getTotalOut
+     * @return bytes exactly write by deflater
+     */
+    public synchronized long getBytesWritten() {
+        // Throw NPE here
+        if (streamHandle == -1)
+            throw new NullPointerException();
+        return getTotalOutImpl(streamHandle);
+    }
 
 	private native long createStream(int level, int strategy1, boolean noHeader1);
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java?rev=391073&r1=391072&r2=391073&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java
Mon Apr  3 08:42:55 2006
@@ -15,7 +15,6 @@
 
 package java.util.zip;
 
-
 /**
  * The Inflater class is used to decompress bytes using the DEFLATE compression
  * algorithm. Inflation is performed by the ZLIB compression library.
@@ -108,11 +107,12 @@
 	public synchronized int getTotalIn() {
 		if (streamHandle == -1)
 			throw new IllegalStateException();
-
-		return getTotalInImpl(streamHandle);
+		long totalIn = getTotalInImpl(streamHandle);
+		return (totalIn <= Integer.MAX_VALUE ? (int) totalIn
+				: Integer.MAX_VALUE);
 	}
 
-	private synchronized native int getTotalInImpl(long handle);
+	private synchronized native long getTotalInImpl(long handle);
 
 	/**
 	 * Returns total number of bytes of input output by the Inflater.
@@ -122,11 +122,12 @@
 	public synchronized int getTotalOut() {
 		if (streamHandle == -1)
 			throw new IllegalStateException();
-
-		return getTotalOutImpl(streamHandle);
+		long totalOut = getTotalOutImpl(streamHandle);
+		return (totalOut <= Integer.MAX_VALUE ? (int) totalOut
+				: Integer.MAX_VALUE);
 	}
 
-	private native synchronized int getTotalOutImpl(long handle);
+	private native synchronized long getTotalOutImpl(long handle);
 
 	/**
 	 * Inflates bytes from current input and stores them in buf.
@@ -294,6 +295,34 @@
 			setInputImpl(buf, off, nbytes, streamHandle);
 		} else
 			throw new ArrayIndexOutOfBoundsException();
+	}
+
+	/**
+	 * Returns a long int of total number of bytes of input read by the
+	 * Inflater.
+	 * 
+	 * @see getTotalIn
+	 * @return Total bytes read
+	 */
+	public synchronized long getBytesRead() {
+		// Throw NPE here
+		if (streamHandle == -1)
+			throw new NullPointerException();
+		return getTotalInImpl(streamHandle);
+	}
+
+	/**
+	 * Returns a long int of total number of bytes of input output by the
+	 * Inflater.
+	 * 
+	 * @see getTotalOut
+	 * @return Total bytes output
+	 */
+	public synchronized long getBytesWritten() {
+		// Throw NPE here
+		if (streamHandle == -1)
+			throw new NullPointerException();
+		return getTotalOutImpl(streamHandle);
 	}
 
 	private native synchronized void setInputImpl(byte[] buf, int off,

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/InflaterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/InflaterTest.java?rev=391073&r1=391072&r2=391073&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/InflaterTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/InflaterTest.java
Mon Apr  3 08:42:55 2006
@@ -28,5 +28,9 @@
     	// Regression test for HARMONY-86
         Inflater inf = new Inflater();
         assertFalse(inf.needsDictionary());
+        assertEquals(0,inf.getTotalIn());
+        assertEquals(0,inf.getTotalOut());
+        assertEquals(0,inf.getBytesRead());
+        assertEquals(0,inf.getBytesWritten());
     } 
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/DeflaterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/DeflaterTest.java?rev=391073&r1=391072&r2=391073&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/DeflaterTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/DeflaterTest.java
Mon Apr  3 08:42:55 2006
@@ -1129,6 +1129,17 @@
 		}
 	}
 
+    /**
+     * @tests java.util.zip.Deflater()
+     */
+    public void test_needsDictionary() {
+        Deflater inf = new Deflater();
+        assertEquals(0, inf.getTotalIn());
+        assertEquals(0, inf.getTotalOut());
+        assertEquals(0, inf.getBytesRead());
+        assertEquals(0, inf.getBytesWritten());
+    }
+    
 	protected void setUp() {
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/include/jclprots.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/include/jclprots.h?rev=391073&r1=391072&r2=391073&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/include/jclprots.h (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/include/jclprots.h Mon
Apr  3 08:42:55 2006
@@ -45,7 +45,7 @@
 /* NativesCommonDeflater*/
 void JNICALL Java_java_util_zip_Deflater_setDictionaryImpl PROTOTYPE(( JNIEnv * env, jobject
recv,  jbyteArray dict, int off, int len, jlong handle));
 void JNICALL Java_java_util_zip_Deflater_resetImpl PROTOTYPE(( JNIEnv * env, jobject recv,
 jlong handle));
-int JNICALL Java_java_util_zip_Deflater_getTotalOutImpl PROTOTYPE(( JNIEnv * env, jobject
recv, jlong handle));
+jlong JNICALL Java_java_util_zip_Deflater_getTotalOutImpl PROTOTYPE(( JNIEnv * env, jobject
recv, jlong handle));
 void JNICALL Java_java_util_zip_Deflater_endImpl PROTOTYPE(( JNIEnv * env, jobject recv,
jlong handle));
 jint JNICALL Java_java_util_zip_Deflater_deflateImpl PROTOTYPE((JNIEnv * env, jobject recv,
jbyteArray buf, int off, int len,
 													 jlong handle, int flushParm));
@@ -53,7 +53,7 @@
 void JNICALL Java_java_util_zip_Deflater_oneTimeInitialization PROTOTYPE((JNIEnv * env, jclass
clazz));
 void JNICALL Java_java_util_zip_Deflater_setInputImpl PROTOTYPE(( JNIEnv * env, jobject recv,
jbyteArray buf, jint off, jint len, jlong handle));
 jlong JNICALL Java_java_util_zip_Deflater_createStream PROTOTYPE(( JNIEnv * env, jobject
recv, jint level, jint strategy, jboolean noHeader));
-jint JNICALL Java_java_util_zip_Deflater_getTotalInImpl PROTOTYPE(( JNIEnv * env, jobject
recv, jlong handle));
+jlong JNICALL Java_java_util_zip_Deflater_getTotalInImpl PROTOTYPE(( JNIEnv * env, jobject
recv, jlong handle));
 jint JNICALL Java_java_util_zip_Deflater_getAdlerImpl PROTOTYPE(( JNIEnv * env, jobject recv,
jlong handle));
 
 /* NativesCommonPlainSocketImpl2*/
@@ -193,9 +193,9 @@
 void JNICALL Java_java_util_zip_Inflater_setDictionaryImpl PROTOTYPE(( JNIEnv * env, jobject
recv,  jbyteArray dict, int off, int len, jlong handle));
 void JNICALL Java_java_util_zip_Inflater_oneTimeInitialization PROTOTYPE((JNIEnv * env, jclass
clazz));
 void JNICALL Java_java_util_zip_Inflater_resetImpl PROTOTYPE(( JNIEnv * env, jobject recv,
jlong handle));
-int JNICALL Java_java_util_zip_Inflater_getTotalOutImpl PROTOTYPE(( JNIEnv * env, jobject
recv, jlong handle));
+jlong JNICALL Java_java_util_zip_Inflater_getTotalOutImpl PROTOTYPE(( JNIEnv * env, jobject
recv, jlong handle));
 jlong JNICALL Java_java_util_zip_Inflater_createStream PROTOTYPE(( JNIEnv * env, jobject
recv, jboolean noHeader));
-int JNICALL Java_java_util_zip_Inflater_getTotalInImpl PROTOTYPE(( JNIEnv * env, jobject
recv, jlong handle));
+jlong JNICALL Java_java_util_zip_Inflater_getTotalInImpl PROTOTYPE(( JNIEnv * env, jobject
recv, jlong handle));
 jint JNICALL Java_java_util_zip_Inflater_getAdlerImpl PROTOTYPE(( JNIEnv * env, jobject recv,
jlong handle));
 
 /* NativesCommonSystem*/

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/deflater.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/deflater.c?rev=391073&r1=391072&r2=391073&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/deflater.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/deflater.c Mon Apr
 3 08:42:55 2006
@@ -51,7 +51,7 @@
   stream->dict = dBytes;
 }
 
-jint JNICALL
+jlong JNICALL
 Java_java_util_zip_Deflater_getTotalInImpl (JNIEnv * env, jobject recv,
 					    jlong handle)
 {
@@ -61,7 +61,7 @@
   return stream->stream->total_in;
 }
 
-int JNICALL
+jlong JNICALL
 Java_java_util_zip_Deflater_getTotalOutImpl (JNIEnv * env, jobject recv,
 					     jlong handle)
 {

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/inflater.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/inflater.c?rev=391073&r1=391072&r2=391073&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/inflater.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/inflater.c Mon Apr
 3 08:42:55 2006
@@ -246,7 +246,7 @@
   (*env)->ThrowNew(env, exceptionClass, message);
 }
 
-int JNICALL
+jlong JNICALL
 Java_java_util_zip_Inflater_getTotalOutImpl (JNIEnv * env, jobject recv,
                                              jlong handle)
 {
@@ -257,7 +257,7 @@
 
 }
 
-int JNICALL
+jlong JNICALL
 Java_java_util_zip_Inflater_getTotalInImpl (JNIEnv * env, jobject recv,
                                             jlong handle)
 {

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/inflater.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/inflater.h?rev=391073&r1=391072&r2=391073&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/inflater.h (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/archive/inflater.h Mon Apr
 3 08:42:55 2006
@@ -47,13 +47,13 @@
 void JNICALL Java_java_util_zip_Inflater_resetImpl (JNIEnv * env,
                                                     jobject recv,
                                                     jlong handle);
-int JNICALL Java_java_util_zip_Inflater_getTotalOutImpl (JNIEnv * env,
+jlong JNICALL Java_java_util_zip_Inflater_getTotalOutImpl (JNIEnv * env,
                                                          jobject recv,
                                                          jlong handle);
 jlong JNICALL Java_java_util_zip_Inflater_createStream (JNIEnv * env,
                                                         jobject recv,
                                                         jboolean noHeader);
-int JNICALL Java_java_util_zip_Inflater_getTotalInImpl (JNIEnv * env,
+jlong JNICALL Java_java_util_zip_Inflater_getTotalInImpl (JNIEnv * env,
                                                         jobject recv,
                                                         jlong handle);
 jint JNICALL Java_java_util_zip_Inflater_getAdlerImpl (JNIEnv * env,

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/include/jclprots.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/include/jclprots.h?rev=391073&r1=391072&r2=391073&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/include/jclprots.h (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/include/jclprots.h Mon Apr
 3 08:42:55 2006
@@ -58,7 +58,7 @@
                 jlong handle));
   void JNICALL Java_java_util_zip_Deflater_resetImpl
     PROTOTYPE ((JNIEnv * env, jobject recv, jlong handle));
-  int JNICALL Java_java_util_zip_Deflater_getTotalOutImpl
+  jlong JNICALL Java_java_util_zip_Deflater_getTotalOutImpl
     PROTOTYPE ((JNIEnv * env, jobject recv, jlong handle));
   void JNICALL Java_java_util_zip_Deflater_endImpl
     PROTOTYPE ((JNIEnv * env, jobject recv, jlong handle));
@@ -76,7 +76,7 @@
   jlong JNICALL Java_java_util_zip_Deflater_createStream
     PROTOTYPE ((JNIEnv * env, jobject recv, jint level, jint strategy,
                 jboolean noHeader));
-  jint JNICALL Java_java_util_zip_Deflater_getTotalInImpl
+  jlong JNICALL Java_java_util_zip_Deflater_getTotalInImpl
     PROTOTYPE ((JNIEnv * env, jobject recv, jlong handle));
   jint JNICALL Java_java_util_zip_Deflater_getAdlerImpl
     PROTOTYPE ((JNIEnv * env, jobject recv, jlong handle));
@@ -316,11 +316,12 @@
     PROTOTYPE ((JNIEnv * env, jclass clazz));
   void JNICALL Java_java_util_zip_Inflater_resetImpl
     PROTOTYPE ((JNIEnv * env, jobject recv, jlong handle));
-  int JNICALL Java_java_util_zip_Inflater_getTotalOutImpl
+
+  jlong JNICALL Java_java_util_zip_Inflater_getTotalOutImpl
     PROTOTYPE ((JNIEnv * env, jobject recv, jlong handle));
   jlong JNICALL Java_java_util_zip_Inflater_createStream
     PROTOTYPE ((JNIEnv * env, jobject recv, jboolean noHeader));
-  int JNICALL Java_java_util_zip_Inflater_getTotalInImpl
+  jlong JNICALL Java_java_util_zip_Inflater_getTotalInImpl
     PROTOTYPE ((JNIEnv * env, jobject recv, jlong handle));
   jint JNICALL Java_java_util_zip_Inflater_getAdlerImpl
     PROTOTYPE ((JNIEnv * env, jobject recv, jlong handle));



Mime
View raw message