Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build with JDK 21 #1556

Merged
merged 7 commits into from
Apr 8, 2024
Merged

Build with JDK 21 #1556

merged 7 commits into from
Apr 8, 2024

Conversation

simuons
Copy link
Collaborator

@simuons simuons commented Mar 21, 2024

Codebase doesn't build with jdk 21 with default settings.

Issue is that workers and test runners use SecurityManager which fails at runtime.

Fix is to conditionally add -Djava.security.manager=allow jvm flag to:

  • tools executed via ctx.actions.run if host jdk is >= 17
  • generated test executables if target jdk is >= 17

This change involves some kind of guessing with which jdk version worker will be run.

JDK is linked into worker/executable runfiles and it matches host jdk (hence added _java_host_runtime attribute to all relevant rules)

Added separate build for jdk 21

@simuons simuons marked this pull request as ready for review March 25, 2024 07:01
@simuons simuons requested a review from liucijus as a code owner March 25, 2024 07:01
test/BUILD Outdated
Comment on lines 779 to 794
#scala_library(
# name = "JunitRuntimePlatform",
# srcs = [
# "src/main/scala/scalarules/test/junit/runtime_platform/JunitRuntimePlatformTest.java",
# ],
# deps = ["@io_bazel_rules_scala_junit_junit"],
#)
#
#scala_junit_test(
# name = "JunitRuntimePlatform_test_runner",
# size = "small",
# runtime_jdk = "@bazel_tools//tools/jdk:remote_jdk11",
# suffixes = ["Test"],
# tests_from = [":JunitRuntimePlatform"],
# runtime_deps = [":JunitRuntimePlatform"],
#)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simuons are these accidentally commented out, or is there a reason? If there's a reason, please leave a comment in the code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liucijus thanks for noting. I forgot about it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liucijus fixed test for jdk > 11. Please take a look.

simuons added 7 commits April 8, 2024 12:39
Add -Djava.security.manager=allow jvm flag to:
- tools executed via ctx.actions.run if host jdk is >= 17
- generated test executables if target jdk is >= 17
Make sure compilation toolchain matches runtime target version

This test was failing with --java_language_version=21

Because it got compiled with newer jdk than was run.
@simuons simuons force-pushed the build-with-jdk-21 branch from a9aaa79 to 3233a86 Compare April 8, 2024 10:29
@liucijus liucijus merged commit 800cd82 into bazelbuild:master Apr 8, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants