From 5136a6e5aa5b8e9cb2705e81ab587ae8cba6ab5c Mon Sep 17 00:00:00 2001 From: Jingwen Chen Date: Fri, 30 Oct 2020 01:01:35 -0400 Subject: Add ctx.ModuleDir and top level module dirs of input sources to JDK9 --patch-module lookup. javac --patch-module accepts a list of directories and/or jars for JDK9 module patching (see bug for more details). In Bazel-Ninja execution, Bazel executes the javac action in its own execution root working directory, unlike Ninja, which works in the Android top level directory. The Bazel execution root is formed of a symlink forest of top level directories. This symlink forest is a problem for javac because it doesn't traverse into symlinks. To support Bazel executing these javac actions, we explicitly encode the module directory, and the top level directory of any other source file inputs into the --patch-module javac flag. For example, the "core-all" libcore module compiles into `java.base`, and depends on filegroups outside of `libcore` (`tools`). This CL adds `tools` to the --patch-module lookup dir, on top of `libcore`. See java_test.go for more details. Bug: 150878007 Fixes: 150878007 Test: m Test: bazel build droid (aosp_flame) Change-Id: Id95b0a9a675fc75678f7b5e600344b4403f0c518 --- java/java_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'java/java_test.go') diff --git a/java/java_test.go b/java/java_test.go index cdb437538..6c0a90856 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2046,7 +2046,14 @@ func TestPatchModule(t *testing.T) { java_library { name: "baz", - srcs: ["c.java"], + srcs: [ + "c.java", + // Tests for b/150878007 + "dir/d.java", + "dir2/e.java", + "dir2/f.java", + "nested/dir/g.java" + ], patch_module: "java.base", } ` @@ -2055,7 +2062,8 @@ func TestPatchModule(t *testing.T) { checkPatchModuleFlag(t, ctx, "foo", "") expected := "java.base=.:" + buildDir checkPatchModuleFlag(t, ctx, "bar", expected) - expected = "java.base=" + strings.Join([]string{".", buildDir, moduleToPath("ext"), moduleToPath("framework")}, ":") + expected = "java.base=" + strings.Join([]string{ + ".", buildDir, "dir", "dir2", "nested", moduleToPath("ext"), moduleToPath("framework")}, ":") checkPatchModuleFlag(t, ctx, "baz", expected) }) } -- cgit v1.2.3-59-g8ed1b