harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r824184 [4/34] - in /harmony/enhanced/classlib/branches/java6: ./ depends/build/ doc/ doc/security/ make/ modules/accessibility/src/main/java/javax/accessibility/ modules/accessibility/src/test/api/java/common/javax/accessibility/ modules/a...
Date Sun, 11 Oct 2009 22:00:56 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java Sun Oct 11 21:59:47 2009
@@ -1,13 +1,13 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *     http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -79,7 +79,7 @@
     /**
      * Constructs a new {@code ZipOutputStream} with the specified output
      * stream.
-     * 
+     *
      * @param p1
      *            the {@code OutputStream} to write the data to.
      */
@@ -90,7 +90,7 @@
     /**
      * Closes the current {@code ZipEntry}, if any, and the underlying output
      * stream. If the stream is already closed this method does nothing.
-     * 
+     *
      * @throws IOException
      *             If an error occurs closing the stream.
      */
@@ -106,7 +106,7 @@
     /**
      * Closes the current {@code ZipEntry}. Any entry terminal data is written
      * to the underlying stream.
-     * 
+     *
      * @throws IOException
      *             If an error occurs closing the entry.
      */
@@ -191,7 +191,7 @@
     /**
      * Indicates that all entries have been written to the stream. Any terminal
      * information is written to the underlying stream.
-     * 
+     *
      * @throws IOException
      *             if an error occurs while terminating the stream.
      */
@@ -235,7 +235,7 @@
      * the entry can then be written using {@code write()}. After data is
      * written {@code closeEntry()} must be called to complete the writing of
      * the entry to the underlying stream.
-     * 
+     *
      * @param ze
      *            the {@code ZipEntry} to store.
      * @throws IOException
@@ -323,7 +323,7 @@
 
     /**
      * Sets the {@code ZipFile} comment associated with the file being written.
-     * 
+     *
      * @param comment
      *            the comment associated with the file.
      */
@@ -338,7 +338,7 @@
      * Sets the compression level to be used for writing entry data. This level
      * may be set on a per entry basis. The level must have a value between -1
      * and 8 according to the {@code Deflater} compression level bounds.
-     * 
+     *
      * @param level
      *            the compression level (ranging from -1 to 8).
      * @see Deflater
@@ -355,7 +355,7 @@
      * Sets the compression method to be used when compressing entry data.
      * method must be one of {@code STORED} (for no compression) or {@code
      * DEFLATED}.
-     * 
+     *
      * @param method
      *            the compression method to use.
      */
@@ -385,7 +385,7 @@
 
     /**
      * Writes data for the current entry to the underlying stream.
-     * 
+     *
      * @exception IOException
      *                If an error occurs writing to the stream
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java Sun Oct 11 21:59:47 2009
@@ -1,13 +1,13 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *     http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,7 @@
 
 /*
  * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
- * All changes made to this file manually will be overwritten 
+ * All changes made to this file manually will be overwritten
  * if this tool runs again. Better make changes in the template file.
  */
 
@@ -43,7 +43,7 @@
  * is looked up, or resource bundle support is not available, the key itself
  * will be returned as the associated message. This means that the <em>KEY</em>
  * should a reasonable human-readable (english) string.
- * 
+ *
  */
 public class Messages {
 
@@ -52,14 +52,15 @@
 
     /**
      * Retrieves a message which has no arguments.
-     * 
+     *
      * @param msg
      *            String the key to look up.
      * @return String the message for that key in the system message bundle.
      */
     static public String getString(String msg) {
-        if (bundle == null)
+        if (bundle == null) {
             return msg;
+        }
         try {
             return bundle.getString(msg);
         } catch (MissingResourceException e) {
@@ -69,7 +70,7 @@
 
     /**
      * Retrieves a message which takes 1 argument.
-     * 
+     *
      * @param msg
      *            String the key to look up.
      * @param arg
@@ -82,7 +83,7 @@
 
     /**
      * Retrieves a message which takes 1 integer argument.
-     * 
+     *
      * @param msg
      *            String the key to look up.
      * @param arg
@@ -95,7 +96,7 @@
 
     /**
      * Retrieves a message which takes 1 character argument.
-     * 
+     *
      * @param msg
      *            String the key to look up.
      * @param arg
@@ -108,7 +109,7 @@
 
     /**
      * Retrieves a message which takes 2 arguments.
-     * 
+     *
      * @param msg
      *            String the key to look up.
      * @param arg1
@@ -123,7 +124,7 @@
 
     /**
      * Retrieves a message which takes several arguments.
-     * 
+     *
      * @param msg
      *            String the key to look up.
      * @param args
@@ -153,7 +154,7 @@
      * To insert the "{" character into the output, use a single backslash
      * character to escape it (i.e. "\{"). The "}" character does not need to be
      * escaped.
-     * 
+     *
      * @param format
      *            String the format to use when printing.
      * @param args
@@ -165,18 +166,20 @@
                 + (args.length * 20));
         String[] argStrings = new String[args.length];
         for (int i = 0; i < args.length; ++i) {
-            if (args[i] == null)
+            if (args[i] == null) {
                 argStrings[i] = "<null>"; //$NON-NLS-1$
-            else
+            } else {
                 argStrings[i] = args[i].toString();
+            }
         }
         int lastI = 0;
         for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
                 lastI)) {
             if (i != 0 && format.charAt(i - 1) == '\\') {
                 // It's escaped, just print and loop.
-                if (i != 1)
+                if (i != 1) {
                     answer.append(format.substring(lastI, i - 1));
+                }
                 answer.append('{');
                 lastI = i + 1;
             } else {
@@ -195,23 +198,25 @@
                     } else {
                         // Got a good one!
                         answer.append(format.substring(lastI, i));
-                        if (argnum >= argStrings.length)
+                        if (argnum >= argStrings.length) {
                             answer.append("<missing argument>"); //$NON-NLS-1$
-                        else
+                        } else {
                             answer.append(argStrings[argnum]);
+                        }
                         lastI = i + 3;
                     }
                 }
             }
         }
-        if (lastI < format.length())
+        if (lastI < format.length()) {
             answer.append(format.substring(lastI, format.length()));
+        }
         return answer.toString();
     }
 
     /**
      * Changes the locale of the messages.
-     * 
+     *
      * @param locale
      *            Locale the locale to change to.
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties Sun Oct 11 21:59:47 2009
@@ -67,4 +67,5 @@
 archive.31={0} failed verification of {1}
 archive.32={0} has invalid digest for {1} in {2}
 archive.33=A length of the encoded header name "{1}" exceeded maximum length {2}
-archive.34=A jar verifier does not support more than one entry with the same name  
+archive.34=A jar verifier does not support more than one entry with the same name
+archive.35=JarFile has been closed

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java Sun Oct 11 21:59:47 2009
@@ -1,13 +1,13 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *     http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,62 +17,113 @@
 
 package org.apache.harmony.archive.util;
 
+/**
+ * Helpers for the archive module.
+ */
 public class Util {
 
-    public static boolean ASCIIIgnoreCaseRegionMatches(String s1, int start1,
-            String s2, int start2, int length) {
-
-        if (s1 != null && s2 != null) {
-            if (start1 < 0 || length > s1.length() - start1) {
-                return false;
-            }
-            if (start2 < 0 || length > s2.length() - start2) {
+    /**
+     * Returns whether the given source string ends with the suffix, ignoring
+     * case and assuming that the strings are ascii encoded.
+     * 
+     * @param source
+     *            the string to match.
+     * @param suffix
+     *            the suffix to test.
+     * @return {@code true} if the source does end with the given suffix, or
+     *         {@code false} if not.
+     */
+    public static boolean asciiEndsWithIgnoreCase(String source, String suffix) {
+        int length = suffix.length();
+        if (length > source.length()) {
+            return false;
+        }
+        int offset = source.length() - length;
+        for (int i = 0; i < length; i++) {
+            char c1 = source.charAt(i + offset);
+            char c2 = suffix.charAt(i);
+            if (c1 != c2 && toASCIIUpperCase(c1) != toASCIIUpperCase(c2)) {
                 return false;
             }
-
-            char c1, c2;
-            for (int i = 0; i < length; i++) {
-                if ((c1 = s1.charAt(start1++)) != (c2 = s2.charAt(start2++))
-                        && toASCIIUpperCase(c1) != toASCIIUpperCase(c2)) {
-                    return false;
-                }
-            }
-            return true;
         }
-        throw new NullPointerException();
+        return true;
     }
 
-    public static final boolean equalsIgnoreCase(byte[] buf1, byte[] buf2) {
+    /**
+     * Compares the given byte arrays and returns whether they are equal,
+     * ignoring case differences and assuming they are ascii-encoded strings.
+     * 
+     * @param buf1
+     *            first byte array to compare.
+     * @param buf2
+     *            second byte array to compare.
+     * @return the result of the comparison.
+     */
+    public static boolean asciiEqualsIgnoreCase(byte[] buf1, byte[] buf2) {
+        if (buf1 == null || buf2 == null) {
+            return false;
+        }
         if (buf1 == buf2) {
             return true;
         }
-
-        if (buf1 == null || buf2 == null || buf1.length != buf2.length) {
+        if (buf1.length != buf2.length) {
             return false;
         }
 
-        byte b1, b2;
-
         for (int i = 0; i < buf1.length; i++) {
-            if ((b1 = buf1[i]) != (b2 = buf2[i])
-                    && toASCIIUpperCase(b1) != toASCIIUpperCase(b2)) {
+            byte b1 = buf1[i];
+            byte b2 = buf2[i];
+            if (b1 != b2 && toASCIIUpperCase(b1) != toASCIIUpperCase(b2)) {
                 return false;
             }
         }
         return true;
     }
 
-    static final char toASCIIUpperCase(char c) {
-        if ('a' <= c && c <= 'z') {
-            return (char) (c - ('a' - 'A'));
+    /**
+     * Compares the given strings and returns whether they are equal, ignoring
+     * case differences and assuming they are ascii-encoded strings.
+     * 
+     * @param s1
+     *            first string to compare.
+     * @param s2
+     *            second string to compare.
+     * @return the result of the comparison.
+     */
+    public static boolean asciiEqualsIgnoreCase(String s1, String s2) {
+        if (s1 == null || s2 == null) {
+            return false;
         }
-        return c;
+        if (s1 == s2) {
+            return true;
+        }
+
+        int length = s1.length();
+        if (length != s2.length()) {
+            return false;
+        }
+
+        for (int i = 0; i < length; i++) {
+            char c1 = s1.charAt(i);
+            char c2 = s2.charAt(i);
+            if (c1 != c2 && toASCIIUpperCase(c1) != toASCIIUpperCase(c2)) {
+                return false;
+            }
+        }
+        return true;
     }
 
-    static final byte toASCIIUpperCase(byte b) {
+    private static final byte toASCIIUpperCase(byte b) {
         if ('a' <= b && b <= 'z') {
             return (byte) (b - ('a' - 'A'));
         }
         return b;
     }
+
+    private static final char toASCIIUpperCase(char c) {
+        if ('a' <= c && c <= 'z') {
+            return (char) (c - ('a' - 'A'));
+        }
+        return c;
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/shared/inflater.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/shared/inflater.c?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/shared/inflater.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/shared/inflater.c Sun Oct 11 21:59:47 2009
@@ -66,7 +66,10 @@
   jstream->dict = NULL;
   jstream->inaddr = NULL;
 
-  /*Unable to find official doc that this is the way to avoid zlib header use. However doc in zipsup.c claims it is so. */
+  /*
+   * In the range 8..15 for checked, or -8..-15 for unchecked inflate. Unchecked
+   * is appropriate for formats like zip that do their own validity checking.
+   */
   if (noHeader)
     wbits = wbits / -1;
   err = inflateInit2 (stream, wbits);   /*Window bits to use. 15 is fastest but consumes the most memory */

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/shared/zip.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/shared/zip.c?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/shared/zip.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/shared/zip.c Sun Oct 11 21:59:47 2009
@@ -68,245 +68,6 @@
   throwNewExceptionByName(env, "java/util/zip/ZipException", message);
 }
 
-JNIEXPORT jint JNICALL
-Java_java_util_zip_ZipFile_openZipImpl (JNIEnv * env, jobject recv,
-                                        jbyteArray zipName)
-{
-  VMI_ACCESS_FROM_ENV (env);
-  PORT_ACCESS_FROM_ENV (env);
-
-  I_32 retval;
-  JCLZipFile *jclZipFile;
-  JCLZipFileLink *zipfileHandles;
-  jsize length;
-  char pathCopy[HyMaxPath];
-#ifndef HY_ZIP_API
-  HyZipCachePool *zipCachePool;
-#else /* HY_ZIP_API */
-  VMIZipFunctionTable *zipFuncs;
-#endif /* HY_ZIP_API */
-
-  jclZipFile = jclmem_allocate_memory (env, sizeof (*jclZipFile));
-  if (!jclZipFile)
-    return 3;
-
-  length = (*env)->GetArrayLength (env, zipName);
-  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
-  ((*env)->GetByteArrayRegion (env, zipName, 0, length, (jbyte*)pathCopy));
-  pathCopy[length++] = '\0';
-  ioh_convertToPlatform (pathCopy);
-
-#ifndef HY_ZIP_API
-  /* Open the zip file (caching will be managed automatically by zipsup) */
-  zipCachePool = (*VMI)->GetZipCachePool (VMI);
-  retval =
-    zip_openZipFile (privatePortLibrary, pathCopy, &(jclZipFile->hyZipFile),
-                     zipCachePool);
-#else /* HY_ZIP_API */
-  /* Open the zip file (caching will be managed automatically) */
-  zipFuncs = (*VMI)->GetZipFunctions(VMI);
-  retval = zipFuncs->zip_openZipFile(VMI, pathCopy, &(jclZipFile->hyZipFile), ZIP_FLAG_OPEN_CACHE);
-#endif /* HY_ZIP_API */
-
-  if (retval)
-    {
-      jclmem_free_memory (env, jclZipFile);     /* free on fail */
-
-      if (retval == ZIP_ERR_FILE_OPEN_ERROR)
-        return 1;
-      else
-        return 2;
-    }
-
-  /* Add the zipFile we just allocated to the list of zip files -- we will
-   * free this on UnLoad if its not already free'd.
-   */
-  zipfileHandles = JCL_CACHE_GET (env, zipfile_handles);
-  MUTEX_ENTER (zipfileHandles->mutex);
-  jclZipFile->last = (JCLZipFile *) zipfileHandles;
-  jclZipFile->next = zipfileHandles->next;
-  if (zipfileHandles->next != NULL)
-    zipfileHandles->next->last = jclZipFile;
-  zipfileHandles->next = jclZipFile;
-  MUTEX_EXIT (zipfileHandles->mutex);
-
-  (*env)->SetLongField (env, recv,
-                        JCL_CACHE_GET (env,
-                                       FID_java_util_zip_ZipFile_descriptor),
-			            ((IDATA) jclZipFile));
-  return 0;
-}
-
-JNIEXPORT jobject JNICALL
-Java_java_util_zip_ZipFile_getEntryImpl (JNIEnv * env, jobject recv,
-                                         jlong zipPointer, jstring entryName)
-{
-#ifdef HY_ZIP_API
-  VMI_ACCESS_FROM_ENV(env);
-#else
-  PORT_ACCESS_FROM_ENV (env);
-#endif /* HY_ZIP_API */
-
-  I_32 retval;
-  I_32 extraval;
-#ifdef HY_ZIP_API
-  VMIZipFile *zipFile;
-  VMIZipEntry zipEntry;
-#else
-  HyZipFile *zipFile;
-  HyZipEntry zipEntry;
-#endif
-  jobject java_ZipEntry, extra;
-  jclass entryClass;
-  jmethodID mid;
-  const char *entryCopy;
-  JCLZipFile *jclZipFile = (JCLZipFile *) (IDATA) zipPointer;
-#ifdef HY_ZIP_API
-  VMIZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
-#endif /* HY_ZIP_API */
-
-  if (jclZipFile == (void *) -1)
-    {
-      throwNewIllegalStateException (env, "");
-      return NULL;
-    }
-  zipFile = &(jclZipFile->hyZipFile);
-  entryCopy = (*env)->GetStringUTFChars (env, entryName, NULL);
-  if (entryCopy == NULL)
-    return (jobject) NULL;
-
-#ifndef HY_ZIP_API
-  zip_initZipEntry (PORTLIB, &zipEntry);
-  retval = zip_getZipEntry (PORTLIB, zipFile, &zipEntry, entryCopy, TRUE);
-#else /* HY_ZIP_API */
-  zipFuncs->zip_initZipEntry (VMI, &zipEntry);
-  retval = zipFuncs->zip_getZipEntry (VMI, zipFile, &zipEntry, entryCopy, ZIP_FLAG_FIND_DIRECTORY|ZIP_FLAG_READ_DATA_POINTER);
-#endif /* HY_ZIP_API */
-  (*env)->ReleaseStringUTFChars (env, entryName, entryCopy);
-  if (retval)
-    {
-#ifndef HY_ZIP_API
-      zip_freeZipEntry (PORTLIB, &zipEntry);
-#else /* HY_ZIP_API */
-	  zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
-#endif /* HY_ZIP_API */
-      return (jobject) NULL;
-    }
-
-  extra = NULL;
-  if (zipEntry.extraFieldLength > 0)
-    {
-      extraval =
-#ifndef HY_ZIP_API
-        zip_getZipEntryExtraField (PORTLIB, zipFile, &zipEntry, NULL,
-#else /* HY_ZIP_API */
-	    zipFuncs->zip_getZipEntryExtraField (VMI, zipFile, &zipEntry, NULL,
-#endif /* HY_ZIP_API */
-                                 zipEntry.extraFieldLength);
-      if (extraval || zipEntry.extraField == NULL)
-        {
-#ifndef HY_ZIP_API
-          zip_freeZipEntry (PORTLIB, &zipEntry);
-#else /* HY_ZIP_API */
-    	  zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
-#endif /* HY_ZIP_API */
-          if (extraval)
-            {
-              char buf[50];
-              sprintf (buf, "Error %d getting extra field of zip entry", extraval);
-              throwNewInternalError (env, buf);
-            }
-          return (jobject) NULL;
-        }
-      extra = ((*env)->NewByteArray (env, zipEntry.extraFieldLength));
-      if (((*env)->ExceptionCheck (env)))
-        {
-#ifndef HY_ZIP_API
-          zip_freeZipEntry (PORTLIB, &zipEntry);
-#else /* HY_ZIP_API */
-    	  zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
-#endif /* HY_ZIP_API */
-          return (jobject) NULL;
-        }
-      ((*env)->
-       SetByteArrayRegion (env, extra, 0, zipEntry.extraFieldLength,
-                           (jbyte*)zipEntry.extraField));
-    }
-
-  entryClass = JCL_CACHE_GET (env, CLS_java_util_zip_ZipEntry);
-  entryClass = (*env)->NewLocalRef(env, entryClass);
-  if (entryClass == NULL) {
-#ifndef HY_ZIP_API
-    zip_freeZipEntry (PORTLIB, &zipEntry);
-#else /* HY_ZIP_API */
-    zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
-#endif /* HY_ZIP_API */
-    return (jobject) NULL;
-  }
-  mid = JCL_CACHE_GET (env, MID_java_util_zip_ZipEntry_init);
-  /* Build a new ZipEntry from the C struct */
-  java_ZipEntry = ((*env)->NewObject (env, entryClass, mid, entryName, NULL,
-                                      extra,
-                                      (jlong) zipEntry.lastModTime,
-                                      (jlong) zipEntry.uncompressedSize,
-                                      (jlong) zipEntry.compressedSize,
-                                      (jlong) zipEntry.crc32,
-                                      zipEntry.compressionMethod,
-                                      (jlong) zipEntry.lastModDate,
-                                      (jlong) zipEntry.dataPointer));
-#ifndef HY_ZIP_API
-  zip_freeZipEntry (PORTLIB, &zipEntry);
-#else /* HY_ZIP_API */
-  zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
-#endif /* HY_ZIP_API */
-  return java_ZipEntry;
-}
-
-JNIEXPORT void JNICALL
-Java_java_util_zip_ZipFile_closeZipImpl (JNIEnv * env, jobject recv, jlong zipPointer)
-{
-  PORT_ACCESS_FROM_ENV (env);
-#ifdef HY_ZIP_API
-  VMI_ACCESS_FROM_ENV(env);
-#endif /* HY_ZIP_API */
-
-  I_32 retval = 0;
-  jfieldID descriptorFID;
-  JCLZipFileLink *zipfileHandles;
-  JCLZipFile *jclZipFile = (JCLZipFile *) (IDATA) zipPointer;
-#ifdef HY_ZIP_API
-  VMIZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
-#endif /* HY_ZIP_API */
-
-  if (jclZipFile != (void *) -1)
-    {
-      retval =
-#ifndef HY_ZIP_API
-        zip_closeZipFile (privatePortLibrary, &(jclZipFile->hyZipFile));
-#else /* HY_ZIP_API */
-        zipFuncs->zip_closeZipFile (VMI, &(jclZipFile->hyZipFile));
-#endif /* HY_ZIP_API */
-      descriptorFID = JCL_CACHE_GET (env, FID_java_util_zip_ZipFile_descriptor);
-      (*env)->SetLongField (env, recv, descriptorFID, -1);
-
-      /* Free the zip struct */
-	  zipfileHandles = JCL_CACHE_GET (env, zipfile_handles);
-      MUTEX_ENTER (zipfileHandles->mutex);
-      if (jclZipFile->last != NULL)
-        jclZipFile->last->next = jclZipFile->next;
-      if (jclZipFile->next != NULL)
-        jclZipFile->next->last = jclZipFile->last;
-      MUTEX_EXIT (zipfileHandles->mutex);
-
-      jclmem_free_memory (env, jclZipFile);
-      if (retval)
-        {
-          throwJavaZIOException (env, "");
-          return;
-        }
-    }
-}
-
 /**
   * Throw java.lang.IllegalStateException
   */
@@ -325,304 +86,4 @@
   throwNewExceptionByName(env, "java/lang/IllegalArgumentException", message);
 }
 
-JNIEXPORT void JNICALL
-Java_java_util_zip_ZipFile_ntvinit (JNIEnv * env, jclass cls)
-{
-  PORT_ACCESS_FROM_ENV (env);
-  jmethodID mid;
-  jfieldID descriptorFID;
-  jclass javaClass;
-  JCLZipFileLink *zipfileHandles;
-
-  javaClass = (*env)->FindClass (env, "java/util/zip/ZipEntry");
-  javaClass = (*env)->NewGlobalRef (env, javaClass);
-  if (!javaClass)
-    return;
-  mid =
-    ((*env)->
-     GetMethodID (env, javaClass, "<init>",
-                  "(Ljava/lang/String;Ljava/lang/String;[BJJJJIJJ)V"));
-  if (!mid)
-    return;
-  JCL_CACHE_SET (env, CLS_java_util_zip_ZipEntry, javaClass);
-  JCL_CACHE_SET (env, MID_java_util_zip_ZipEntry_init, mid);
-
-  descriptorFID = (*env)->GetFieldID (env, cls, "descriptor", "J");
-  if (!descriptorFID)
-    return;
-  JCL_CACHE_SET (env, FID_java_util_zip_ZipFile_descriptor, descriptorFID);
-
-  javaClass = (*env)->FindClass (env, "java/util/zip/ZipFile$ZFEnum");
-  if (!javaClass)
-    return;
-  descriptorFID =
-    (*env)->GetFieldID (env, javaClass, "nextEntryPointer", "J");
-  if (!descriptorFID)
-    return;
-  JCL_CACHE_SET (env, FID_java_util_zip_ZipFile_nextEntryPointer,
-                 descriptorFID);
-
-  zipfileHandles = jclmem_allocate_memory (env, sizeof (JCLZipFileLink));
-  if (!zipfileHandles)
-    return;
-  zipfileHandles->last = NULL;
-  zipfileHandles->next = NULL;
-  MUTEX_INIT (zipfileHandles->mutex);
-  JCL_CACHE_SET (env, zipfile_handles, zipfileHandles);
-}
-
-JNIEXPORT jlong JNICALL
-Java_java_util_zip_ZipFile_00024ZFEnum_resetZip (JNIEnv * env, jobject recv,
-                                                 jlong descriptor)
-{
-#ifdef HY_ZIP_API
-  VMI_ACCESS_FROM_ENV(env);
-#else
-  PORT_ACCESS_FROM_ENV (env);
-#endif /* HY_ZIP_API */
-
-  IDATA nextEntryPointer;
-  JCLZipFile *jclZipFile = (JCLZipFile *) (IDATA) descriptor;
-#ifdef HY_ZIP_API
-  VMIZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
-#endif /* HY_ZIP_API */
-
-  if (jclZipFile == (void *) -1)
-    {
-      throwNewIllegalStateException (env, "");
-      return 0;
-    }
-#ifndef HY_ZIP_API
-  zip_resetZipFile (privatePortLibrary,
-#else /* HY_ZIP_API */
-  zipFuncs->zip_resetZipFile (VMI,
-#endif /* HY_ZIP_API */
-		    &(jclZipFile->hyZipFile), 
-                    &nextEntryPointer);
-  return nextEntryPointer;
-}
-
-JNIEXPORT jobject JNICALL
-Java_java_util_zip_ZipFile_00024ZFEnum_getNextEntry (JNIEnv * env,
-                                                     jobject recv,
-                                                     jlong descriptor,
-                                                     jlong nextEntry)
-{
-  PORT_ACCESS_FROM_ENV (env);
-#ifdef HY_ZIP_API
-  VMI_ACCESS_FROM_ENV(env);
-#endif /* HY_ZIP_API */
-
-  I_32 retval;
-  I_32 extraval;
-#ifdef HY_ZIP_API
-  VMIZipFile *zipFile;
-  VMIZipEntry zipEntry;
-#else
-  HyZipFile *zipFile;
-  HyZipEntry zipEntry;
-#endif
-  jobject java_ZipEntry, extra;
-  jclass javaClass;
-  jmethodID mid;
-  jstring entryName = NULL;
-  IDATA nextEntryPointer;
-  JCLZipFile *jclZipFile = (JCLZipFile *) (IDATA) descriptor;
-#ifdef HY_ZIP_API
-  VMIZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
-#endif /* HY_ZIP_API */
-
-  if (jclZipFile == (void *) -1)
-    {
-      throwNewIllegalStateException (env, "");
-      return NULL;
-    }
-  zipFile = &(jclZipFile->hyZipFile);
-#ifndef HY_ZIP_API
-  zip_initZipEntry (PORTLIB, &zipEntry);
-#else /* HY_ZIP_API */
-  zipFuncs->zip_initZipEntry (VMI, &zipEntry);
-#endif /* HY_ZIP_API */
-
-  nextEntryPointer = (IDATA) nextEntry;
-  retval =
-#ifndef HY_ZIP_API
-    zip_getNextZipEntry (PORTLIB, zipFile, &zipEntry, &nextEntryPointer);
-#else /* HY_ZIP_API */
-    zipFuncs->zip_getNextZipEntry (VMI, zipFile, &zipEntry, &nextEntryPointer, ZIP_FLAG_READ_DATA_POINTER);
-#endif /* HY_ZIP_API */
-  if (retval)
-    {
-      if (retval != ZIP_ERR_NO_MORE_ENTRIES)
-        {
-          char buf[40];
-          sprintf (buf, "Error %d getting next zip entry", retval);
-          throwNewInternalError (env, buf);
-        }
-      return (jobject) NULL;
-    }
-
-  /* Build a new ZipEntry from the C struct */
-  entryName = ((*env)->NewStringUTF (env, (const char*)zipEntry.filename));
-
-  if (((*env)->ExceptionCheck (env)))
-    return NULL;
-
-  extra = NULL;
-  if (zipEntry.extraFieldLength > 0)
-    {
-      extraval =
-#ifndef HY_ZIP_API
-        zip_getZipEntryExtraField (PORTLIB, zipFile, &zipEntry, NULL,
-#else /* HY_ZIP_API */
-        zipFuncs->zip_getZipEntryExtraField (VMI, zipFile, &zipEntry, NULL,
-#endif /* HY_ZIP_API */
-                                 zipEntry.extraFieldLength);
-      if (extraval || zipEntry.extraField == NULL)
-        {
-#ifndef HY_ZIP_API
-          zip_freeZipEntry (PORTLIB, &zipEntry);
-#else /* HY_ZIP_API */
-    	  zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
-#endif /* HY_ZIP_API */
-          if (extraval)
-            {
-              char buf[50];
-              sprintf (buf, "Error %d getting extra field of zip entry", extraval);
-              throwNewInternalError (env, buf);
-            }
-          return (jobject) NULL;
-        }
-      extra = ((*env)->NewByteArray (env, zipEntry.extraFieldLength));
-      if (((*env)->ExceptionCheck (env)))
-        {
-          /* free the extraField entry */
-#ifndef HY_ZIP_API
-          zip_freeZipEntry (PORTLIB, &zipEntry);
-#else /* HY_ZIP_API */
-          zipFuncs->zip_freeZipEntry (VMI, &zipEntry); /* not valid zipEntry (-1) */
-#endif /* HY_ZIP_API */
-          return NULL;
-        }
-      ((*env)->
-       SetByteArrayRegion (env, extra, 0, zipEntry.extraFieldLength,
-                           (jbyte*)zipEntry.extraField));
-      jclmem_free_memory (env, zipEntry.extraField);
-      zipEntry.extraField = NULL;
-    }
-
-  javaClass = JCL_CACHE_GET (env, CLS_java_util_zip_ZipEntry);
-  mid = JCL_CACHE_GET (env, MID_java_util_zip_ZipEntry_init);
-  java_ZipEntry = ((*env)->NewObject (env, javaClass, mid, entryName, NULL,     /* comment */
-                                      extra,
-                                      (jlong) zipEntry.lastModTime,
-                                      (jlong) zipEntry.uncompressedSize,
-                                      (jlong) zipEntry.compressedSize,
-                                      (jlong) zipEntry.crc32,
-                                      zipEntry.compressionMethod,
-                                      (jlong) zipEntry.lastModDate,
-                                      (jlong) zipEntry.dataPointer));
-#ifndef HY_ZIP_API
-  zip_freeZipEntry (PORTLIB, &zipEntry);
-#else /* HY_ZIP_API */
-  zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
-#endif /* HY_ZIP_API */
-  (*env)->SetLongField (env, recv,
-                        JCL_CACHE_GET (env,
-                                       FID_java_util_zip_ZipFile_nextEntryPointer),
-                        nextEntryPointer);
-  return java_ZipEntry;
-}
-
-JNIEXPORT jbyteArray JNICALL
-Java_java_util_zip_ZipFile_inflateEntryImpl2 (JNIEnv * env, jobject recv,
-					                          jlong descriptor,
-                                              jstring entryName)
-{
-#ifdef HY_ZIP_API
-  VMI_ACCESS_FROM_ENV(env);
-#endif /* HY_ZIP_API */
-  PORT_ACCESS_FROM_ENV (env);
-
-  I_32 retval;
-#ifdef HY_ZIP_API
-  VMIZipFile *zipFile;
-  VMIZipEntry zipEntry;
-#else
-  HyZipFile *zipFile;
-  HyZipEntry zipEntry;
-#endif
-  const char *entryCopy;
-  jbyteArray buf;
-  JCLZipFile *jclZipFile = (JCLZipFile *) (IDATA) descriptor;
-#ifdef HY_ZIP_API
-  VMIZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
-#endif /* HY_ZIP_API */
-
-  /* Build the zipFile */
-  if (jclZipFile == (void *) -1)
-    {
-      throwNewIllegalStateException (env, "");
-      return NULL;
-    }
-  zipFile = &(jclZipFile->hyZipFile);
-  entryCopy = (*env)->GetStringUTFChars (env, entryName, NULL);
-  if (entryCopy == NULL)
-    return NULL;
-
-#ifndef HY_ZIP_API
-  zip_initZipEntry (privatePortLibrary, &zipEntry);
-#else /* HY_ZIP_API */
-  zipFuncs->zip_initZipEntry (VMI, &zipEntry);
-#endif /* HY_ZIP_API */
-  retval =
-#ifndef HY_ZIP_API
-    zip_getZipEntry (privatePortLibrary, zipFile, &zipEntry, entryCopy, TRUE);
-#else /* HY_ZIP_API */
-    zipFuncs->zip_getZipEntry (VMI, zipFile, &zipEntry, entryCopy, ZIP_FLAG_FIND_DIRECTORY|ZIP_FLAG_READ_DATA_POINTER);
-#endif /* HY_ZIP_API */
-  (*env)->ReleaseStringUTFChars (env, entryName, entryCopy);
-  if (retval)
-    {
-#ifndef HY_ZIP_API
-      zip_freeZipEntry (privatePortLibrary, &zipEntry);
-#else /* HY_ZIP_API */
-      zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
-#endif /* HY_ZIP_API */
-      if (retval == ZIP_ERR_OUT_OF_MEMORY)
-        throwNewOutOfMemoryError (env, "");
-      return NULL;
-    }
-
-  buf = (*env)->NewByteArray (env, zipEntry.uncompressedSize);
-  if (!buf)
-    {
-      throwNewOutOfMemoryError (env, "");
-      return NULL;
-    }
 
-  retval =
-#ifndef HY_ZIP_API
-    zip_getZipEntryData (privatePortLibrary, zipFile, &zipEntry, NULL,
-#else /* HY_ZIP_API */
-    zipFuncs->zip_getZipEntryData (VMI, zipFile, &zipEntry, NULL,
-#endif /* HY_ZIP_API */
-                         zipEntry.uncompressedSize);
-  if (retval == 0)
-    (*env)->SetByteArrayRegion (env, buf, 0, zipEntry.uncompressedSize,
-                                (jbyte*)zipEntry.data);
-#ifndef HY_ZIP_API
-  zip_freeZipEntry (privatePortLibrary, &zipEntry);
-#else /* HY_ZIP_API */
-  zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
-#endif /* HY_ZIP_API */
-  if (!retval)
-    return buf;
-
-  if (retval == ZIP_ERR_OUT_OF_MEMORY)
-    throwNewOutOfMemoryError (env, "");
-  else
-    throwJavaZIOException (env, "");
-
-  return NULL;
-}

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/unix/exports.txt?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/unix/exports.txt (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/native/archive/unix/exports.txt Sun Oct 11 21:59:47 2009
@@ -24,12 +24,5 @@
 Java_java_util_zip_Inflater_resetImpl
 Java_java_util_zip_Inflater_setDictionaryImpl
 Java_java_util_zip_Inflater_setInputImpl
-Java_java_util_zip_ZipFile_00024ZFEnum_getNextEntry
-Java_java_util_zip_ZipFile_00024ZFEnum_resetZip
-Java_java_util_zip_ZipFile_closeZipImpl
-Java_java_util_zip_ZipFile_getEntryImpl
-Java_java_util_zip_ZipFile_inflateEntryImpl2
-Java_java_util_zip_ZipFile_ntvinit
-Java_java_util_zip_ZipFile_openZipImpl
 JNI_OnLoad
 JNI_OnUnload

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java-internal/org/apache/harmony/archive/util/UtilTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java-internal/org/apache/harmony/archive/util/UtilTest.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java-internal/org/apache/harmony/archive/util/UtilTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java-internal/org/apache/harmony/archive/util/UtilTest.java Sun Oct 11 21:59:47 2009
@@ -43,44 +43,27 @@
         }
     }
 
-    public void testASCIIIgnoreCaseRegionMatches() {
+    public void testasciiEndsWithIgnoreCase() {
         final String s1 = ASCII_ALPHABET_LC;
         final String s2 = ASCII_ALPHABET_UC;
-        for (int i = 0; i < s1.length(); i++) {
-            assertTrue(Util.ASCIIIgnoreCaseRegionMatches(s1, i, s2, i, s1
-                    .length()
-                    - i));
-        }
-    }
-
-    public void testToASCIIUpperCaseByte() {
-        for (int i = 0; i < ASCII_ALPHABET_LC_BYTES.length; i++) {
-            assertEquals(ASCII_ALPHABET_UC_BYTES[i], Util
-                    .toASCIIUpperCase(ASCII_ALPHABET_LC_BYTES[i]));
-        }
-        for (int i = 0; i < ASCII_ALPHABET_UC_BYTES.length; i++) {
-            assertEquals(ASCII_ALPHABET_UC_BYTES[i], Util
-                    .toASCIIUpperCase(ASCII_ALPHABET_UC_BYTES[i]));
-        }
+        assertTrue(Util.asciiEndsWithIgnoreCase(s1, s2));
+        assertTrue(Util.asciiEndsWithIgnoreCase(s2, s1));
+        assertTrue(Util.asciiEndsWithIgnoreCase(s1, "wxyz"));
     }
 
-    public void testToASCIIUpperCaseChar() {
-        for (int i = 0; i < ASCII_ALPHABET_LC.length(); i++) {
-            assertEquals(ASCII_ALPHABET_UC.charAt(i), Util
-                    .toASCIIUpperCase(ASCII_ALPHABET_LC.charAt(i)));
-        }
-        for (int i = 0; i < ASCII_ALPHABET_UC.length(); i++) {
-            assertEquals(ASCII_ALPHABET_UC.charAt(i), Util
-                    .toASCIIUpperCase(ASCII_ALPHABET_UC.charAt(i)));
-        }
+    public void testasciiEqualsIgnoreCase() {
+        final String s1 = ASCII_ALPHABET_LC;
+        final String s2 = ASCII_ALPHABET_UC;
+        assertTrue(Util.asciiEqualsIgnoreCase(s1, s2));
+        assertTrue(Util.asciiEqualsIgnoreCase(s2, s1));
     }
 
     public void testEqualsIgnoreCaseByteArrayByteArray() {
-        assertTrue(Util.equalsIgnoreCase(ASCII_ALPHABET_LC_BYTES,
+        assertTrue(Util.asciiEqualsIgnoreCase(ASCII_ALPHABET_LC_BYTES,
                 ASCII_ALPHABET_LC_BYTES));
-        assertTrue(Util.equalsIgnoreCase(ASCII_ALPHABET_LC_BYTES,
+        assertTrue(Util.asciiEqualsIgnoreCase(ASCII_ALPHABET_LC_BYTES,
                 ASCII_ALPHABET_UC_BYTES));
-        assertTrue(Util.equalsIgnoreCase(ASCII_ALPHABET_UC_BYTES,
+        assertTrue(Util.asciiEqualsIgnoreCase(ASCII_ALPHABET_UC_BYTES,
                 ASCII_ALPHABET_UC_BYTES));
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java Sun Oct 11 21:59:47 2009
@@ -65,6 +65,18 @@
 
     private File resources;
 
+    private final String jarName = "hyts_patch.jar"; // a 'normal' jar file
+
+    private final String entryName = "foo/bar/A.class";
+
+    private final String emptyEntryJar = "EmptyEntries_signed.jar";
+
+    private final String emptyEntry1 = "subfolder/internalSubset01.js";
+
+    private final String emptyEntry2 = "svgtest.js";
+
+    private final String emptyEntry3 = "svgunit.js";
+
     @Override
     protected void setUp() {
         resources = Support_Resources.createTempFolder();
@@ -122,6 +134,72 @@
         }
     }
 
+    public void test_getEntryLjava_lang_String() throws IOException {
+        try {
+            Support_Resources.copyFile(resources, null, jarName);
+            JarFile jarFile = new JarFile(new File(resources, jarName));
+            assertEquals("Error in returned entry", 311, jarFile.getEntry(
+                    entryName).getSize());
+            jarFile.close();
+        } catch (Exception e) {
+            fail("Exception during test: " + e.toString());
+        }
+
+        Support_Resources.copyFile(resources, null, jarName);
+        JarFile jarFile = new JarFile(new File(resources, jarName));
+        Enumeration<JarEntry> enumeration = jarFile.entries();
+        assertTrue(enumeration.hasMoreElements());
+        while (enumeration.hasMoreElements()) {
+            JarEntry je = enumeration.nextElement();
+            jarFile.getEntry(je.getName());
+        }
+
+        enumeration = jarFile.entries();
+        assertTrue(enumeration.hasMoreElements());
+        JarEntry je = enumeration.nextElement();
+        try {
+            jarFile.close();
+            jarFile.getEntry(je.getName());
+            // fail("IllegalStateException expected.");
+        } catch (IllegalStateException ee) { // Per documentation exception
+            // may be thrown.
+            // expected
+        }
+    }
+
+    public void test_getJarEntryLjava_lang_String() throws IOException {
+        try {
+            Support_Resources.copyFile(resources, null, jarName);
+            JarFile jarFile = new JarFile(new File(resources, jarName));
+            assertEquals("Error in returned entry", 311, jarFile.getJarEntry(
+                    entryName).getSize());
+            jarFile.close();
+        } catch (Exception e) {
+            fail("Exception during test: " + e.toString());
+        }
+
+        Support_Resources.copyFile(resources, null, jarName);
+        JarFile jarFile = new JarFile(new File(resources, jarName));
+        Enumeration<JarEntry> enumeration = jarFile.entries();
+        assertTrue(enumeration.hasMoreElements());
+        while (enumeration.hasMoreElements()) {
+            JarEntry je = enumeration.nextElement();
+            jarFile.getJarEntry(je.getName());
+        }
+
+        enumeration = jarFile.entries();
+        assertTrue(enumeration.hasMoreElements());
+        JarEntry je = enumeration.nextElement();
+        try {
+            jarFile.close();
+            jarFile.getJarEntry(je.getName());
+            // fail("IllegalStateException expected.");
+        } catch (IllegalStateException ee) { // Per documentation exception
+            // may be thrown.
+            // expected
+        }
+    }
+
     /**
      * @tests java.util.jar.JarFile#getJarEntry(java.lang.String)
      */
@@ -310,7 +388,7 @@
         jar = new JarFile(signedFile);
         entry = jar.getJarEntry(JAR4_SIGNED_ENTRY);
         in = jar.getInputStream(entry);
-        in.read(new byte[(int) entry.getSize() - 1]);
+        readExactly(in, (int) entry.getSize() - 1);
         assertNull(entry.getCertificates());
         in.read();
         assertNotNull(entry.getCertificates());
@@ -320,7 +398,7 @@
         entry = jar.getJarEntry(JAR4_SIGNED_ENTRY);
         entry.setSize(entry.getSize() - 1);
         in = jar.getInputStream(entry);
-        in.read(new byte[(int) entry.getSize() - 1]);
+        readExactly(in, (int) entry.getSize() - 1);
         assertNull(entry.getCertificates());
         try {
             in.read();
@@ -331,6 +409,19 @@
         assertEquals(-1, in.read());
     }
 
+    /**
+     * Performs as many read() calls as necessary to read {@code numBytes} from
+     * the stream. Should the stream exhaust early, this method will fail.
+     */
+    private void readExactly(InputStream in, int numBytes) throws IOException {
+        byte[] buffer = new byte[1024];
+        while (numBytes > 0) {
+            int read = in.read(buffer, 0, Math.min(numBytes, 1024));
+            assertTrue(read != -1);
+            numBytes -= read;
+        }
+    }
+
     /*
      * The jar created by 1.4 which does not provide a
      * algorithm-Digest-Manifest-Main-Attributes entry in .SF file.
@@ -551,4 +642,23 @@
         assertNull(is);
         jf.close(); 
     }
+
+    public void testJarVerificationEmptyEntry() throws IOException {
+        Support_Resources.copyFile(resources, null, emptyEntryJar);
+        File f = new File(resources, emptyEntryJar);
+
+        JarFile jarFile = new JarFile(f);
+
+        ZipEntry zipEntry = jarFile.getJarEntry(emptyEntry1);
+        int res = jarFile.getInputStream(zipEntry).read(new byte[100], 0, 100);
+        assertEquals("Wrong length of empty jar entry", -1, res);
+
+        zipEntry = jarFile.getJarEntry(emptyEntry2);
+        res = jarFile.getInputStream(zipEntry).read(new byte[100], 0, 100);
+        assertEquals("Wrong length of empty jar entry", -1, res);
+
+        zipEntry = jarFile.getJarEntry(emptyEntry3);
+        res = jarFile.getInputStream(zipEntry).read();
+        assertEquals("Wrong length of empty jar entry", -1, res);
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java Sun Oct 11 21:59:47 2009
@@ -390,4 +390,25 @@
         jin.close();
     }    
 
+    public void test_getNextEntry() throws Exception {
+        File resources = Support_Resources.createTempFolder();
+        Support_Resources.copyFile(resources, null, "Broken_entry.jar");
+        InputStream is = Support_Resources.getStream("Broken_entry.jar");
+        JarInputStream jis = new JarInputStream(is, false);
+        jis.getNextEntry();
+        try {
+            jis.getNextEntry();
+            fail("ZipException expected");
+        } catch (ZipException ee) {
+            // expected
+        }
+
+        try {
+            jis.close();  // Android throws exception here, already!
+            jis.getNextEntry();  // But RI here, only!
+            fail("IOException expected");
+        } catch (IOException ee) {
+            // expected
+        }
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java Sun Oct 11 21:59:47 2009
@@ -19,11 +19,13 @@
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.InputStream;
+import java.io.IOException;
 import java.net.URL;
 import java.util.jar.Attributes;
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
 
 import tests.support.Support_Exec;
 import tests.support.resource.Support_Resources;
@@ -98,6 +100,53 @@
 		}
 	}
 
+    public void test_JarOutputStreamLjava_io_OutputStreamLjava_util_jar_Manifest()
+            throws IOException {
+        File fooJar = File.createTempFile("hyts_", ".jar");
+        File barZip = File.createTempFile("hyts_", ".zip");
+
+        FileOutputStream fos = new FileOutputStream(fooJar);
+
+        Manifest man = new Manifest();
+        Attributes att = man.getMainAttributes();
+        att.put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        att.put(Attributes.Name.MAIN_CLASS, "foo.bar.execjartest.Foo");
+        att.put(Attributes.Name.CLASS_PATH, barZip.getName());
+
+        fos.close();
+        try {
+            new JarOutputStream(fos, man);
+            fail("IOException expected");
+        } catch (IOException ee) {
+            // expected
+        }
+    }
+
+    public void test_JarOutputStreamLjava_io_OutputStream() throws IOException {
+        File fooJar = File.createTempFile("hyts_", ".jar");
+
+        FileOutputStream fos = new FileOutputStream(fooJar);
+        ZipEntry ze = new ZipEntry("Test");
+
+        try {
+            JarOutputStream joutFoo = new JarOutputStream(fos);
+            joutFoo.putNextEntry(ze);
+            joutFoo.write(33);
+        } catch (IOException ee) {
+            fail("IOException is not expected");
+        }
+
+        fos.close();
+        fooJar.delete();
+        try {
+            JarOutputStream joutFoo = new JarOutputStream(fos);
+            joutFoo.putNextEntry(ze);
+            fail("IOException expected");
+        } catch (IOException ee) {
+            // expected
+        }
+    }
+
 	@Override
     protected void setUp() {
 	}

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java Sun Oct 11 21:59:47 2009
@@ -20,6 +20,7 @@
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
+import java.io.IOException;
 import java.util.zip.CRC32;
 import java.util.zip.CheckedInputStream;
 
@@ -105,4 +106,39 @@
                 .getValue());
         checkInput.close();
     }
+
+    public void test_read() throws Exception {
+        // testing that the return by skip is valid
+        InputStream checkInput = Support_Resources
+                .getStream("hyts_checkInput.txt");
+        CheckedInputStream checkIn = new CheckedInputStream(checkInput,
+                new CRC32());
+        checkIn.read();
+        checkIn.close();
+        try {
+            checkIn.read();
+            fail("IOException expected.");
+        } catch (IOException ee) {
+            // expected
+        }
+        checkInput.close();
+    }
+
+    public void test_read$byteII() throws Exception {
+        // testing that the return by skip is valid
+        InputStream checkInput = Support_Resources
+                .getStream("hyts_checkInput.txt");
+        CheckedInputStream checkIn = new CheckedInputStream(checkInput,
+                new CRC32());
+        byte buff[] = new byte[50];
+        checkIn.read(buff, 10, 5);
+        checkIn.close();
+        try {
+            checkIn.read(buff, 10, 5);
+            fail("IOException expected.");
+        } catch (IOException ee) {
+            // expected
+        }
+        checkInput.close();
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java Sun Oct 11 21:59:47 2009
@@ -32,6 +32,8 @@
 public class DeflaterOutputStreamTest extends TestCase {
 
     private class MyDeflaterOutputStream extends DeflaterOutputStream {
+        boolean deflateFlag = false;
+
         MyDeflaterOutputStream(OutputStream out) {
             super(out);
         }
@@ -48,8 +50,13 @@
             return buf;
         }
 
-        void myDeflate() throws IOException {
-            deflate();
+        protected void deflate() throws IOException {
+            deflateFlag = true;
+            super.deflate();
+        }
+
+        boolean getDaflateFlag() {
+            return deflateFlag;
         }
     }
 
@@ -168,22 +175,23 @@
      * @tests java.util.zip.DeflaterOutputStream#close()
      */
     public void test_close() throws Exception {
-        File f1 = new File("close.tst");
-        FileOutputStream fos = new FileOutputStream(f1);
-        DeflaterOutputStream dos = new DeflaterOutputStream(fos);
-        byte byteArray[] = { 1, 3, 4, 6 };
-        dos.write(byteArray);
+        File f1 = File.createTempFile("close", ".tst");
 
-        FileInputStream fis = new FileInputStream(f1);
-        InflaterInputStream iis = new InflaterInputStream(fis);
+        InflaterInputStream iis = new InflaterInputStream(new FileInputStream(f1));
         try {
             iis.read();
             fail("EOFException Not Thrown");
         } catch (EOFException e) {
         }
 
+        FileOutputStream fos = new FileOutputStream(f1);
+        DeflaterOutputStream dos = new DeflaterOutputStream(fos);
+        byte byteArray[] = {1, 3, 4, 6};
+        dos.write(byteArray);
         dos.close();
 
+        iis = new InflaterInputStream(new FileInputStream(f1));
+
         // Test to see if the finish method wrote the bytes to the file.
         assertEquals("Incorrect Byte Returned.", 1, iis.read());
         assertEquals("Incorrect Byte Returned.", 3, iis.read());
@@ -379,4 +387,16 @@
 
         f2.delete();
     }
+
+    public void test_deflate() throws Exception {
+        File f1 = File.createTempFile("writeI1", ".tst");
+        FileOutputStream fos = new FileOutputStream(f1);
+        MyDeflaterOutputStream dos = new MyDeflaterOutputStream(fos);
+        assertFalse(dos.getDaflateFlag());
+        for (int i = 0; i < 3; i++) {
+            dos.write(i);
+        }
+        assertTrue(dos.getDaflateFlag());
+        dos.close();
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java Sun Oct 11 21:59:47 2009
@@ -21,6 +21,8 @@
 import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.File;
+import java.io.FileInputStream;
 import java.util.zip.DeflaterOutputStream;
 import java.util.zip.Inflater;
 import java.util.zip.InflaterInputStream;
@@ -158,6 +160,42 @@
 		}
 	}
 
+    public void testAvailableNonEmptySource() throws Exception {
+        // this byte[] is a deflation of these bytes: { 1, 3, 4, 6 }
+        byte[] deflated = { 72, -119, 99, 100, 102, 97, 3, 0, 0, 31, 0, 15, 0 };
+        InputStream in = new InflaterInputStream(new ByteArrayInputStream(deflated));
+        // InflaterInputStream.available() returns either 1 or 0, even though
+        // that contradicts the behavior defined in InputStream.available()
+        assertEquals(1, in.read());
+        assertEquals(1, in.available());
+        assertEquals(3, in.read());
+        assertEquals(1, in.available());
+        assertEquals(4, in.read());
+        assertEquals(1, in.available());
+        assertEquals(6, in.read());
+        assertEquals(0, in.available());
+        assertEquals(-1, in.read());
+        assertEquals(-1, in.read());
+    }
+
+    public void testAvailableSkip() throws Exception {
+        // this byte[] is a deflation of these bytes: { 1, 3, 4, 6 }
+        byte[] deflated = { 72, -119, 99, 100, 102, 97, 3, 0, 0, 31, 0, 15, 0 };
+        InputStream in = new InflaterInputStream(new ByteArrayInputStream(deflated));
+        assertEquals(1, in.available());
+        assertEquals(4, in.skip(4));
+        assertEquals(0, in.available());
+    }
+
+    public void testAvailableEmptySource() throws Exception {
+        // this byte[] is a deflation of the empty file
+        byte[] deflated = { 120, -100, 3, 0, 0, 0, 0, 1 };
+        InputStream in = new InflaterInputStream(new ByteArrayInputStream(deflated));
+        assertEquals(-1, in.read());
+        assertEquals(-1, in.read());
+        assertEquals(0, in.available());
+    }
+
 	/**
 	 * @tests java.util.zip.InflaterInputStream#read(byte[], int, int)
 	 */
@@ -192,6 +230,39 @@
         }
 	}
 
+    public void test_read$BII2() throws IOException {
+        File resources = Support_Resources.createTempFolder();
+        Support_Resources.copyFile(resources, null, "Broken_manifest.jar");
+        FileInputStream fis = new FileInputStream(new File(resources,
+                "Broken_manifest.jar"));
+        InflaterInputStream iis = new InflaterInputStream(fis);
+        byte[] outBuf = new byte[530];
+
+        iis.close();
+        try {
+            iis.read(outBuf, 0, 5);
+            fail("IOException expected");
+        } catch (IOException ee) {
+            // expected.
+        }
+    }
+
+    public void test_read$BII3() throws IOException {
+        File resources = Support_Resources.createTempFolder();
+        Support_Resources.copyFile(resources, null, "Broken_manifest.jar");
+        FileInputStream fis = new FileInputStream(new File(resources,
+                "Broken_manifest.jar"));
+        InflaterInputStream iis = new InflaterInputStream(fis);
+        byte[] outBuf = new byte[530];
+
+        try {
+            iis.read();
+            fail("IOException expected.");
+        } catch (IOException ee) {
+            // expected
+        }
+    }
+
     /**
      * @tests java.util.zip.InflaterInputStream#reset()
      */
@@ -310,19 +381,16 @@
 		InputStream is = Support_Resources.getStream("hyts_available.tst");
 		InflaterInputStream iis = new InflaterInputStream(is);
 
-		int available;
-		int read;
-		for (int i = 0; i < 11; i++) {
-			read = iis.read();
-			available = iis.available();
-			if (read == -1) {
-                assertEquals("Bytes Available Should Return 0 ",
-						0, available);
+        int available;
+        for (int i = 0; i < 11; i++) {
+            iis.read();
+            available = iis.available();
+            if (available == 0) {
+                assertEquals("Expected no more bytes to read", -1, iis.read());
             } else {
-                assertEquals("Bytes Available Should Return 1.",
-						1, available);
+                assertEquals("Bytes Available Should Return 1.", 1, available);
             }
-		}
+        }
 
 		iis.close();
 		try {

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java Sun Oct 11 21:59:47 2009
@@ -19,6 +19,7 @@
 import java.io.BufferedInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.zip.Adler32;
 import java.io.UnsupportedEncodingException;
 import java.util.zip.DataFormatException;
@@ -314,6 +315,41 @@
 				0, outPutInf[emptyArray.length]);
 	}
 
+    public void test_inflate$B1() {
+        byte codedData[] = {
+                120, -38, 75, -54, 73, -52, 80, 40, 46, 41, -54, -52, 75, 87,
+                72, -50, -49, 43, 73, -52, -52, 43, 86, 72, 2, 10, 34, 99,
+                -123, -60, -68, 20, -80, 32, 0, -101, -69, 17, 84};
+        String codedString = "blah string contains blahblahblahblah and blah";
+
+        Inflater infl1 = new Inflater();
+        Inflater infl2 = new Inflater();
+
+        byte[] result = new byte[100];
+        int decLen = 0;
+
+        infl1.setInput(codedData, 0, codedData.length);
+        try {
+            decLen = infl1.inflate(result);
+        } catch (DataFormatException e) {
+            fail("Unexpected DataFormatException");
+        }
+
+        infl1.end();
+        assertEquals(codedString, new String(result, 0, decLen));
+        codedData[5] = 0;
+
+        infl2.setInput(codedData, 0, codedData.length);
+        try {
+            decLen = infl2.inflate(result);
+            fail("Expected DataFormatException");
+        } catch (DataFormatException e) {
+            // expected
+        }
+
+        infl2.end();
+    }
+
 	/**
 	 * @tests java.util.zip.Inflater#inflate(byte[], int, int)
 	 */
@@ -361,6 +397,41 @@
 		assertEquals("out of bounds error did not get caught", 1, r);
 	}
 
+    public void test_inflate$BII1() {
+        byte codedData[] = {
+                120, -38, 75, -54, 73, -52, 80, 40, 46, 41, -54, -52, 75, 87,
+                72, -50, -49, 43, 73, -52, -52, 43, 86, 72, 2, 10, 34, 99,
+                -123, -60, -68, 20, -80, 32, 0, -101, -69, 17, 84};
+        String codedString = "blah string";
+
+        Inflater infl1 = new Inflater();
+        Inflater infl2 = new Inflater();
+
+        byte[] result = new byte[100];
+        int decLen = 0;
+
+        infl1.setInput(codedData, 0, codedData.length);
+        try {
+            decLen = infl1.inflate(result, 10, 11);
+        } catch (DataFormatException e) {
+            fail("Unexpected DataFormatException");
+        }
+
+        infl1.end();
+        assertEquals(codedString, new String(result, 10, decLen));
+        codedData[5] = 0;
+
+        infl2.setInput(codedData, 0, codedData.length);
+        try {
+            decLen = infl2.inflate(result, 10, 11);
+            fail("Expected DataFormatException");
+        } catch (DataFormatException e) {
+            // expected
+        }
+
+        infl2.end();
+    }
+
 	/**
 	 * @tests java.util.zip.Inflater#Inflater()
 	 */
@@ -712,17 +783,249 @@
         byte[] b = new byte[1024];
         assertEquals(0, inflater.inflate(b));
         inflater.end();
-        
+
         // Regression for HARMONY-2510
         inflater = new Inflater();
-        byte[] input = new byte[] { -1 };
-        inflater.setInput(input);
+        inflater.setInput(new byte[] { -1 });
         try {
             inflater.inflate(b);
-            fail("should throw DataFormateException");
+
+            // The RI detects malformed data on the malformed input { -1 }. Both
+            // this implementation and the native zlib API return "need input"
+            // on that data. This is an error if the stream is exhausted, but
+            // not one that results in an exception in the Inflater API.
+            assertTrue(inflater.needsInput());
         } catch (DataFormatException e) {
             // expected
-        }       
-    }   
-    
+        }
+
+        inflater = new Inflater();
+        inflater.setInput(new byte[] { -1, -1, -1 });
+        try {
+            inflater.inflate(b);
+        } catch (DataFormatException e) {
+            // expected
+        }
+    }
+
+    public void testSetDictionary$B() throws Exception {
+        int i = 0;
+        String inputString = "blah string contains blahblahblahblah and blah";
+        String dictionary1 = "blah";
+        String dictionary2 = "1234";
+
+        byte[] outputNo = new byte[100];
+        byte[] output1 = new byte[100];
+        byte[] output2 = new byte[100];
+        Deflater defDictNo = new Deflater(9);
+        Deflater defDict1 = new Deflater(9);
+        Deflater defDict2 = new Deflater(9);
+
+        defDict1.setDictionary(dictionary1.getBytes());
+        defDict2.setDictionary(dictionary2.getBytes());
+
+        defDictNo.setInput(inputString.getBytes());
+        defDict1.setInput(inputString.getBytes());
+        defDict2.setInput(inputString.getBytes());
+
+        defDictNo.finish();
+        defDict1.finish();
+        defDict2.finish();
+
+        int dataLenNo = defDictNo.deflate(outputNo);
+        int dataLen1 = defDict1.deflate(output1);
+        int dataLen2 = defDict2.deflate(output2);
+
+        boolean passNo1 = false;
+        boolean passNo2 = false;
+        boolean pass12 = false;
+
+        for (i = 0; i < (dataLenNo < dataLen1 ? dataLenNo : dataLen1); i++) {
+            if (outputNo[i] != output1[i]) {
+                passNo1 = true;
+                break;
+            }
+        }
+        for (i = 0; i < (dataLenNo < dataLen1 ? dataLenNo : dataLen2); i++) {
+            if (outputNo[i] != output2[i]) {
+                passNo2 = true;
+                break;
+            }
+        }
+        for (i = 0; i < (dataLen1 < dataLen2 ? dataLen1 : dataLen2); i++) {
+            if (output1[i] != output2[i]) {
+                pass12 = true;
+                break;
+            }
+        }
+
+        assertTrue(
+                "Compressed data the same for stream with dictionary and without it.",
+                passNo1);
+        assertTrue(
+                "Compressed data the same for stream with dictionary and without it.",
+                passNo2);
+        assertTrue(
+                "Compressed data the same for stream with different dictionaries.",
+                pass12);
+
+        Inflater inflNo = new Inflater();
+        Inflater infl1 = new Inflater();
+        Inflater infl2 = new Inflater();
+
+        byte[] result = new byte[100];
+        int decLen;
+
+        inflNo.setInput(outputNo, 0, dataLenNo);
+        decLen = inflNo.inflate(result);
+
+        assertFalse(inflNo.needsDictionary());
+        inflNo.end();
+        assertEquals(inputString, new String(result, 0, decLen));
+
+        infl1.setInput(output1, 0, dataLen1);
+        decLen = infl1.inflate(result);
+
+        assertTrue(infl1.needsDictionary());
+        infl1.setDictionary(dictionary1.getBytes());
+        decLen = infl1.inflate(result);
+        infl1.end();
+        assertEquals(inputString, new String(result, 0, decLen));
+
+        infl2.setInput(output2, 0, dataLen2);
+        decLen = infl2.inflate(result);
+
+        assertTrue(infl2.needsDictionary());
+        infl2.setDictionary(dictionary2.getBytes());
+        decLen = infl2.inflate(result);
+        infl2.end();
+        assertEquals(inputString, new String(result, 0, decLen));
+
+
+        inflNo = new Inflater();
+        infl1 = new Inflater();
+        inflNo.setInput(outputNo, 0, dataLenNo);
+        try {
+            infl1.setDictionary(dictionary1.getBytes());
+            fail("IllegalArgumentException expected.");
+        } catch (IllegalArgumentException ee) {
+            // expected.
+        }
+        inflNo.end();
+
+        infl1.setInput(output1, 0, dataLen1);
+        decLen = infl1.inflate(result);
+
+        assertTrue(infl1.needsDictionary());
+        try {
+            infl1.setDictionary(dictionary2.getBytes());
+            fail("IllegalArgumentException expected.");
+        } catch (IllegalArgumentException ee) {
+            // expected.
+        }
+        infl1.end();
+    }
+
+    public void testSetDictionary$BII() throws Exception {
+        int i = 0;
+        String inputString = "blah string contains blahblahblahblah and blah";
+        String dictionary1 = "blah";
+        String dictionary2 = "blahblahblah";
+
+        byte[] output1 = new byte[100];
+        byte[] output2 = new byte[100];
+        byte[] output3 = new byte[100];
+
+        Deflater defDict1 = new Deflater(9);
+        Deflater defDict2 = new Deflater(9);
+        Deflater defDict3 = new Deflater(9);
+
+        defDict1.setDictionary(dictionary1.getBytes());
+        defDict2.setDictionary(dictionary2.getBytes());
+        defDict3.setDictionary(dictionary2.getBytes(), 4, 4);
+
+        defDict1.setInput(inputString.getBytes());
+        defDict2.setInput(inputString.getBytes());
+        defDict3.setInput(inputString.getBytes());
+
+        defDict1.finish();
+        defDict2.finish();
+        defDict3.finish();
+
+        int dataLen1 = defDict1.deflate(output1);
+        int dataLen2 = defDict2.deflate(output2);
+        int dataLen3 = defDict3.deflate(output3);
+
+        boolean pass12 = false;
+        boolean pass23 = false;
+        boolean pass13 = true;
+
+        for (i = 0; i < (dataLen1 < dataLen2 ? dataLen1 : dataLen2); i++) {
+            if (output1[i] != output2[i]) {
+                pass12 = true;
+                break;
+            }
+        }
+        for (i = 0; i < (dataLen2 < dataLen3 ? dataLen2 : dataLen3); i++) {
+            if (output2[i] != output3[i]) {
+                pass23 = true;
+                break;
+            }
+        }
+        for (i = 0; i < (dataLen1 < dataLen3 ? dataLen1 : dataLen3); i++) {
+            if (output1[i] != output3[i]) {
+                pass13 = false;
+                break;
+            }
+        }
+
+        assertTrue(
+                "Compressed data the same for stream with different dictionaries.",
+                pass12);
+        assertTrue(
+                "Compressed data the same for stream with different dictionaries.",
+                pass23);
+        assertTrue(
+                "Compressed data the differs for stream with the same dictionaries.",
+                pass13);
+
+        Inflater infl1 = new Inflater();
+        Inflater infl2 = new Inflater();
+        Inflater infl3 = new Inflater();
+
+        byte[] result = new byte[100];
+        int decLen;
+
+        infl1.setInput(output1, 0, dataLen1);
+        decLen = infl1.inflate(result);
+
+        assertTrue(infl1.needsDictionary());
+        infl1.setDictionary(dictionary2.getBytes(), 4, 4);
+        decLen = infl1.inflate(result);
+        infl1.end();
+        assertEquals(inputString, new String(result, 0, decLen));
+
+        infl2.setInput(output2, 0, dataLen2);
+        decLen = infl2.inflate(result);
+
+        assertTrue(infl2.needsDictionary());
+        try {
+            infl2.setDictionary(dictionary1.getBytes());
+            fail("IllegalArgumentException expected.");
+        } catch (IllegalArgumentException ee) {
+            // expected
+        }
+        infl2.end();
+
+        infl3.setInput(output3, 0, dataLen3);
+        decLen = infl3.inflate(result);
+
+        assertTrue(infl3.needsDictionary());
+        infl3.setDictionary(dictionary1.getBytes());
+        decLen = infl3.inflate(result);
+        infl3.end();
+        assertEquals(inputString, new String(result, 0, decLen));
+
+    }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java Sun Oct 11 21:59:47 2009
@@ -18,10 +18,26 @@
 
 import java.util.TimeZone;
 import java.util.zip.ZipEntry;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 
 import tests.support.resource.Support_Resources;
 
 public class ZipEntryTest extends junit.framework.TestCase {
+
+    public byte[] getAllBytesFromStream(InputStream is) throws IOException {
+        ByteArrayOutputStream bs = new ByteArrayOutputStream();
+        byte[] buf = new byte[512];
+        int iRead;
+        int off;
+        while (is.available() > 0) {
+            iRead = is.read(buf, 0, buf.length);
+            if (iRead > 0) bs.write(buf, 0, iRead);
+        }
+        return bs.toByteArray();
+    }
+
 	// zip file hyts_ZipFile.zip must be included as a resource
 	java.util.zip.ZipEntry zentry;
 
@@ -435,7 +451,6 @@
     protected void setUp() {
 		java.io.File f = null;
 		try {
-			byte[] rbuf = new byte[2000];
 			// Create a local copy of the file since some tests want to alter
 			// information.
 			f = new java.io.File(tempFileName);
@@ -446,8 +461,7 @@
 			java.io.InputStream is = Support_Resources
 					.getStream("hyts_ZipFile.zip");
 			java.io.FileOutputStream fos = new java.io.FileOutputStream(f);
-			rbuf = new byte[is.available()];
-			is.read(rbuf, 0, rbuf.length);
+            byte[] rbuf = getAllBytesFromStream(is);
 			fos.write(rbuf, 0, rbuf.length);
 			is.close();
 			fos.close();

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java Sun Oct 11 21:59:47 2009
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.ByteArrayOutputStream;
 import java.util.Enumeration;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
@@ -30,6 +31,18 @@
 
 public class ZipFileTest extends junit.framework.TestCase {
 
+    public byte[] getAllBytesFromStream(InputStream is) throws IOException {
+        ByteArrayOutputStream bs = new ByteArrayOutputStream();
+        byte[] buf = new byte[512];
+        int iRead;
+        int off;
+        while (is.available() > 0) {
+            iRead = is.read(buf, 0, buf.length);
+            if (iRead > 0) bs.write(buf, 0, iRead);
+        }
+        return bs.toByteArray();
+    }
+
 	// the file hyts_zipFile.zip in setup must be included as a resource
 	private String tempFileName;
 
@@ -254,10 +267,12 @@
         assertEquals(rbuf1.length, r1);
         r2 = is.read(rbuf2);
         assertEquals(rbuf2.length, r2);
-        
-        is.reset();
-        r2 = is.read(rbuf2);
-        assertEquals(rbuf2.length, r2);
+
+        try {
+            is.reset();
+            fail();
+        } catch (IOException expected) {
+        }
         is.close();
 
         // read a compressed entry
@@ -266,18 +281,21 @@
         is = zfile.getInputStream(zentry2);
         r1 = is.read(rbuf3);
         assertEquals(4183, r1);
-        is.reset();
-        
-        r1 = is.read(rbuf3);
-        assertEquals(4183, r1);
+        try {
+            is.reset();
+            fail();
+        } catch (IOException expected) {
+        }
         is.close();
 
         is = zfile.getInputStream(zentry2);
         r1 = is.read(rbuf3, 0, 3000);
         assertEquals(3000, r1);
-        is.reset();
-        r1 = is.read(rbuf3, 0, 3000);
-        assertEquals(3000, r1);
+        try {
+            is.reset();
+            fail();
+        } catch (IOException expected) {
+        }
         is.close();
     }
     
@@ -296,11 +314,13 @@
         r = is.read(rbuf1);
         assertEquals(8, r);
         assertEquals(-1, is.read());
-        
-        is.reset();
-        r = is.read(rbuf2);
-        assertEquals(8, r);
-        assertEquals(-1, is.read());
+
+        try {
+            is.reset();
+            fail();
+        } catch (IOException expected) {
+        }
+
         is.close();
 
         // read a compressed entry
@@ -313,11 +333,13 @@
         r = is.read(rbuf3);
         assertEquals(1183, r);
         assertEquals(-1, is.read());
-        
-        is.reset();
-        r = is.read(rbuf3);
-        assertEquals(1183, r);
-        assertEquals(-1, is.read());
+
+        try {
+            is.reset();
+            fail();
+        } catch (IOException expected) {
+        }
+
         is.close();
     }
 
@@ -328,7 +350,6 @@
 	@Override
     protected void setUp() {
 		try {
-			byte[] rbuf = new byte[2000];
 			// Create a local copy of the file since some tests want to alter
 			// information.
 			tempFileName = System.getProperty("user.dir");
@@ -346,8 +367,7 @@
 			f.delete();
 			InputStream is = Support_Resources.getStream("hyts_ZipFile.zip");
 			FileOutputStream fos = new FileOutputStream(f);
-			rbuf = new byte[is.available()];
-			is.read(rbuf, 0, rbuf.length);
+            byte[] rbuf = getAllBytesFromStream(is);
 			fos.write(rbuf, 0, rbuf.length);
 			is.close();
 			fos.close();

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java Sun Oct 11 21:59:47 2009
@@ -207,4 +207,39 @@
             // Expected
         }
     }
+
+    public void test_available() throws Exception {
+
+        File resources = Support_Resources.createTempFolder();
+        Support_Resources.copyFile(resources, null, "hyts_ZipFile.zip");
+        File fl = new File(resources, "hyts_ZipFile.zip");
+        FileInputStream fis = new FileInputStream(fl);
+
+        ZipInputStream zis1 = new ZipInputStream(fis);
+        ZipEntry entry = zis1.getNextEntry();
+        assertNotNull("No entry in the archive.", entry);
+        long entrySize = entry.getSize();
+        assertTrue("Entry size was < 1", entrySize > 0);
+        int i = 0;
+        while (zis1.available() > 0) {
+            zis1.skip(1);
+            i++;
+        }
+        if (i != entrySize) {
+            fail("ZipInputStream.available or ZipInputStream.skip does not " +
+                    "working properly. Only skipped " + i +
+                    " bytes instead of " + entrySize);
+        }
+        assertEquals(0, zis1.skip(1));
+        assertEquals(0, zis1.available());
+        zis1.closeEntry();
+        assertEquals(1, zis.available());
+        zis1.close();
+        try {
+            zis1.available();
+            fail("IOException expected");
+        } catch (IOException ee) {
+            // expected
+        }
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/common/javax/security/auth/PrivateCredentialPermission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/common/javax/security/auth/PrivateCredentialPermission.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/common/javax/security/auth/PrivateCredentialPermission.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/common/javax/security/auth/PrivateCredentialPermission.java Sun Oct 11 21:59:47 2009
@@ -375,6 +375,9 @@
         // Checks two CredOwner objects for equality. 
         @Override
         public boolean equals(Object obj) {
+            if (obj == null) {
+                return false;
+            }
             return principalClass.equals(((CredOwner) obj).principalClass)
                     && principalName.equals(((CredOwner) obj).principalName);
         }

Modified: harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTDomainPrincipal.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTDomainPrincipal.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTDomainPrincipal.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTDomainPrincipal.java Sun Oct 11 21:59:47 2009
@@ -17,7 +17,6 @@
 
 /**
  * @author Alexander V. Astapchuk
- * @version $Revision$
  */
 package org.apache.harmony.auth;
 

Modified: harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTNumericCredential.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTNumericCredential.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTNumericCredential.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTNumericCredential.java Sun Oct 11 21:59:47 2009
@@ -17,7 +17,6 @@
 
 /**
  * @author Alexander V. Astapchuk
- * @version $Revision$
  */
 package org.apache.harmony.auth;
 

Modified: harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSid.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSid.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSid.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSid.java Sun Oct 11 21:59:47 2009
@@ -17,7 +17,6 @@
 
 /**
  * @author Alexander V. Astapchuk
- * @version $Revision$
  */
 package org.apache.harmony.auth;
 

Modified: harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidDomainPrincipal.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidDomainPrincipal.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidDomainPrincipal.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidDomainPrincipal.java Sun Oct 11 21:59:47 2009
@@ -17,7 +17,6 @@
 
 /**
  * @author Alexander V. Astapchuk
- * @version $Revision$
  */
 package org.apache.harmony.auth;
 

Modified: harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidGroupPrincipal.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidGroupPrincipal.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidGroupPrincipal.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidGroupPrincipal.java Sun Oct 11 21:59:47 2009
@@ -17,7 +17,6 @@
 
 /**
  * @author Alexander V. Astapchuk
- * @version $Revision$
  */
 package org.apache.harmony.auth;
 

Modified: harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidPrimaryGroupPrincipal.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidPrimaryGroupPrincipal.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidPrimaryGroupPrincipal.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidPrimaryGroupPrincipal.java Sun Oct 11 21:59:47 2009
@@ -17,7 +17,6 @@
 
 /**
  * @author Alexander V. Astapchuk
- * @version $Revision$
  */
 package org.apache.harmony.auth;
 

Modified: harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidUserPrincipal.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidUserPrincipal.java?rev=824184&r1=824183&r2=824184&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidUserPrincipal.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/auth/src/main/java/windows/org/apache/harmony/auth/NTSidUserPrincipal.java Sun Oct 11 21:59:47 2009
@@ -17,7 +17,6 @@
 
 /**
  * @author Alexander V. Astapchuk
- * @version $Revision$
  */
 package org.apache.harmony.auth;
 



Mime
View raw message