我有一个 jar 文件,每个 java 文件有两个类文件。
Java:
Foo.java
Bar.java
类文件:
Foo.class
Foo.class
Bar.class
Bar.class
我已经验证每个类只有一个 java 文件。 java 文件不包含任何内部类。 我正在使用 ant jar-task 来创建 jar 文件。在我执行任务之前,构建目录中每个类只有一个类文件。
我使用 jar -tf jarfile.jar 或在 zip 程序中查看它时看到了双类文件。当我解压文件时,zip 程序询问是否应该覆盖现有文件。
怎么会发生这种事?
最佳答案
您正在使用 Ant Jar 任务吗?如果是这样,那么您绝对可以在同一个 jar 文件中获得重复的文件。 duplicate 属性用于阻止这种情况。
Please note that the zip format allows multiple files of the same fully-qualified name to exist within a single archive. This has been documented as causing various problems for unsuspecting users. If you wish to avoid this behavior you must set the duplicate attribute to a value other than its default, "add".
来自 Ant 手册页面:http://ant.apache.org/manual/Tasks/jar.html
关于java - 每个类在jar文件中都有两个类文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7122955/