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

Long live Java modules system.

Fixes: 254752344
Test: run build_kzip.bash
Change-Id: I9c807afd22d7b2abc2af1f6ac7a0c1e4c8a8b3e1
This commit is contained in:
Sasha Smundak
2022-10-23 15:23:55 -07:00
parent b2ea6c193e
commit 706d35fe7c

View File

@@ -83,9 +83,9 @@ var (
_ = 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 @@ var (
`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 ` +