Mark out an mmodule API surface / add bi-dir deps
This commit introduces the term "mmodule" in place of
"module" for the thing that is being prototyped;
"module" is a heavily overloaded term so
the extra "m" is intended to make it easier to track /
understand what "type of" module is involved.
Important parts of this commit:
+ {simple mmodule}.TestClass has been renamed to
DemoSimpleClass to distinguish it from a test and new
similar class being added in libart (DemoLibartClass).
+ Adds the @IntraCoreMModuleApi annotation; it is used to
indicate API members that form part of a "core" mmodule
contract (either incoming or outgoing dependency of a
libcore mmodule) that must be kept stable.
+ Annotates parts of the DemoSimpleClass to make them part
of the "simple mmodule API" contract.
+ Adds a method in the simple mmodule that isn't annotated
to demonstrate (Java) public methods that are not part
of the mmodule contract.
+ Includes a new target "core-simple.mmodule.stubs"
which generates the simple mmodule API stubs.
+ Includes a new target "core-all.mmodule.stubs"
which generates the mmodule API stubs for the core-all
library.
+ Adds bi-direction dependencies between parts of the
boot classpath. This makes the code a more realistic part
of "core" for prototyping / demostration purposes:
- DemoSimpleClass (now) has a method that calls through
to a method on DemoLibartClass to demonstrate a
dependency from {simple mmodule} onto core-libart.
- DemoLibartClass has a similar arrangement going in the
other direction making core-libart depend on {simple
mmodule} (making a bi-dir dependency but without an
infinite loop at runtime).
+ A test has been added for DemoLibartClass in the
CtsLibcoreSimpleMModuleTestCases to confirm the bi-dir
behavior in an automated test.
Bug: 113148576
Test: make checkbuild / make cts
Test: CTS: run cts -m CtsLibcoreSimpleModuleTestCases
Change-Id: I5564d6be61eba4c0116e91c601e32208da104f02
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index a728d61..c6b0855 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -16,21 +16,23 @@
// Definitions for building the Java library and associated tests.
//
-// libcore is divided into modules.
+// libcore has some sub-directories that follow a common structure:
+// e.g. dalvik, dom, harmony-tests, json, jsr166-tests, luni, libart, ojluni,
+// support, xml, xmlpull.
//
-// The structure of each module is:
+// The structure of these is generally:
//
// src/
// main/ # To be shipped on every device.
// java/ # Java source for library code.
-// native/ # C++ source for library code.
+// native/ # C/C++ source for library code.
// resources/ # Support files.
// test/ # Built only on demand, for testing.
// java/ # Java source for tests.
-// native/ # C++ source for tests (rare).
+// native/ # C/C++ source for tests (rare).
// resources/ # Support files.
//
-// All subdirectories are optional
+// All subdirectories are optional.
build = [
"openjdk_java_files.bp",
@@ -70,6 +72,7 @@
":openjdk_java_files",
":non_openjdk_java_files",
":android_icu4j_src_files",
+ ":core_simple_mmodule_java_files",
":openjdk_lambda_stub_files",
],
@@ -522,3 +525,41 @@
no_standard_libs: true,
system_modules: "none",
}
+
+//
+// Targets related to core mmodule APIs / dependencies.
+//
+
+// Generates stub source files for the {public SDK API + intra-core mmodule API}
+// of core-all.
+droiddoc {
+ name: "core-all-mmodule-stubs-docs",
+ srcs: [
+ ":openjdk_javadoc_files",
+ ":non_openjdk_javadoc_files",
+ ":android_icu4j_src_files_for_docs",
+ ":core_simple_mmodule_java_files",
+ ],
+
+ installable: false,
+ no_framework_libs: true,
+ metalava_enabled: true,
+ args: "-nodocs -stubsourceonly -showAnnotation libcore.mmodule.IntraCoreMModuleApi",
+}
+
+// A library containing the {public SDK API + intra-core mmodule API} stubs for
+// core-all.
+java_library {
+ name: "core-all.mmodule.stubs",
+ srcs: [
+ ":core-all-mmodule-stubs-docs",
+ ],
+ no_framework_libs: true,
+
+ no_standard_libs: true,
+ libs: ["core-all"],
+ system_modules: "core-all-system-modules",
+ openjdk9: {
+ javacflags: ["--patch-module=java.base=."],
+ },
+}