Don't attempt to add stub libraries to class loader context.
A Java module may depend on a stub library. In that case an additional dependency on the implementation library is created, and it is used to add the implementation library to class loader context. We should not attempt to add the stubs library as well (previously the attempt to add it happend after the implemention was added to CLC, to the attempt was unsuccessful). Raise an error if someone tries to add the same library with different build/instal paths. Also, rename local variable `implicitSdkLib` to `sdkLib` to better reflect its meaning. Bug: 193425964 Test: $ lunch aosp_cf_x86_64_phone-userdebug && m && launch_cvd $ adb wait-for-device && \ adb root && \ adb logcat | \ grep -E 'ClassLoaderContext [a-z ]+ mismatch' -C1 # empty output, no errors Change-Id: I01c1bdd23f9d118d891d0b806e7e3b4d78896a34
This commit is contained in:
@@ -286,11 +286,19 @@ func (clcMap ClassLoaderContextMap) addContext(ctx android.ModuleInstallPathCont
|
||||
}
|
||||
subcontexts := nestedClcMap[AnySdkVersion]
|
||||
|
||||
// If the library with this name is already present as one of the unconditional top-level
|
||||
// components, do not re-add it.
|
||||
// Check if the library with this name is already present in unconditional top-level CLC.
|
||||
for _, clc := range clcMap[sdkVer] {
|
||||
if clc.Name == lib {
|
||||
if clc.Name != lib {
|
||||
// Ok, a different library.
|
||||
} else if clc.Host == hostPath && clc.Device == devicePath {
|
||||
// Ok, the same library with the same paths. Don't re-add it, but don't raise an error
|
||||
// either, as the same library may be reachable via different transitional dependencies.
|
||||
return nil
|
||||
} else {
|
||||
// Fail, as someone is trying to add the same library with different paths. This likely
|
||||
// indicates an error somewhere else, like trying to add a stub library.
|
||||
return fmt.Errorf("a <uses-library> named %q is already in class loader context,"+
|
||||
"but the library paths are different:\t\n", lib)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user