On Sun, 19 Mar 2023 14:38:46 GMT, Eirik Bjorsnos <d...@openjdk.org> wrote:

>> src/java.base/share/classes/java/util/zip/ZipOutputStream.java line 208:
>> 
>>> 206:      *
>>> 207:      * This ensures strict compliance with the ZIP specification and
>>> 208:      * allows optimal performance when processing directory entries.
>> 
>> I think we can remove at least the first part of the sentence regarding 
>> "strict compliance" as  "file data" can be interpreted as the contents of 
>> the file as 4.1.3 of the App.Note allows for the default compression method 
>> to be DEFAULT.  The intent of the apiNote is to remind developers that the 
>> use of the STORED compression method is preferred and may be more optimal
>
> 4.3.8  File data
> 
>       Immediately following the local header for a file
>       SHOULD be placed the compressed or stored data for the file.
>       If the file is encrypted, the encryption header for the file 
>       SHOULD be placed after the local header and before the file 
>       data. The series of [local file header][encryption header]
>       [file data][data descriptor] repeats for each file in the 
>       .ZIP archive. 
> 
>       Zero-byte files, directories, and other file types that 
>       contain no content MUST NOT include file data.
> 
> 
> 
> My interpretation of section 4.3.8 is that 'file data' in the last sentence 
> of this section refers to what is defined in the first sentence: 'Immediately 
> following the local header for a file SHOULD be placed the compressed or 
> stored data for the file.'
> 
> While I'm not sure I fully understand you interpretation, it seems you are 
> saying that a DEFLATED entry with the two-byte 'empty final' DEFLATE blocks 
> does not have file data? (Because it is just an encoding of 'no content')?
> 
> In any case, I'm happy to remove this since as it stands it is a bit vague  
> and as we've seen open for interpretation.

> I think we can remove at least the first part of the sentence regarding 
> "strict compliance" as "file data" can be interpreted as the contents of the 
> file as 4.1.3 of the App.Note allows for the default compression method to be 
> DEFAULT. 


4.1.3 Data compression MAY be used to reduce the size of files
   placed into a ZIP file, but is not required.  This format supports the 
   use of multiple data compression algorithms.  When compression is used, 
   one of the documented compression algorithms MUST be used.  Implementors 
   are advised to experiment with their data to determine which of the 
   available algorithms provides the best compression for their needs.
   Compression method 8 (Deflate) is the method used by default by most 
   ZIP compatible application programs.  


I think we read 4.1.3 slightly differently. I read it as saying that WHEN data 
compression is used, 8 (Deflate) is the method used by default by most ZIP 
compatible application programs.  STORED entries are not using data 
compression, and as such do not have any 'default compression method'. 4.1.3 
does not apply to them.

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

PR: https://git.openjdk.org/jdk/pull/12899

Reply via email to