[英]Do Linux and Windows java compilers produce the same or different class files?
We have Java compilation both on Linux and Windows by the same version 1.6.0_25. 我们在Linux和Windows上使用相同版本的1.6.0_25进行Java编译。
For some reason the resulted class files are different. 由于某种原因,结果类文件是不同的。 Is it correct?
这是对的吗?
The java compiler is not deterministic and may not generate the same .class if compiled on the same platform mulitple times or compiled on different platforms. java编译器不具有确定性,如果在同一平台上编译多次或在不同平台上编译,则可能不会生成相同的.class。 I am trying to figure out the internals of java compiler to see why it is not deterministic.
我试图找出java编译器的内部,看看为什么它不是确定性的。
Searching it further gives more insight while learning about cross compilation option in javac : 在学习javac中的交叉编译选项时,进一步搜索可以提供更多洞察力:
Cross-Compilation Options 交叉编译选项
By default, classes are compiled against the bootstrap and extension classes of the platform that javac shipped with .
默认情况下,类是根据javac附带的平台的引导程序和扩展类编译的 。 But javac also supports cross-compiling, where classes are compiled against a bootstrap and extension classes of a different Java platform implementation.
但javac还支持交叉编译,其中类是针对不同Java平台实现的引导程序和扩展类编译的。 It is important to use -bootclasspath and -extdirs when cross-compiling;
交叉编译时使用-bootclasspath和-extdirs非常重要; see Cross-Compilation Example below.
请参阅下面的交叉编译示例。
Java字节码与平台无关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.