Skip to content

Commit

Permalink
Use the provided javac for host_javabase=9
Browse files Browse the repository at this point in the history
See bazelbuild#3410, bazelbuild#4812

Change-Id: Idd4adad7d48899c3b6de635d417446b71ba44afa
  • Loading branch information
cushon committed Mar 27, 2018
1 parent b8765a6 commit 63ef034
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 34 deletions.
14 changes: 14 additions & 0 deletions third_party/java/jdk/langtools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ filegroup(
srcs = [
"BUILD",
"LICENSE",
"java_compiler.jar",
"java_compiler-src.jar",
"javac-9+181-r4173-1.jar",
"javac-9+181-r4173-1.srcjar",
"jdk_compiler.jar",
"jdk_compiler-src.jar",
],
)

Expand All @@ -26,3 +30,13 @@ filegroup(
name = "javac_jar",
srcs = ["javac-9+181-r4173-1.jar"],
)

filegroup(
name = "jdk_compiler_jar",
srcs = ["jdk_compiler.jar"],
)

filegroup(
name = "java_compiler_jar",
srcs = ["java_compiler.jar"],
)
Binary file not shown.
Binary file added third_party/java/jdk/langtools/java_compiler.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions tools/jdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ default_java_toolchain(
default_java_toolchain(
name = "toolchain_jdk9",
jvm_opts = JDK9_JVM_OPTS,
tools = [
"@bazel_tools//third_party/java/jdk/langtools:java_compiler_jar",
"@bazel_tools//third_party/java/jdk/langtools:jdk_compiler_jar",
],
)

alias(
Expand Down
68 changes: 34 additions & 34 deletions tools/jdk/default_java_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Bazel rules for creating Java toolchains."""

JDK8_JVM_OPTS = [
"-Xbootclasspath/p:$(location //third_party/java/jdk/langtools:javac_jar)",
"-Xbootclasspath/p:$(location @bazel_tools//third_party/java/jdk/langtools:javac_jar)",
]

JDK9_JVM_OPTS = [
Expand All @@ -29,48 +29,48 @@ JDK9_JVM_OPTS = [
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",

# TODO(cushon): override the javac in the JDK.
# "--patch-module=java.compiler=$(location //third_party/java/jdk/langtools/blaze:java_compiler_jar)",
# "--patch-module=jdk.compiler=$(location //third_party/java/jdk/langtools/blaze:jdk_compiler_jar)",
# override the javac in the JDK.
"--patch-module=java.compiler=$(location @bazel_tools//third_party/java/jdk/langtools:java_compiler_jar)",
"--patch-module=jdk.compiler=$(location @bazel_tools//third_party/java/jdk/langtools:jdk_compiler_jar)",
]

DEFAULT_COMPATIBLE_JAVACOPTS = {
# Restrict protos to Java 7 so that they are compatible with Android.
"proto": [
"-source",
"7",
"-target",
"7",
],
# Restrict protos to Java 7 so that they are compatible with Android.
"proto": [
"-source",
"7",
"-target",
"7",
],
}

DEFAULT_JAVACOPTS = [
"-XDskipDuplicateBridges=true",
"-g",
"-parameters",
"-XDskipDuplicateBridges=true",
"-g",
"-parameters",
]

DEFAULT_TOOLCHAIN_CONFIGURATION = {
# javac -extdirs is implemented by appending the contents to the platform
# class path after -bootclasspath. For convenience, we currently have a
# single jar that contains the contents of both the bootclasspath and
# extdirs.
"bootclasspath": ["@bazel_tools//tools/jdk:platformclasspath.jar"],
"extclasspath": [],
"compatible_javacopts": DEFAULT_COMPATIBLE_JAVACOPTS,
"encoding": "UTF-8",
"forcibly_disable_header_compilation": 0,
"genclass": ["@bazel_tools//tools/jdk:genclass"],
"header_compiler": ["@bazel_tools//tools/jdk:turbine"],
"ijar": ["@bazel_tools//tools/jdk:ijar"],
"javabuilder": ["@bazel_tools//tools/jdk:javabuilder"],
"javac": ["//third_party/java/jdk/langtools:javac_jar"],
"javac_supports_workers": 1,
"jvm_opts": JDK8_JVM_OPTS,
"misc": DEFAULT_JAVACOPTS,
"singlejar": ["@bazel_tools//tools/jdk:singlejar"],
"source_version": "8",
"target_version": "8",
# javac -extdirs is implemented by appending the contents to the platform
# class path after -bootclasspath. For convenience, we currently have a
# single jar that contains the contents of both the bootclasspath and
# extdirs.
"bootclasspath": ["@bazel_tools//tools/jdk:platformclasspath.jar"],
"extclasspath": [],
"compatible_javacopts": DEFAULT_COMPATIBLE_JAVACOPTS,
"encoding": "UTF-8",
"forcibly_disable_header_compilation": 0,
"genclass": ["@bazel_tools//tools/jdk:genclass"],
"header_compiler": ["@bazel_tools//tools/jdk:turbine"],
"ijar": ["@bazel_tools//tools/jdk:ijar"],
"javabuilder": ["@bazel_tools//tools/jdk:javabuilder"],
"javac": ["@bazel_tools//third_party/java/jdk/langtools:javac_jar"],
"javac_supports_workers": 1,
"jvm_opts": JDK8_JVM_OPTS,
"misc": DEFAULT_JAVACOPTS,
"singlejar": ["@bazel_tools//tools/jdk:singlejar"],
"source_version": "8",
"target_version": "8",
}

def default_java_toolchain(name, **kwargs):
Expand Down

0 comments on commit 63ef034

Please sign in to comment.