Skip to content

Commit

Permalink
upgrade to jdk17 (#19214)
Browse files Browse the repository at this point in the history
* initial attempt to upgrade to jdk17

* patch rules_nixpkgs to allow for jdk 17

* format

* fix compatibility/.bazelrc

* update jar_jar, disable jdk8

* get jarjar's hash right

* ignore timestamp parsing test for now

* fix build-release-artifacts

* fix JsonLfDecodersTest in the code drop

* dadew

---------

Co-authored-by: = <=>
Co-authored-by: Gary Verhaegen <gary.verhaegen@digitalasset.com>
  • Loading branch information
paulbrauner-da and garyverhaegen-da authored May 17, 2024
1 parent 1064fff commit 9472bf3
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 65 deletions.
8 changes: 4 additions & 4 deletions sdk/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ test --strategy=Scalac=worker
# https://github.com/grpc/grpc/pull/13929/files
build --copt -DGRPC_BAZEL_BUILD

build --java_language_version=11
build --java_runtime_version=nixpkgs_java_11
build --tool_java_runtime_version=nixpkgs_java_11
build --tool_java_language_version=11
build --java_language_version=17
build --java_runtime_version=nixpkgs_java_17
build --tool_java_runtime_version=nixpkgs_java_17
build --tool_java_language_version=17

# Propagate locales and the java home to the test environment.
build --test_env=LANG=en_US.utf8 --test_env=LOCALE_ARCHIVE --test_env=JAVA_HOME
Expand Down
2 changes: 1 addition & 1 deletion sdk/.dadew
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"cacert",
"curl",
"gcloud",
"ojdkbuild11",
"jdk",
"maven-3.6.1",
"msys2",
"nodejs-14",
Expand Down
6 changes: 3 additions & 3 deletions sdk/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -576,17 +576,17 @@ load("//bazel_tools:java.bzl", "dadew_java_configure")

dadew_java_configure(
name = "dadew_java_runtime",
dadew_path = "ojdkbuild11",
dadew_path = "jdk",
) if is_windows else None

nixpkgs_java_configure(
attribute_path = "jdk11.home",
attribute_path = "jdk17.home",
nix_file = "//nix:bazel.nix",
nix_file_deps = common_nix_file_deps,
repositories = dev_env_nix_repos,
toolchain = True,
toolchain_name = "nixpkgs_java",
toolchain_version = "11",
toolchain_version = "17",
) if not is_windows else None

# rules_go used here to compile a wrapper around the protoc-gen-scala plugin
Expand Down
18 changes: 18 additions & 0 deletions sdk/bazel_tools/jvm-opts.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/toolchains/java/default_java_toolchain.bzl b/toolchains/java/default_java_toolchain.bzl
index 1919433..6cf40bc 100644
--- a/toolchains/java/default_java_toolchain.bzl
+++ b/toolchains/java/default_java_toolchain.bzl
@@ -42,8 +42,8 @@ BASE_JDK9_JVM_OPTS = [

JDK9_JVM_OPTS = BASE_JDK9_JVM_OPTS + [
# override the javac in the JDK.
- "--patch-module=java.compiler=$(location @remote_java_tools//:java_compiler_jar)",
- "--patch-module=jdk.compiler=$(location @remote_java_tools//:jdk_compiler_jar)",
+ #"--patch-module=java.compiler=$(location @remote_java_tools//:java_compiler_jar)",
+ #"--patch-module=jdk.compiler=$(location @remote_java_tools//:jdk_compiler_jar)",
]

DEFAULT_JAVACOPTS = [
--
2.34.1

Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public void testTimestamp() throws JsonLfDecoder.Error {
eq("\"1990-11-09T04:30:23.12Z\"", timestampUTC(1990, Month.NOVEMBER, 9, 4, 30, 23, 120000)),
eq("\"1990-11-09T04:30:23.1Z\"", timestampUTC(1990, Month.NOVEMBER, 9, 4, 30, 23, 100000)),
eq("\"1990-11-09T04:30:23Z\"", timestampUTC(1990, Month.NOVEMBER, 9, 4, 30, 23, 0)),
eq("\"0001-01-01T00:00:00Z\"", timestampUTC(1, Month.JANUARY, 1, 0, 0, 0, 0)));
eq("\"0001-01-01T00:00:00Z\"", timestampUTC(1, Month.JANUARY, 1, 0, 0, 0, 0)),
eq("\"1990-11-09T04:30:23.123-07:00\"", timestampUTC(1990, Month.NOVEMBER, 9, 11, 30, 23, 123000)));
}

@Test
Expand All @@ -173,12 +174,6 @@ public void testTimestampErrors() throws JsonLfDecoder.Error {
"\"1990-11-09\"",
"Expected valid ISO 8601 date and time in UTC but was 1990-11-09 at line: 1, column: 1",
DateTimeParseException.class),
// Time zone
errors(
"\"1990-11-09T04:30:23.123-07:00\"",
"Expected valid ISO 8601 date and time in UTC but was 1990-11-09T04:30:23.123-07:00 at"
+ " line: 1, column: 1",
DateTimeParseException.class),
// No -
errors(
"\"19901109T043023Z\"",
Expand Down
8 changes: 4 additions & 4 deletions sdk/compatibility/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ test --strategy=Scalac=worker
# https://github.com/grpc/grpc/pull/13929/files
build --copt -DGRPC_BAZEL_BUILD

build --java_language_version=11
build --java_runtime_version=nixpkgs_java_11
build --tool_java_runtime_version=nixpkgs_java_11
build --tool_java_language_version=11
build --java_language_version=17
build --java_runtime_version=nixpkgs_java_17
build --tool_java_runtime_version=nixpkgs_java_17
build --tool_java_language_version=17

# Propagate locales and the java home to the test environment.
build --test_env=LANG=en_US.utf8 --test_env=LOCALE_ARCHIVE --test_env=JAVA_HOME
Expand Down
6 changes: 3 additions & 3 deletions sdk/compatibility/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,17 @@ load("@daml//bazel_tools:java.bzl", "dadew_java_configure")

dadew_java_configure(
name = "dadew_java_runtime",
dadew_path = "ojdkbuild11",
dadew_path = "jdk",
) if is_windows else None

nixpkgs_java_configure(
attribute_path = "jdk11.home",
attribute_path = "jdk17.home",
nix_file = "@daml//nix:bazel.nix",
nix_file_deps = common_nix_file_deps,
repositories = dev_env_nix_repos,
toolchain = True,
toolchain_name = "nixpkgs_java",
toolchain_version = "11",
toolchain_version = "17",
) if not is_windows else None

load("@rules_jvm_external//:defs.bzl", "maven_install")
Expand Down
8 changes: 4 additions & 4 deletions sdk/compatibility/build-release-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ HEAD_TARGET_DIR=${1:-compatibility/head_sdk}
git clean -fxd -e 'daml-*.tgz' $HEAD_TARGET_DIR

bazel build \
--java_language_version=11 \
--java_runtime_version=nixpkgs_java_11 \
--tool_java_runtime_version=nixpkgs_java_11 \
--tool_java_language_version=11 \
--java_language_version=17 \
--java_runtime_version=nixpkgs_java_17 \
--tool_java_runtime_version=nixpkgs_java_17 \
--tool_java_language_version=17 \
//release:sdk-release-tarball \
//daml-assistant:daml

Expand Down
26 changes: 23 additions & 3 deletions sdk/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ rules_nixpkgs_sha256 = "46aa0ca80b77848492aa1564e9201de9ed79588ca1284f8a4f76deb7
rules_nixpkgs_patches = [
]

rules_nixpkgs_toolchain_patches = {
"java": [
# rules_nixpkgs passes a --patch-module=java.compiler=... option to
# jvm_opts which is no longer necessary nor compatible with jkd 17 (see
# https://github.com/bazelbuild/bazel/issues/14474#issuecomment-1001071398).
# This is fixed in rules_nixpkgs v0.10.0 (see
# https://github.com/tweag/rules_nixpkgs/commit/c2c5ffaf559a7ec08a7b4ac5ba0f0369650df970),
# but migrating to this version of rules_nixpkgs is a non-trivial piece
# of work. In the meantime we backport the relevant 2 lines of the fix.
"@com_github_digital_asset_daml//bazel_tools:jvm-opts.patch",
],
"cc": [],
"python": [],
"go": [],
"rust": [],
"posix": [],
}

buildifier_version = "b163fcf72b7def638f364ed129c9b28032c1d39b"
buildifier_sha256 = "c2399161fa569f7c815f8e27634035557a2e07a557996df579412ac73bf52c23"
zlib_version = "1.2.11"
Expand Down Expand Up @@ -139,6 +157,8 @@ def daml_deps():
strip_prefix = strip_prefix + "/toolchains/" + toolchain,
urls = ["https://github.com/tweag/rules_nixpkgs/archive/%s.tar.gz" % rules_nixpkgs_version],
sha256 = rules_nixpkgs_sha256,
patches = rules_nixpkgs_toolchain_patches[toolchain],
patch_args = ["-p3"],
)

if "com_github_madler_zlib" not in native.existing_rules():
Expand Down Expand Up @@ -285,9 +305,9 @@ def daml_deps():
if "com_github_johnynek_bazel_jar_jar" not in native.existing_rules():
http_archive(
name = "com_github_johnynek_bazel_jar_jar",
sha256 = "64748da73bc82ecbbb2a872722690a3be52c06bb92a1c939136e2852470f308d",
strip_prefix = "bazel_jar_jar-20dbf71f09b1c1c2a8575a42005a968b38805519",
urls = ["https://github.com/johnynek/bazel_jar_jar/archive/20dbf71f09b1c1c2a8575a42005a968b38805519.tar.gz"], # Latest commit SHA as at 2019/02/13
sha256 = "a9d2ca9a2e9014f8d63dcbe9091bcb9f2d2929b3b7d16836c6225e98f9ca54df",
strip_prefix = "bazel_jar_jar-0.1.5",
url = "https://github.com/bazeltools/bazel_jar_jar/releases/download/v0.1.5/bazel_jar_jar-v0.1.5.tar.gz",
)

if "com_github_bazelbuild_remote_apis" not in native.existing_rules():
Expand Down
8 changes: 8 additions & 0 deletions sdk/dev-env/windows/manifests/jdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{"homepage": "https://jdk.java.net/archive/",
"version": "17.0.2",
"license": "GPL-2.0-only WITH Classpath-exception-2.0",
"architecture": {"64bit": {"url": "https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_windows-x64_bin.zip",
"hash": "b2208206bda47f2e0c971a39e057a5ec32c40b503d71e486790cb728d926b615",
"extract_dir": "jdk-17.0.2"}},
"env_add_path": "bin",
"env_set": {"JAVA_HOME": "$dir"}}
32 changes: 0 additions & 32 deletions sdk/dev-env/windows/manifests/ojdkbuild11.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ class ApiCodecCompressedSpec
("\"garbage\"", VA.int64, ""),
("\" 42 \"", VA.int64, ""),
("\"1970-01-01T00:00:00\"", VA.timestamp, ""),
("\"1970-01-01T00:00:00+01:00\"", VA.timestamp, ""),
// TODO(https://github.com/digital-asset/daml/issues/19195): this string actually parses on jdk17
// ("\"1970-01-01T00:00:00+01:00\"", VA.timestamp, ""),
("\"1970-01-01T00:00:00+01:00[Europe/Paris]\"", VA.timestamp, ""),
("\"0000-01-01\"", VA.date, "Invalid date: 0000-01-01"),
("\"9999-99-99\"", VA.date, "Invalid date: 9999-99-99"),
Expand Down
3 changes: 1 addition & 2 deletions sdk/nix/bazel.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ let shared = rec {
grpcurl
gzip
imagemagick
jdk11
jdk8
jdk17
jekyll
jq
netcat-gnu
Expand Down
2 changes: 1 addition & 1 deletion sdk/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ in rec {

zinc = pkgs.callPackage ./tools/zinc {};

jdk = bazel_dependencies.jdk11;
jdk = bazel_dependencies.jdk17;
java = jdk;
javac = jdk;
jinfo = jdk;
Expand Down

0 comments on commit 9472bf3

Please sign in to comment.