JDK-8321274 : Rename ZipEntry.extraAttributes to ZipEntry.externalFileAttributes
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • Submitted: 2023-12-04
  • Updated: 2024-03-08
Related Reports
Relates :  
Relates :  
Description
The internal field 'ZipEntry.extraAttributes' was introduced in JDK-8218021, then under the name 'ZipEntry.posixPerms'. JDK-8250968 later renamed the field to 'ZipEntry.extraAttributes' and extended its semantics to hold the full value of the "external file attributes" field, as defined by APPNOTE.TXT.

The name 'extraAttributes' is misleading. The two-byte field it holds refers to the 'external file attributes' field of the CEN header. It has nothing to do with the 'extra field', an unrelated structure defined in APPNOTE.TXT.

To prevent confusion and make life easier for future maintainers, the field  should be renamed to 'ZipEntry.externalFileAttributes'. Any derived local variable or method should be renamed accordingly.

The field is not public, so renaming it does not change the API and should have no compatibility impact.

A similar rename should also be done in zipfs
Comments
Yes, that's my understanding from reviewing the code changes and releated issues. The field was added for the specific purpose of enabling preservation of posix attribuites for signed jars. It was not exposed for public use, this was probably intentional, or at least the simplest choice given that exposing it would be an API change, require a CSR and a discussion.
12-12-2023

Are you implying that the public class ZipEntry is not intended to be used except by JarSigner?
12-12-2023

My understanding is that this field was added to preserve this field in the jar signing process. JarSigner "copies" ZipEntry instances from ZipFile to ZipOutputStream.
12-12-2023

Is there some reason why there are no public accessors for this field? I understand that the interpretation of the field is not standardized, but the field itself is defined in the standard.
12-12-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16952 Date: 2023-12-04 15:34:34 +0000
04-12-2023