8157613: Internal documentation improvements to ZipFile.java
authormartin
Mon, 23 May 2016 12:44:55 -0700
changeset 38467 172e0c9007a6
parent 38466 4bcf5f2bb351
child 38468 d459a0f8fe72
8157613: Internal documentation improvements to ZipFile.java Reviewed-by: plevart, sherman
jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
--- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java	Mon May 23 12:53:56 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java	Mon May 23 12:44:55 2016 -0700
@@ -808,11 +808,10 @@
     }
 
     /**
-     * Returns an array of strings representing the names of all entries
-     * that begin with "META-INF/" (case ignored). This method is used
-     * in JarFile, via SharedSecrets, as an optimization when looking up
-     * manifest and signature file entries. Returns null if no entries
-     * were found.
+     * Returns the names of all non-directory entries that begin with
+     * "META-INF/" (case ignored). This method is used in JarFile, via
+     * SharedSecrets, as an optimization when looking up manifest and
+     * signature file entries. Returns null if no entries were found.
      */
     private String[] getMetaInfEntryNames() {
         synchronized (this) {
@@ -1304,18 +1303,19 @@
                 && (name[off]         ) == '/';
         }
 
-        /*
-         * Counts the number of CEN headers in a central directory extending
-         * from BEG to END.  Might return a bogus answer if the zip file is
-         * corrupt, but will not crash.
+        /**
+         * Returns the number of CEN headers in a central directory.
+         * Will not throw, even if the zip file is corrupt.
+         *
+         * @param cen copy of the bytes in a zip file's central directory
+         * @param size number of bytes in central directory
          */
-        static int countCENHeaders(byte[] cen, int end) {
+        private static int countCENHeaders(byte[] cen, int size) {
             int count = 0;
-            int pos = 0;
-            while (pos + CENHDR <= end) {
+            for (int p = 0;
+                 p + CENHDR <= size;
+                 p += CENHDR + CENNAM(cen, p) + CENEXT(cen, p) + CENCOM(cen, p))
                 count++;
-                pos += (CENHDR + CENNAM(cen, pos) + CENEXT(cen, pos) + CENCOM(cen, pos));
-            }
             return count;
         }
     }