OpenJDK / bsd-port / jdk9 / jdk
changeset 14610:e93c15465318
8157613: Internal documentation improvements to ZipFile.java
Reviewed-by: plevart, sherman
author | martin |
---|---|
date | Mon, 23 May 2016 12:44:55 -0700 |
parents | 87e8d92a9f6c |
children | ca392a5bf0ef |
files | src/java.base/share/classes/java/util/zip/ZipFile.java |
diffstat | 1 files changed, 14 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/zip/ZipFile.java Mon May 23 12:53:56 2016 -0700 +++ b/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; } }