Fix EXPERIMENTAL_USE_OPENJDK9=true build.
There are currently three different versions of some java.lang.invoke.*
classes used during compilation / while building java_system_modules:
1.) Manually curated stubs from:
libcore/ojluni/src/lambda/java/java/lang/invoke/
2.) Automatically generated stubs from core-platform-api-stubs.
3.) The full implementation classes from
libcore/ojluni/src/main/java/java/lang/invoke/
The manually curated stubs in 2.) are not complete, for example
CallSite.java is missing the package private CallSite(MethodType)
constructor and therefore gets a default (public no-arg) constructor
instead.
Mixing any two of these breaks compilation of java_system_modules targets:
* core-platform-api-stubs-system-modules broke because it combined
1.) and 2.).
* core-system-modules broke because it combined 1.) and 3.).
The classes from 1.) were included as part of core-lambda-stubs;
including them is inappropriate because the other classes in the
system_modules are a different kind of stubs (2., used in
core-platform-api-stubs-system-modules) or aren't stubs (3., used in
core-system-modules).
This CL fixes that by letting these system modules depend on a new
target core-lambda-stubs-for-system-modules, which omits the classes 1.).
This means that the system-modules only contain the version of these
classes from 2.) or 3.), as appropriate.
Bug: 118100586
Test: EXPERIMENTAL_USE_OPENJDK9=true make core-platform-api-stubs-system-modules
Test: Cherry-picked into internal branch and ran:
EXPERIMENTAL_USE_OPENJDK9=true make checkbuild docs
This command failed, but only at a late step and the
corresponding failure (ran out of space on a filesystem
in the image) is already happening prior to this CL.
Change-Id: I35e8d0b629dd1033afe50e4e674a09c1a16cd029
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index bbe1539..94ba05d 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -298,18 +298,12 @@
],
}
-// Creates a jar that exists to satisfy javac when compiling source code that
-// contains lambdas.
-java_library {
- name: "core-lambda-stubs",
+
+java_defaults {
+ name: "core_lambda_stubs_defaults",
defaults: ["libcore_java_defaults"],
hostdex: true,
- srcs: [
- ":openjdk_lambda_stub_files",
- ":openjdk_lambda_duplicate_stub_files",
- ],
-
no_standard_libs: true,
libs: ["core-all"],
system_modules: "core-all-system-modules",
@@ -323,6 +317,30 @@
include_srcs: true,
}
+// Creates a jar that exists to satisfy javac when compiling source code that
+// contains lambdas. This contains all classes / methods required by javac
+// when generating invoke-dynamic lambda implementation code, even those that
+// are also in the public SDK API from API level 26 onwards.
+java_library {
+ name: "core-lambda-stubs",
+ defaults: ["core_lambda_stubs_defaults"],
+ srcs: [
+ ":openjdk_lambda_stub_files",
+ ":openjdk_lambda_duplicate_stub_files",
+ ],
+}
+
+// An alternative to core-lambda-stubs that omits openjdk_lambda_duplicate_stub_files
+// because those classes are also part of the core library public SDK API
+// (since API level 26).
+java_library {
+ name: "core-lambda-stubs-for-system-modules",
+ defaults: ["core_lambda_stubs_defaults"],
+ srcs: [
+ ":openjdk_lambda_stub_files",
+ ],
+}
+
// A system modules definition containing the implementations for the various
// parts that make up the core library.
//
@@ -346,7 +364,7 @@
"apache-xml",
// This one is not on device but it's needed when javac compiles code
// containing lambdas.
- "core-lambda-stubs",
+ "core-lambda-stubs-for-system-modules",
],
}