[Bug 262278] file(1) fails to identify a JAR file

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 17 May 2022 12:27:33 UTC

Michael Osipov <michael.osipov@siemens.com> changed:

           What    |Removed                     |Added
                 CC|                            |michael.osipov@siemens.com

--- Comment #3 from Michael Osipov <michael.osipov@siemens.com> ---
The 0xcafebabe applies to classes, not to JAR files.

Unwritten law how to detect a JAR:
Either the first or the second ZIP entry must be the manifest file:


or just


Maven produces fully reproducible JARs that those two entries come first:
> $ unzip -t maven-core-4.0.0-alpha-1-SNAPSHOT.jar | head
> Archive:  maven-core-4.0.0-alpha-1-SNAPSHOT.jar
>     testing: META-INF/                OK
>     testing: META-INF/MANIFEST.MF     OK
>     testing: META-INF/maven/          OK
>     testing: META-INF/sisu/           OK
>     testing: org/                     OK
>     testing: org/apache/              OK

Don't expect a JAR to contain a class file. It could solely contain resources,
still being a JAR file due to the manifest and the first entry of the manifest
is fixed to "Manifest-Version: 1.0". This is by spec and guaranteed to be
written by Maven libraries.

You are receiving this mail because:
You are the assignee for the bug.