Java清单文件中各行的顺序 [英] Order of the lines in Java manifest files
问题描述
清单文件中的行顺序重要吗?
Does the order of lines in manifest file matter?
有人试图说服我,当清单文件从更改时,事情就对他不利了
Somebody 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
到
Manifest-Version: 1.0
Main-Class: com.something
Class-Path: xxx.jar
(Main-Class和Class-Path行颠倒了.)
(Main-Class and Class-Path lines are reversed.)
推荐答案
不,这两行的顺序无关紧要.
No, the order of those two lines should not matter.
以下是该文档中的引文:
...
...
-
版本:
Versions:
Manifest-Version和Signature-Version必须是第一个,并且在这种情况下必须如此(以便可以轻松地将它们识别为魔术字符串).除此之外,主要部分中的属性顺序并不重要.
Manifest-Version and Signature-Version must be first, and in exactly that case (so that they can be recognized easily as magic strings). Other than that, the order of attributes within a main section is not significant.
订购:
单个清单条目的顺序并不重要.
The order of individual manifest entries is not significant.
...
在内部,清单由HashMap
表示,它是无序的数据结构.如果您想仔细看看,这是源代码java.util.jar.Manifest
.
Internally the manifest is represented by a HashMap
which is an unordered data structure. Here's the source code java.util.jar.Manifest
if you wish to have a closer look.
这篇关于Java清单文件中各行的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!