RFR: 8304014: Convert test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java to junit [v5]

Eirik Bjorsnos duke at openjdk.org
Fri Mar 31 22:37:00 UTC 2023


On Fri, 31 Mar 2023 17:38:02 GMT, Lance Andersen <lancea at openjdk.org> wrote:

>> Eirik Bjorsnos has updated the pull request incrementally with four additional commits since the last revision:
>> 
>>  - Document the structure of the 'good' ZIP
>>  - Use the "Validate that.." comment style
>>  - Document the ByteBuffer with a comment
>>  - Use ByteBuffer when manipulating multi-byte fields
>
> test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java line 192:
> 
>> 190:     /*
>> 191:      * Validate that a ZipException is thrown when the 'End of Central Directory'
>> 192:      * (END) header has a CEN offset incoherent with the position calculated
> 
> Not sure _incoherent_ is the best term.
> 
>       perhaps something along the lines:
> 
> header  contains an invalid CEN Directory  starting offset.....

I remember my struggles trying to write this one in the first place. The code says:


long cenpos = end.endpos - end.cenlen;     // position of CEN table
// Get position of first local file (LOC) header, taking into
// account that there may be a stub prefixed to the zip file.
locpos = cenpos - end.cenoff;
if (locpos < 0) {
        zerror("invalid END header (bad central directory offset)");
}
``` 

so I ended up trying to express this equation in words, which is maybe not so successful. I don't see _incoherent_ as the main problem, if it was we could just use _inconsistent_.

Do you have a better concrete suggestion?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/12563#discussion_r1154844552


More information about the core-libs-dev mailing list