How to use javac to create binary identical class files across different platforms?

前端 未结 3 2123
野趣味
野趣味 2020-12-19 19:37

I write my AWS Lambda functions in Java. The tool I use to upload my lambdas (Terraform) wants to use the SHA-256 hash of my jar file to track if a new version of a lambda n

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-19 20:15

    For any body that stumbles across this question:

    • the first thing to look at is to check the vendor of the JDK on each platform

    Turns out I had the same version/update level, but was actually using different JDKs (duh).

    I was using Oracle JDK on Windows and OpenJDK on Linux. Once I changed these to Azul Zulu JDK (u112) on both Windows and Linux - it appears that exactly the same bytecode is being generated, at least for the limited amount of Java code I've written so far (though as per Holger's answer, it's apparently not to be relied upon).

提交回复
热议问题