Add --add-exports= options to the java extractor invocation.

Long live Java modules system.

Fixes: 254752344
Test: run build_kzip.bash
Change-Id: I9c807afd22d7b2abc2af1f6ac7a0c1e4c8a8b3e1
diff --git a/java/builder.go b/java/builder.go
index c0fadd4..b1b9a4a 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -83,9 +83,9 @@
 	_ = pctx.VariableFunc("kytheCuJavaSourceMax",
 		func(ctx android.PackageVarContext) string { return ctx.Config().XrefCuJavaSourceMax() })
 	_ = pctx.SourcePathVariable("kytheVnames", "build/soong/vnames.json")
-	// Run it with -add-opens=java.base/java.nio=ALL-UNNAMED to avoid JDK9's warning about
-	// "Illegal reflective access by com.google.protobuf.Utf8$UnsafeProcessor ...
-	// to field java.nio.Buffer.address"
+	// Run it with several --add-exports to allow the classes in the
+	// com.google.devtools.kythe.extractors.java.standalone package access the packages in the
+	// jdk.compiler compiler module. Long live Java modules.
 	kytheExtract = pctx.AndroidStaticRule("kythe",
 		blueprint.RuleParams{
 			Command: `${config.ZipSyncCmd} -d $srcJarDir ` +
@@ -97,7 +97,17 @@
 				`KYTHE_KZIP_ENCODING=${kytheCuEncoding} ` +
 				`KYTHE_JAVA_SOURCE_BATCH_SIZE=${kytheCuJavaSourceMax} ` +
 				`${config.SoongJavacWrapper} ${config.JavaCmd} ` +
+				// Avoid JDK9's warning about "Illegal reflective access by com.google.protobuf.Utf8$UnsafeProcessor ...
+				// to field java.nio.Buffer.address"
 				`--add-opens=java.base/java.nio=ALL-UNNAMED ` +
+				// Allow the classes in the com.google.devtools.kythe.extractors.java.standalone package
+				// access the packages in the jdk.compiler compiler module
+				`--add-opens=java.base/java.nio=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=ALL-UNNAMED ` +
+				`--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED ` +
+				`--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED ` +
 				`-jar ${config.JavaKytheExtractorJar} ` +
 				`${config.JavacHeapFlags} ${config.CommonJdkFlags} ` +
 				`$processorpath $processor $javacFlags $bootClasspath $classpath ` +