Skip to content

Commit

Permalink
Java 16 toolchain
Browse files Browse the repository at this point in the history
Closes #13270.

Closes #13274.

Change-Id: I215c2f86a35f87bea0102cf6da5248b19a319d3e
PiperOrigin-RevId: 368591949
  • Loading branch information
davido authored and copybara-github committed Apr 15, 2021
1 parent e37a9ab commit e2ed2fd
Show file tree
Hide file tree
Showing 12 changed files with 466 additions and 10 deletions.
116 changes: 116 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,62 @@ http_archive(
],
)

# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.
http_archive(
name = "remotejdk16_linux_for_testing",
build_file = "@local_jdk//:BUILD.bazel",
patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE,
patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN,
sha256 = "236b5ea97aff3cb312e743848d7efa77faf305170e41371a732ca93c1b797665",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-linux_x64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-linux_x64.tar.gz",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-linux_x64.tar.gz",
],
)

# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.
http_archive(
name = "remotejdk16_macos_for_testing",
build_file = "@local_jdk//:BUILD.bazel",
patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE,
patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN,
sha256 = "6d47ef22dc56ce1f5a102ed39e21d9a97320f0bb786818e2c686393109d79bc5",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-macosx_x64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_x64.tar.gz",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_x64.tar.gz",
],
)

# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.
http_archive(
name = "remotejdk16_macos_aarch64_for_testing",
build_file = "@local_jdk//:BUILD.bazel",
patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE,
patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN,
sha256 = "c92131e83bc71474850e667bc4e05fca33662b8feb009a0547aa14e76b40e890",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-macosx_aarch64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_aarch64.tar.gz",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_aarch64.tar.gz",
],
)

# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.
http_archive(
name = "remotejdk16_win_for_testing",
build_file = "@local_jdk//:BUILD.bazel",
patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE,
patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN,
sha256 = "6cbf98ada27476526a5f6dff79fd5f2c15e2f671818e503bdf741eb6c8fed3d4",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-win_x64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-win_x64.zip",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-win_x64.zip",
],
)

# Used in src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.
dist_http_archive(
name = "remote_java_tools_for_testing",
Expand Down Expand Up @@ -790,6 +846,66 @@ exports_files(["WORKSPACE"], visibility = ["//visibility:public"])
],
)

# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives.
http_archive(
name = "openjdk16_linux_archive",
build_file_content = """
java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public'])
exports_files(["WORKSPACE"], visibility = ["//visibility:public"])
""",
sha256 = "236b5ea97aff3cb312e743848d7efa77faf305170e41371a732ca93c1b797665",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-linux_x64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-linux_x64.tar.gz",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-linux_x64.tar.gz",
],
)

# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives.
http_archive(
name = "openjdk16_darwin_archive",
build_file_content = """
java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public'])
exports_files(["WORKSPACE"], visibility = ["//visibility:public"])
""",
sha256 = "6d47ef22dc56ce1f5a102ed39e21d9a97320f0bb786818e2c686393109d79bc5",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-macosx_x64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_x64.tar.gz",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_x64.tar.gz",
],
)

# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives.
http_archive(
name = "openjdk16_darwin_aarch64_archive",
build_file_content = """
java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public'])
exports_files(["WORKSPACE"], visibility = ["//visibility:public"])
""",
sha256 = "c92131e83bc71474850e667bc4e05fca33662b8feb009a0547aa14e76b40e890",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-macosx_aarch64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_aarch64.tar.gz",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_aarch64.tar.gz",
],
)

# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives.
http_archive(
name = "openjdk16_windows_archive",
build_file_content = """
java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public'])
exports_files(["WORKSPACE"], visibility = ["//visibility:public"])
""",
sha256 = "6cbf98ada27476526a5f6dff79fd5f2c15e2f671818e503bdf741eb6c8fed3d4",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-win_x64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-win_x64.zip",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-win_x64.zip",
],
)

load("@io_bazel_skydoc//:setup.bzl", "stardoc_repositories")

stardoc_repositories()
Expand Down
8 changes: 8 additions & 0 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ filegroup(
"@openjdk15_darwin_archive//:WORKSPACE",
"@openjdk15_linux_archive//:WORKSPACE",
"@openjdk15_windows_archive//:WORKSPACE",
"@openjdk16_darwin_aarch64_archive//:WORKSPACE",
"@openjdk16_darwin_archive//:WORKSPACE",
"@openjdk16_linux_archive//:WORKSPACE",
"@openjdk16_windows_archive//:WORKSPACE",
"@openjdk_linux_aarch64_minimal//file",
"@openjdk_linux_minimal//file",
"@openjdk_macos_aarch64_minimal//file",
Expand All @@ -740,6 +744,10 @@ filegroup(
"@remotejdk15_macos_aarch64_for_testing//:WORKSPACE",
"@remotejdk15_macos_for_testing//:WORKSPACE",
"@remotejdk15_win_for_testing//:WORKSPACE",
"@remotejdk16_linux_for_testing//:WORKSPACE",
"@remotejdk16_macos_aarch64_for_testing//:WORKSPACE",
"@remotejdk16_macos_for_testing//:WORKSPACE",
"@remotejdk16_win_for_testing//:WORKSPACE",
"@rules_cc//:WORKSPACE",
"@rules_java//:WORKSPACE",
"@rules_pkg//:WORKSPACE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,74 @@ maybe(
version = "15",
)

# This must be kept in sync with the top-level WORKSPACE file.
maybe(
remote_java_repository,
name = "remotejdk16_linux",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
sha256 = "236b5ea97aff3cb312e743848d7efa77faf305170e41371a732ca93c1b797665",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-linux_x64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-linux_x64.tar.gz",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-linux_x64.tar.gz",
],
version = "16",
)

# This must be kept in sync with the top-level WORKSPACE file.
maybe(
remote_java_repository,
name = "remotejdk16_macos",
exec_compatible_with = [
"@platforms//os:macos",
"@platforms//cpu:x86_64",
],
sha256 = "6d47ef22dc56ce1f5a102ed39e21d9a97320f0bb786818e2c686393109d79bc5",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-macosx_x64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_x64.tar.gz",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_x64.tar.gz",
],
version = "16",
)

# This must be kept in sync with the top-level WORKSPACE file.
maybe(
remote_java_repository,
name = "remotejdk16_macos_aarch64",
exec_compatible_with = [
"@platforms//os:macos",
"@platforms//cpu:aarch64",
],
sha256 = "c92131e83bc71474850e667bc4e05fca33662b8feb009a0547aa14e76b40e890",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-macosx_aarch64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_aarch64.tar.gz",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-macosx_aarch64.tar.gz",
],
version = "16",
)

# This must be kept in sync with the top-level WORKSPACE file.
maybe(
remote_java_repository,
name = "remotejdk16_win",
exec_compatible_with = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
sha256 = "6cbf98ada27476526a5f6dff79fd5f2c15e2f671818e503bdf741eb6c8fed3d4",
strip_prefix = "zulu16.28.11-ca-jdk16.0.0-win_x64",
urls = [
"https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-win_x64.zip",
"https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-win_x64.zip",
],
version = "16",
)

{remote_java_tools}
{remote_java_tools_linux}
{remote_java_tools_windows}
Expand Down
4 changes: 4 additions & 0 deletions src/test/py/bazel/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class TestBase(unittest.TestCase):
'remotejdk15_macos_for_testing',
'remotejdk15_macos_aarch64_for_testing',
'remotejdk15_win_for_testing',
'remotejdk16_linux_for_testing',
'remotejdk16_macos_for_testing',
'remotejdk16_macos_aarch64_for_testing',
'remotejdk16_win_for_testing',
'remote_java_tools_for_testing',
'remote_java_tools_darwin_for_testing',
'remote_java_tools_linux_for_testing',
Expand Down
28 changes: 25 additions & 3 deletions src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,24 @@ sh_test(
tags = ["local"],
)

sh_test(
name = "bazel_java16_test",
srcs = ["bazel_java16_test.sh"],
args = [
# java_tools zip to test
"src/java_tools.zip",
"src/java_tools_prebuilt.zip",
],
data = [
":test-deps",
"//src:java_tools_prebuilt_zip",
"//src:java_tools_zip",
"//src/test/shell/bazel/testdata:jdk_http_archives_filegroup",
"@bazel_tools//tools/bash/runfiles",
],
tags = ["local"],
)

sh_test(
name = "bazel_java_test",
# TODO(iirina): Investigate if the 'large' and 'eternal' values still apply.
Expand All @@ -224,7 +242,11 @@ sh_test(
exec_compatible_with = ["//:highcpu_machine"],
)

JAVA_VERSIONS = ("11", "15")
JAVA_VERSIONS = ("11", "15", "16")

# TODO(davido): Enable test coverage for JDK 16 toolchain when this issue is fixed:
# https://github.com/bazelbuild/bazel/issues/13358
JAVA_VERSIONS_COVERAGE = ("11", "15")

[
sh_test(
Expand Down Expand Up @@ -484,7 +506,7 @@ sh_test(
"no_windows",
],
)
for java_version in JAVA_VERSIONS
for java_version in JAVA_VERSIONS_COVERAGE
]

# Test java coverage with the java_toolchain in the java_tools zip built at head.
Expand All @@ -510,7 +532,7 @@ sh_test(
],
tags = ["no_windows"],
)
for java_version in JAVA_VERSIONS
for java_version in JAVA_VERSIONS_COVERAGE
]

sh_test(
Expand Down
6 changes: 1 addition & 5 deletions src/test/shell/bazel/bazel_java15_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Tests that bazel runs projects with Java 14 features.
# Tests that bazel runs projects with Java 15 features.

# --- begin runfiles.bash initialization ---
if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
Expand Down Expand Up @@ -120,10 +120,6 @@ public class Javac15Example {
}
}
EOF
bazel run java/main:Javac15Example --java_language_version=14 --java_runtime_version=14 \
--test_output=all --verbose_failures &>"${TEST_log}" \
&& fail "Running with --java_language_version=14 unexpectedly succeeded."

bazel run java/main:Javac15Example --java_language_version=11 --java_runtime_version=11 \
--test_output=all --verbose_failures &>"${TEST_log}" \
&& fail "Running with --java_language_version=11 unexpectedly succeeded."
Expand Down
Loading

0 comments on commit e2ed2fd

Please sign in to comment.