Line order in Java manifest files

Is the order of the lines in the manifest file maintained?

Someone is trying to convince me that things break for him when the manifest file changes from

Manifest-Version: 1.0 Class-Path: xxx.jar Main-Class: com.something 

to

 Manifest-Version: 1.0 Main-Class: com.something Class-Path: xxx.jar 

(The Main-Class and Class-Path lines are reversed.)

+6
source share
1 answer

No, the order of these two lines should not matter.

Here is a quote from the documentation :

...

  • Versions:

    Manifest-Version and Signature-Version should be the first in this case (so that they can be easily recognized as magic lines). In addition, the order of the attributes in the main section is negligible.

  • Order:

    The order of the individual manifest does not matter.

...

The internal manifest is represented by the HashMap , which is an unordered data structure. Here is the source code for java.util.jar.Manifest if you want to get to know each other better.

+8
source

Source: https://habr.com/ru/post/895575/


All Articles