diff options
author | Colin Cross <ccross@android.com> | 2018-01-02 18:14:25 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2018-01-02 18:23:43 -0800 |
commit | 7fdd2b788c760ea48e20f330ea5860d6a14c625c (patch) | |
tree | b839058822c02d9e560419b255e3942a175073a4 /java/java.go | |
parent | ee6143cde25cbe41df754337de89d608ca890bb1 (diff) |
Pass OpenJDK 8's bootclasspath for host tools targeting <= 1.8.
Follow the Make change in I9b6081edfdd2c3e9a450ae8a39c4e32c3d2cda92
to explicitly pass the OpenJDK 8 bootclasspath when targeting <= 1.8.
Bug: 70862583
Test: java_test.go
Test: javap -c -p out/soong/.intermediates/external/guava/guava/linux_glibc_common/javac/classes/com/google/common/hash/AbstractStreamingHashFunction\$AbstractStreamingHasher.class | grep ByteBuffer.flip
shows java/nio/Buffer return type in signature.
Change-Id: Ief66bbf6e3a4220b3afb2e02009bd0157d4c7fae
Diffstat (limited to 'java/java.go')
-rw-r--r-- | java/java.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go index dbf202a00..8159af850 100644 --- a/java/java.go +++ b/java/java.go @@ -597,6 +597,29 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB // classpath flags.bootClasspath.AddPaths(deps.bootClasspath) flags.classpath.AddPaths(deps.classpath) + + if len(flags.bootClasspath) == 0 && ctx.Host() && !ctx.Config().TargetOpenJDK9() && + !Bool(j.properties.No_standard_libs) && + inList(flags.javaVersion, []string{"1.6", "1.7", "1.8"}) { + // Give host-side tools a version of OpenJDK's standard libraries + // close to what they're targeting. As of Dec 2017, AOSP is only + // bundling OpenJDK 8 and 9, so nothing < 8 is available. + // + // When building with OpenJDK 8, the following should have no + // effect since those jars would be available by default. + // + // When building with OpenJDK 9 but targeting a version < 1.8, + // putting them on the bootclasspath means that: + // a) code can't (accidentally) refer to OpenJDK 9 specific APIs + // b) references to existing APIs are not reinterpreted in an + // OpenJDK 9-specific way, eg. calls to subclasses of + // java.nio.Buffer as in http://b/70862583 + java8Home := ctx.Config().Getenv("ANDROID_JAVA8_HOME") + flags.bootClasspath = append(flags.bootClasspath, + android.PathForSource(ctx, java8Home, "jre/lib/jce.jar"), + android.PathForSource(ctx, java8Home, "jre/lib/rt.jar")) + } + // systemModules if deps.systemModules != nil { flags.systemModules = append(flags.systemModules, deps.systemModules) |