Java清单文件中的行顺序

前端之家收集整理的这篇文章主要介绍了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

猜你在找的Java相关文章