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

前端 未结 3 2122
野趣味
野趣味 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:39

    In the build process of Eclipse, the following is routinely checked for sanity: do any compiled class files from projects that have no changes in git since the last baseline, have any binary difference vs. the jar file from that baseline. Experience tells that indeed differences only occur when relevant changes have been made in the compiler.

    This is not a guarantee, but empirical evidence that normally the same compiler version will produce the same bytes when compiling the same sources.

    In this case the compiler is ecj.

    See a recent example logfile from the comparator (will be removed soon), that did signal unexpected class file changes, which were then traced back to a specific compiler change. The corresponding logs of a release are expected to be empty.

提交回复
热议问题