From 18554243de2edc5350bbb8bc234a7c15141c30d3 Mon Sep 17 00:00:00 2001 From: Ulya Trafimovich Date: Tue, 3 Nov 2020 15:55:11 +0000 Subject: Add nested class loader subcontext at the proper hierarchy level. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When adding a subcontext in a class loader context tree, there are two possible cases: 1) the root of the subcontext is itself a and should be present as a node in the tree, or 2) the root is not a , but some of its dependencies are -- in that case they should be disconnected from the root, and the resulting forrest should be added at the top-level. Example: 1) C is a : A ├── B └── C ├── D └── E └── F 2) C is not a : A ├── B ├── D └── E └── F Before the patch subcontexts for transitive dependencies were added before the subcontext for the direct dependency (even if it was a , resulting in case-2 hierarchy when case-1 should have been used. Previosuly this didn't matter because class loader context was a flat set of libraries, but now it matters because class loader context is a tree. This patch changes the order in which libraries are added, so that direct dependencies are added before transitive ones. The context adding method now accepts an "implicit root" parameter, so that when adding transitive dependencies it can check if the corresponding direct dependency is a and already present in the context. Partially constructed class loader context is now propagated top-down into aapt.buildActions, so that the method can use existing part of the context to decide where the missing part should be connected. Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: I649aff9e27494306885a4f4fc90226c399636b57 --- java/java.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index 31466b0bd..d6dc148a6 100644 --- a/java/java.go +++ b/java/java.go @@ -1039,7 +1039,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { case libTag, instrumentationForTag: deps.classpath = append(deps.classpath, dep.HeaderJars()...) // sdk lib names from dependencies are re-exported - j.exportedSdkLibs.AddContextMap(dep.ExportedSdkLibs()) + j.exportedSdkLibs.AddContextMap(dep.ExportedSdkLibs(), otherName) deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...) pluginJars, pluginClasses := dep.ExportedPlugins() addPlugins(&deps, pluginJars, pluginClasses...) @@ -1051,7 +1051,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars()...) deps.staticResourceJars = append(deps.staticResourceJars, dep.ResourceJars()...) // sdk lib names from dependencies are re-exported - j.exportedSdkLibs.AddContextMap(dep.ExportedSdkLibs()) + j.exportedSdkLibs.AddContextMap(dep.ExportedSdkLibs(), otherName) deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...) pluginJars, pluginClasses := dep.ExportedPlugins() addPlugins(&deps, pluginJars, pluginClasses...) @@ -2735,7 +2735,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { case libTag, staticLibTag: flags.classpath = append(flags.classpath, dep.HeaderJars()...) // sdk lib names from dependencies are re-exported - j.exportedSdkLibs.AddContextMap(dep.ExportedSdkLibs()) + j.exportedSdkLibs.AddContextMap(dep.ExportedSdkLibs(), otherName) case bootClasspathTag: flags.bootClasspath = append(flags.bootClasspath, dep.HeaderJars()...) } -- cgit v1.2.3