如果其他 jars 使用 64 位编译,则可以安全地使用 java 32 位构建?
我有一个64位系统来构建一个java项目。现在我只能使用 32 位机器。使用 javac x32 与 javac x64 的字节码会有什么不同吗?即我需要发送错误修复,并且如果所有其余的 jar 都使用 x64 编译,我不确定是否可以发送使用 javac x32 编译的 jar 文件。
找到了这个,但是我仍然不太确定。
I had a 64-bit system to build a java project. For now I'm stuck with a 32-bit machine. Will the bytecode be any different using javac x32 versus javac x64. i.e. I need to send a bug fix and I'm not sure I can send a jar file compiled with javac x32 if all the rest of the jars where compiled with x64.
Found this but, I'm still not quite sure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如您链接的答案中提到的那样,它应该工作得很好 Java 字节码完全独立于平台
It should work perfectly fine as was mentioned in the answer you linked Java Bytecode is completely platform independant
就像链接一样,其他人也说:一切都会好起来的。
您可能会感到困惑的是JIT编译器和
javac
编译器之间的区别。 JIT 编译器是虚拟机的一部分 - 与javac
不同 - 并且在 32 位和 64 位 Windows 计算机上具有不同的默认设置。这会影响由javac
编译的字节码运行时的执行速度和内存使用等性能,但不会影响由javac< 编译的代码的兼容性 /代码>。
javac
with will 在任何兼容的 JVM 上输出。看看您的评论,我认为这些信息也可能对您有帮助:Java代码调用 .dll/.so 只需调用带有
native
修饰符的方法,如public native byte[] doFoo(byte[] img);
.通常,这些方法具有指定为在所有系统中相同的行为,以及一些未指定的行为(请参阅 FileChannel)。除非您提供修复的项目确实很奇怪,否则 Java 几乎总是与系统无关,这意味着 Java 代码仅处理与系统无关的行为。您应该很少会看到在不同系统上执行不同操作的 Java 源代码。如果您只编写 Java 代码,那么您的修复应该适用于项目部署到的所有系统。但没有任何保证。查看您使用的任何类和方法的文档,以确保它们完全从 Java 源代码中抽象出操作系统。Like the link and everyone else said: It will be fine.
What may be confusing you is the difference between the JIT compiler and the
javac
compiler. The JIT compiler is part of the virtual machine - unlikejavac
- and has different default settings on 32- and 64-bit Windows machines. This will effect performance like execution speed and memory usage when bytecode - compiled byjavac
- is run, but it doesn't effect compatibility of code compiled byjavac
. The output ofjavac
with will on any compliant JVM.Looking at your comments, I think this info might help you, too: Java code invokes .dll/.so s simply with a call to a method with the
native
modifier, as inpublic native byte[] doFoo(byte[] img);
. Typically, these methods have behavior that is specified to be the same across all systems, and some behavior that is unspecified (see FileChannel). Unless the project you delivered a fix for is really weird, Java almost always is system-agnostic, meaning Java code only deals with system-independent behavior. You should rarely see Java source code that does different things on different system. If you only wrote Java code, your fix should work across all systems that the project is deployed to. But there's no guarantee. Look at the documentation for any classes and methods you used to make sure they fully abstract the operating system from the Java source code.