RFR: 8260617: Merge ZipFile encoding check with the initial hash calculation [v2]

Claes Redestad redestad at openjdk.java.net
Fri Jan 29 23:21:44 UTC 2021


On Fri, 29 Jan 2021 18:43:40 GMT, Lance Andersen <lancea at openjdk.org> wrote:

>> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Refactor to do most entry validation in one place, out of line from initCEN.
>
> src/java.base/share/classes/java/util/zip/ZipCoder.java line 140:
> 
>> 138:     // aborting the ASCII fast-path in the UTF8 implementation, so {@code h}
>> 139:     // might be a partially calculated hash code
>> 140:     int normalizedHashDecode(int h, byte[] a, int off, int end) {
> 
> Would it make sense to keep some of this comment for clarity?

The comment is misleading after JDK-8260010 since the UTF8 implementation can't use this method, and I should have rewritten or removed it with JDK-8260010.

> src/java.base/share/classes/java/util/zip/ZipFile.java line 1501:
> 
>> 1499:                 if (entryPos + nlen > limit)
>> 1500:                     zerror("invalid CEN header (bad header size)");
>> 1501:                 idx = addEntry(idx, table, nlen, pos, entryPos);
> 
> Perhaps  consider adding  a comment describing addEntry.  Probably  similar to the  line 1500 comment (or similar) would be beneficial

I've refactored this code a bit further, both for clarity and to outline more related things into what's now `checkAndAddEntry`, which helps startup time as measured with a spring-petclinic startup test (time spent opening 393 jar files drop from ~46 to ~41ms on my setup).

-------------

PR: https://git.openjdk.java.net/jdk/pull/2306


More information about the core-libs-dev mailing list