[build] silence protobuf sun.misc.Unsafe warnings from Java compile workers#17640
Merged
Conversation
Contributor
Review Summary by QodoSilence protobuf sun.misc.Unsafe warnings from Java compile workers
WalkthroughsDescription• Suppress protobuf sun.misc.Unsafe warnings from JDK 25 compile workers • Add custom Java toolchain with --sun-misc-unsafe-memory-access=allow flag • Register toolchain in base build config for local and RBE builds • Version-independent toolchain selection across JDK updates Diagramflowchart LR
A["JDK 25 Compile Workers"] -->|emit warnings| B["sun.misc.Unsafe Deprecation"]
C["Custom Java Toolchain"] -->|adds flag| D["--sun-misc-unsafe-memory-access=allow"]
D -->|suppresses| B
E[".bazelrc"] -->|registers| C
C -->|applies to| F["Local & RBE Builds"]
File Changes1. .bazelrc
|
Contributor
Code Review by Qodo
1. Pinned JDK in toolchain
|
Contributor
|
Code review by qodo was updated up to the latest commit 4aeb51d |
Contributor
|
Code review by qodo was updated up to the latest commit d4bdd12 |
Contributor
|
Code review by qodo was updated up to the latest commit 4204821 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issues
When #17598 bumped the build from JDK 21 to JDK 25,
sun.misc.Unsafeaccess became a terminal-deprecation warning, sowe're seeing thousands of
sun.misc.Unsafewarnings the Java compile workers spam into the console:💥 What does this PR do?
Registers a custom
default_java_toolchainthat appends--sun-misc-unsafe-memory-access=allowto the worker JVMs (jvm_optsfor JavaBuilder,turbine_jvm_optsfor Turbine), wired into the basebuildconfig so it applies to every build. The warnings are not RBE-specific — the sameremotejdk_25worker emits them on local builds too.🔧 Implementation Notes
--add-opensworkaround rules_java already ships no longer suppresses it; the new--sun-misc-unsafe-memory-access=allowflag does. rules_java runs all its compile workers onremotejdk_25, so the JDK-25 worker emits it.--jvmopt/--test_jvmopt/--host_jvm_argsall target the wrong process (seeJavaBuilderWorker JVM does not use jvm flags specified with--jvmoptbazelbuild/bazel#16486). The only supported lever for worker JVM args is adefault_java_toolchain, so this defines one that mirrors rules_java's default config and appends the flag.java_language_versiontarget_setting, so it is selected regardless of which version--java_language_versionis pinned to. A BUILD file can't read that bazelrc flag, so pinning a literal version would silently stop matching (and the warnings would return) the day the JDK is bumped. Actual source/target is governed by the global--javacopt="--release 11", so being version-independent is safe.buildconfig (not justbuild:rbe), because the warnings appear on local builds as well — anything compiling Java on theremotejdk_25worker hits them, not only RBE/CI.Alternatives Considered
ci-build.sh: lighter and would also catch the ClosureWorker and Ruby-bundler lines, but hides symptoms rather than fixing the cause and risks masking future real warnings.🤖 AI assistance
💡 Additional Considerations
🔄 Types of changes