Closed jameskyle closed 1 year ago
Checking bazel info, looks like it's using Java 11 for the sdk. Seems a likely candidate for this issue.
JAVA_HOME
is set for Java 8. So looking into how to get bazel to pick up this sdk for the build.
azel-bin: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/execroot/com_google_java_differential_privacy/bazel-out/darwin-fastbuild/bin
bazel-genfiles: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/execroot/com_google_java_differential_privacy/bazel-out/darwin-fastbuild/bin
bazel-testlogs: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/execroot/com_google_java_differential_privacy/bazel-out/darwin-fastbuild/testlogs
character-encoding: file.encoding = ISO-8859-1, defaultCharset = ISO-8859-1
command_log: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/command.log
committed-heap-size: 125MB
execution_root: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/execroot/com_google_java_differential_privacy
gc-count: 108
gc-time: 2295ms
install_base: /var/tmp/_bazel_jkyle/install/d07238c5957d0addf241b6be07f3c14b
java-home: /private/var/tmp/_bazel_jkyle/install/d07238c5957d0addf241b6be07f3c14b/embedded_tools/jdk
java-runtime: OpenJDK Runtime Environment (build 11.0.6+10-LTS) by Azul Systems, Inc.
java-vm: OpenJDK 64-Bit Server VM (build 11.0.6+10-LTS, mixed mode) by Azul Systems, Inc.
max-heap-size: 17179MB
output_base: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399
output_path: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/execroot/com_google_java_differential_privacy/bazel-out
package_path: %workspace%
release: release 4.1.0
repository_cache: /var/tmp/_bazel_jkyle/cache/repos/v1
server_log: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/java.log.ip-192-168-0-2.jkyle.log.java.20220901-144136.18665
server_pid: 18665
used-heap-size: 63MB
workspace: /Users/jkyle/IdeaProjects/differential-privacy/java
Ok, bazel info says it's using java11. But, if I execute the following it builds successfully
bazel-4.1.0 build --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11 ...
But if I do this, it fails with the error above
bazel-4.1.0 build --java_toolchain=@bazel_tools//tools/jdk:toolchain_java8 ...
I know there were changes in how @Generated is managed between java 8 and 11, so this is probably a consequence of that. Looking for a workaround.
build succeeds with java 17.
Ohh, k. I found a patch for the Gerrit Build that seemed to describe the same behavior I was seeing. And I looked at the executed javadoc command and it was referencing the host binary.
So I installed java 17, set that to JAVA_HOME, then ran the build with
bazel-4.1.0 build --java_toolchain=@bazel_tools//tools/jdk:toolchain_java8 ...
This succeeded. I verified the byte code by checking a class file
% file SecureNoiseMath.class
SecureNoiseMath.class: compiled Java class data, version 52.0 (Java 1.8)
So this looks good, maybe just needs a documentation update for building with 1.8?
Thanks for filing this issue and also figuring out a solution!
I wasn't able to reproduce this issue on Linux. However, we just updated the Auto Value and other dependencies for Java. Could you kindly check if this is still an issue for the current head?
Thanks :)
Looks like it's resolve don HEAD!
bazel-4.1.0 build ...
from the java workspace produces the following build errorsMacOS 12.5.1 Processor: 2.4 GHz 8-Core Intel Core i9