Repository: kythe/kythe
Pull request #6049 (2024-03-12 17:14:03)

feat(java): Switch to add_exports
add_exports can be used instead of specifying exports in javacopts and jvm_flags. The values are passed up the dependency chain, so the top level binary no longer needs explicit jvm_flags.

add_exports was added in bazel 7.1.0 so this also needs a bazel version update.

https://bazel.build/reference/be/java#java_library.add_exports


Patch:
diff --git a/.bazelminversion b/.bazelminversion
index 19b860c18..a3fcc7121 100644
--- a/.bazelminversion
+++ b/.bazelminversion
@@ -1,1 +1,1 @@
-6.4.0
+7.1.0
diff --git a/.bazelversion b/.bazelversion
index a8907c025..a3fcc7121 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1,1 +1,1 @@
-7.0.2
+7.1.0
diff --git a/kythe/java/com/google/devtools/kythe/analyzers/java/BUILD b/kythe/java/com/google/devtools/kythe/analyzers/java/BUILD
index 33d56fe1c..df0a9bb15 100644
--- a/kythe/java/com/google/devtools/kythe/analyzers/java/BUILD
+++ b/kythe/java/com/google/devtools/kythe/analyzers/java/BUILD
@@ -17,12 +17,12 @@ java_library(
         "SourceText.java",
         "TreeContext.java",
     ],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.api",
+        "jdk.compiler/com.sun.tools.javac.code",
+        "jdk.compiler/com.sun.tools.javac.parser",
+        "jdk.compiler/com.sun.tools.javac.tree",
+        "jdk.compiler/com.sun.tools.javac.util",
     ],
     deps = [
         ":plugin",
@@ -55,10 +55,10 @@ java_library(
 java_library(
     name = "source_text",
     srcs = ["SourceText.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.parser",
+        "jdk.compiler/com.sun.tools.javac.tree",
+        "jdk.compiler/com.sun.tools.javac.util",
     ],
     deps = [
         "//kythe/java/com/google/devtools/kythe/platform/java/helpers",
@@ -71,10 +71,10 @@ java_library(
 java_library(
     name = "plugin",
     srcs = ["Plugin.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.code",
+        "jdk.compiler/com.sun.tools.javac.tree",
+        "jdk.compiler/com.sun.tools.javac.util",
     ],
     deps = [
         "//kythe/java/com/google/devtools/kythe/analyzers/base:entryset",
@@ -88,14 +88,6 @@ java_binary(
     name = "indexer",
     srcs = ["JavaIndexer.java"],
     jvm_flags = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
         # Avoid writing hsperdata logs to stdout and breaking everyting.
         # https://github.com/bazelbuild/bazel/issues/3236
         "-Xlog:disable",
@@ -130,11 +122,11 @@ java_library(
         "AutoValuePlugin.java",
         "ResolvedAutoValue.java",
     ],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.api",
+        "jdk.compiler/com.sun.tools.javac.code",
+        "jdk.compiler/com.sun.tools.javac.tree",
+        "jdk.compiler/com.sun.tools.javac.util",
     ],
     deps = [
         ":plugin",
diff --git a/kythe/java/com/google/devtools/kythe/extractors/java/BUILD b/kythe/java/com/google/devtools/kythe/extractors/java/BUILD
index d1f3fd4c3..6f5dd4ccf 100644
--- a/kythe/java/com/google/devtools/kythe/extractors/java/BUILD
+++ b/kythe/java/com/google/devtools/kythe/extractors/java/BUILD
@@ -11,12 +11,12 @@ java_library(
         "UsageAsInputReportingFileManager.java",
         "UsageAsInputReportingJavaFileObject.java",
     ],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.api",
+        "jdk.compiler/com.sun.tools.javac.code",
+        "jdk.compiler/com.sun.tools.javac.file",
+        "jdk.compiler/com.sun.tools.javac.main",
+        "jdk.compiler/com.sun.tools.javac.util",
     ],
     deps = [
         "//kythe/java/com/google/devtools/kythe/common:flogger",
diff --git a/kythe/java/com/google/devtools/kythe/extractors/java/bazel/BUILD b/kythe/java/com/google/devtools/kythe/extractors/java/bazel/BUILD
index 1459c9e4d..fbedfb6a2 100644
--- a/kythe/java/com/google/devtools/kythe/extractors/java/bazel/BUILD
+++ b/kythe/java/com/google/devtools/kythe/extractors/java/bazel/BUILD
@@ -6,12 +6,12 @@ package(default_visibility = ["//visibility:public"])
 java_binary(
     name = "java_extractor",
     srcs = ["JavaExtractor.java"],
-    jvm_flags = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.api",
+        "jdk.compiler/com.sun.tools.javac.code",
+        "jdk.compiler/com.sun.tools.javac.file",
+        "jdk.compiler/com.sun.tools.javac.main",
+        "jdk.compiler/com.sun.tools.javac.util",
     ],
     main_class = "com.google.devtools.kythe.extractors.java.bazel.JavaExtractor",
     deps = [
diff --git a/kythe/java/com/google/devtools/kythe/extractors/java/standalone/BUILD b/kythe/java/com/google/devtools/kythe/extractors/java/standalone/BUILD
index c118ef17a..ecd519d9d 100644
--- a/kythe/java/com/google/devtools/kythe/extractors/java/standalone/BUILD
+++ b/kythe/java/com/google/devtools/kythe/extractors/java/standalone/BUILD
@@ -9,18 +9,11 @@ exports_files(["javac-wrapper.sh"])
 java_binary(
     name = "javac_extractor",
     srcs = ["JavacWrapper.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
-    ],
-    jvm_flags = [
-        "--add-exports=jdk.internal.opt/jdk.internal.opt=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.file",
+        "jdk.compiler/com.sun.tools.javac.main",
+        "jdk.compiler/com.sun.tools.javac.util",
+        "jdk.internal.opt/jdk.internal.opt",
     ],
     main_class = "com.google.devtools.kythe.extractors.java.standalone.JavacWrapper",
     visibility = ["//visibility:public"],
@@ -37,8 +30,8 @@ java_binary(
 java_library(
     name = "abstract_javac_wrapper",
     srcs = ["AbstractJavacWrapper.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.main",
     ],
     runtime_deps = [
         ":reflective_jdk_compatibility_shims",
@@ -70,8 +63,8 @@ java_library(
 java_library(
     name = "jdk_compatibility_shims",
     srcs = ["JdkCompatibilityShims.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.main",
     ],
     visibility = ["//visibility:private"],
     deps = ["//kythe/java/com/google/devtools/kythe/util:ordered_compatibility_service"],
@@ -80,8 +73,10 @@ java_library(
 java_library(
     name = "jdk9_compatibility_shims",
     srcs = ["9/JdkCompatibilityShimsImpl.java"],
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.main",
+    ],
     javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
         "-Xep:PackageLocation:OFF",
     ],
     target_compatible_with = select_with_or({
@@ -103,8 +98,10 @@ java_library(
 java_library(
     name = "jdk15_compatibility_shims",
     srcs = ["15/JdkCompatibilityShimsImpl.java"],
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.main",
+    ],
     javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
         "-Xep:PackageLocation:OFF",
     ],
     # This is incompatible with the default test configuration and
@@ -130,10 +127,12 @@ java_library(
 java_library(
     name = "jdk21_compatibility_shims",
     srcs = ["21/JdkCompatibilityShimsImpl.java"],
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.main",
+        "jdk.compiler/com.sun.tools.javac.tree",
+        "jdk.internal.opt/jdk.internal.opt",
+    ],
     javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-        "--add-exports=jdk.internal.opt/jdk.internal.opt=ALL-UNNAMED",
         "-Xep:PackageLocation:OFF",
     ],
     # This is incompatible with the default test configuration and
@@ -157,12 +156,12 @@ java_library(
 java_library(
     name = "reflective_jdk_compatibility_shims",
     srcs = ["ReflectiveJdkCompatibilityShims.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.main",
     ] + select_with_or({
         (
             "//buildenv/java:language_version_21",
-        ): ["--add-exports=jdk.internal.opt/jdk.internal.opt=ALL-UNNAMED"],
+        ): ["jdk.internal.opt/jdk.internal.opt"],
         "//conditions:default": [],
     }),
     visibility = ["//visibility:private"],
diff --git a/kythe/java/com/google/devtools/kythe/platform/java/BUILD b/kythe/java/com/google/devtools/kythe/platform/java/BUILD
index 66ccb7467..ccd66eb2a 100644
--- a/kythe/java/com/google/devtools/kythe/platform/java/BUILD
+++ b/kythe/java/com/google/devtools/kythe/platform/java/BUILD
@@ -9,8 +9,8 @@ java_library(
         "JavacAnalysisDriver.java",
         "JavacAnalyzer.java",
     ],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.api",
     ],
     deps = [
         ":options",
@@ -31,12 +31,12 @@ java_library(
 java_library(
     name = "options",
     srcs = ["JavacOptionsUtils.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.api",
+        "jdk.compiler/com.sun.tools.javac.code",
+        "jdk.compiler/com.sun.tools.javac.file",
+        "jdk.compiler/com.sun.tools.javac.main",
+        "jdk.compiler/com.sun.tools.javac.util",
     ],
     deps = [
         "//kythe/java/com/google/devtools/kythe/common:flogger",
diff --git a/kythe/java/com/google/devtools/kythe/platform/java/filemanager/BUILD b/kythe/java/com/google/devtools/kythe/platform/java/filemanager/BUILD
index 5fae36cb0..ef22a9050 100644
--- a/kythe/java/com/google/devtools/kythe/platform/java/filemanager/BUILD
+++ b/kythe/java/com/google/devtools/kythe/platform/java/filemanager/BUILD
@@ -5,18 +5,18 @@ package(default_visibility = ["//kythe:default_visibility"])
 java_library(
     name = "forwarding_standard_java_file_manager",
     srcs = ["ForwardingStandardJavaFileManager.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.api",
     ],
 )
 
 java_library(
     name = "filemanager",
     srcs = ["CompilationUnitPathFileManager.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.api",
+        "jdk.compiler/com.sun.tools.javac.main",
+        "jdk.compiler/com.sun.tools.javac.util",
     ],
     deps = [
         ":forwarding_standard_java_file_manager",
diff --git a/kythe/java/com/google/devtools/kythe/platform/java/helpers/BUILD b/kythe/java/com/google/devtools/kythe/platform/java/helpers/BUILD
index 68bfb3a5c..dc21eaf9a 100644
--- a/kythe/java/com/google/devtools/kythe/platform/java/helpers/BUILD
+++ b/kythe/java/com/google/devtools/kythe/platform/java/helpers/BUILD
@@ -13,12 +13,12 @@ java_library(
         "SignatureGenerator.java",
         "SyntaxPreservingScanner.java",
     ],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.code",
+        "jdk.compiler/com.sun.tools.javac.model",
+        "jdk.compiler/com.sun.tools.javac.parser",
+        "jdk.compiler/com.sun.tools.javac.tree",
+        "jdk.compiler/com.sun.tools.javac.util",
     ],
     runtime_deps = [
         ":reflective_jdk_compatibility_shims",
@@ -50,9 +50,9 @@ java_library(
 java_library(
     name = "jdk_compatibility_shims",
     srcs = ["JdkCompatibilityShims.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.parser",
+        "jdk.compiler/com.sun.tools.javac.tree",
     ],
     visibility = ["//visibility:private"],
     deps = [
@@ -63,9 +63,11 @@ java_library(
 java_library(
     name = "jdk9_compatibility_shims",
     srcs = ["9/JdkCompatibilityShimsImpl.java"],
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.parser",
+        "jdk.compiler/com.sun.tools.javac.tree",
+    ],
     javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
         "-Xep:PackageLocation:OFF",
     ],
     target_compatible_with = select_with_or({
@@ -87,8 +89,10 @@ java_library(
 java_library(
     name = "jdk15_compatibility_shims",
     srcs = ["15/JdkCompatibilityShimsImpl.java"],
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.tree",
+    ],
     javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
         "-Xep:PackageLocation:OFF",
     ],
     # This is incompatible with the default test configuration and
@@ -112,8 +116,10 @@ java_library(
 java_library(
     name = "jdk20_compatibility_shims",
     srcs = ["20/JdkCompatibilityShimsImpl.java"],
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.tree",
+    ],
     javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
         "-Xep:PackageLocation:OFF",
     ],
     tags = ["manual"],
@@ -134,8 +140,10 @@ java_library(
 java_library(
     name = "jdk21_compatibility_shims",
     srcs = ["21/JdkCompatibilityShimsImpl.java"],
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.tree",
+    ],
     javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
         "-Xep:PackageLocation:OFF",
     ],
     tags = ["manual"],
@@ -156,9 +164,9 @@ java_library(
 java_library(
     name = "reflective_jdk_compatibility_shims",
     srcs = ["ReflectiveJdkCompatibilityShimsImpl.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.parser",
+        "jdk.compiler/com.sun.tools.javac.tree",
     ],
     visibility = ["//visibility:private"],
     deps = [
diff --git a/version.bzl b/version.bzl
index 25db9502e..fbb0165b2 100644
--- a/version.bzl
+++ b/version.bzl
@@ -1,8 +1,8 @@
 # Minimum supported Bazel version.  Should match .bazelminversion file.
-MIN_VERSION = "6.4.0"
+MIN_VERSION = "7.1.0"
 
 # Maximum supported Bazel version.  Should match .bazelversion file.
-MAX_VERSION = "7.0.2"
+MAX_VERSION = "7.1.0"
 
 def _tuplicate(value, delim):
     rv = ()


Test patch:
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/BUILD b/kythe/javatests/com/google/devtools/kythe/analyzers/java/BUILD
index dc486bd06..c47064882 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/BUILD
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/BUILD
@@ -55,10 +55,10 @@ java_test(
 java_library(
     name = "test_plugin",
     srcs = ["TestPlugin.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.code",
+        "jdk.compiler/com.sun.tools.javac.tree",
+        "jdk.compiler/com.sun.tools.javac.util",
     ],
     visibility = ["//kythe/javatests/com/google/devtools/kythe/analyzers/java:__subpackages__"],
     deps = [
diff --git a/kythe/javatests/com/google/devtools/kythe/extractors/java/BUILD b/kythe/javatests/com/google/devtools/kythe/extractors/java/BUILD
index f3be0a495..71cff6544 100644
--- a/kythe/javatests/com/google/devtools/kythe/extractors/java/BUILD
+++ b/kythe/javatests/com/google/devtools/kythe/extractors/java/BUILD
@@ -8,13 +8,6 @@ java_test(
         ":SillyProcessor_deploy.jar",
     ],
     javacopts = ["-Xlint:all"],
-    jvm_flags = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
-    ],
     test_class = "com.google.devtools.kythe.extractors.java.JavaExtractorTest",
     deps = [
         "//kythe/java/com/google/devtools/kythe/extractors/java",
diff --git a/kythe/javatests/com/google/devtools/kythe/platform/java/BUILD b/kythe/javatests/com/google/devtools/kythe/platform/java/BUILD
index fd37888a3..796cc3dd4 100644
--- a/kythe/javatests/com/google/devtools/kythe/platform/java/BUILD
+++ b/kythe/javatests/com/google/devtools/kythe/platform/java/BUILD
@@ -6,16 +6,9 @@ java_test(
     name = "options_utils_test",
     size = "small",
     srcs = ["OptionsTest.java"],
-    javacopts = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
-    ],
-    jvm_flags = [
-        "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-        "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+    add_exports = [
+        "jdk.compiler/com.sun.tools.javac.code",
+        "jdk.compiler/com.sun.tools.javac.main",
     ],
     test_class = "com.google.devtools.kythe.platform.java.OptionsTest",
     deps = [