Java清单文件中的行顺序

清单文件中的行顺序是否重要?

有人试图说服我,当清单文件发生变化时,事情就会破坏

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线相反.)

解决方法

不,这两行的顺序无关紧要.

这是the documentation的引用:

  • Versions:

    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.

  • Ordering:

    The order of individual manifest entries is not significant.

在内部,清单由HashMap表示,HashMap是无序数据结构.如果你想仔细看看,这是源代码java.util.jar.Manifest.

> http://www.massapi.com/source/jdk1.6.0_17/src/java/util/jar/Manifest.java.html

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...