From 706d35fe7c6b7d89d7d57beeec5d6f988eb19674 Mon Sep 17 00:00:00 2001 From: Sasha Smundak Date: Sun, 23 Oct 2022 15:23:55 -0700 Subject: [PATCH] Add --add-exports= options to the java extractor invocation. Long live Java modules system. Fixes: 254752344 Test: run build_kzip.bash Change-Id: I9c807afd22d7b2abc2af1f6ac7a0c1e4c8a8b3e1 --- java/builder.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/java/builder.go b/java/builder.go index c0fadd42c..b1b9a4a07 100644 --- a/java/builder.go +++ b/java/builder.go @@ -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 ` +