Lines Matching full:clc
28 // 1. the concept of class loader context (CLC) and its relation to classpath
29 // 2. how PackageManager constructs CLC from shared libraries and their dependencies
30 // 3. build-time vs. run-time CLC and why this matters for dexpreopt
32 // 5. build system support for CLC
50 // Class loader context (CLC) is a tree-like structure that describes class loader hierarchy. The
51 // build system uses CLC in a more narrow sense: it is a tree of libraries that represents
53 // a CLC are the direct <uses-library> dependencies specified in the manifest (aka. classpath). Each
54 // node of a CLC tree is a <uses-library> which may have its own <uses-library> sub-nodes.
56 // Because <uses-library> dependencies are, in general, a graph and not necessarily a tree, CLC may
57 // contain subtrees for the same library multiple times. In other words, CLC is the dependency graph
63 // D has <uses-library> E; B and E have no <uses-library> dependencies. The CLC is:
73 // CLC defines the lookup order of libraries when resolving Java classes used by the library/app.
80 // In order to load an APK at runtime, PackageManager (in frameworks/base) creates a CLC. It adds
81 // the libraries listed in the <uses-library> tags in the app's manifest as top-level CLC elements.
83 // as tags in the manifest of that library) and adds a nested CLC for each dependency. This process
84 // continues recursively until all leaf nodes of the constructed CLC tree are libraries that have no
94 // In other words, there are two sources of information that allow PackageManager to construct CLC
98 // 3. Build-time and run-time CLC and dexpreopt
101 // CLC is needed not only when loading a library/app, but also when compiling it. Compilation may
108 // Thus, the build-time CLC used by dexpreopt and the run-time CLC used by PackageManager are
113 // run-time CLCs, the dex2oat compiler records build-time CLC in the *.odex files (in the
114 // "classpath" field of the OAT file header). To find the stored CLC, use the following command:
117 // Mismatch between build-time and run-time CLC is reported in logcat during boot (search with
124 // present or absent at build time: if present, it will be added to the CLC, passed to dex2oat and
126 // added to CLC. If there is a mismatch between built-time and run-time status (optional library is
129 // runtime, therefore either including or excluding it may cause CLC mismatch.
150 // Soong computes the libraries that need to be in the manifest as the top-level libraries in CLC.
160 // In order to construct CLC for dexpreopt and manifest_fixer, the build system needs to know all
191 // ClassLoaderContext is a structure that represents CLC.
205 // Nested sub-CLC for dependencies.
237 // ClassLoaderContextMap is a map from SDK version to CLC. There is a special entry with key
238 // AnySdkVersion that stores unconditional CLC that is added regardless of the target SDK version.
240 // Conditional CLC is for compatibility libraries which didn't exist prior to a certain SDK version
243 // CLC if the library/app that uses them has `targetSdkVersion` less than N in the manifest.
245 // Currently only apps (but not libraries) use conditional CLC.
248 // the build system doesn't know whether conditional CLC is needed for a given app or not. So it
249 // generates a build rule that includes conditional CLC for all versions, extracts the target SDK
250 // version from the manifest, and filters the CLCs based on that version. Exact final CLC that is
319 // Check if the library with this name is already present in unconditional top-level CLC.
320 for _, clc := range clcMap[sdkVer] {
321 if clc.Name != lib {
323 } else if clc.Host == hostPath && clc.Device == devicePath {
326 clc.Optional = clc.Optional && optional
349 // are validated later before CLC is used (in validateClassLoaderContext).
371 for _, clc := range clcMap[AnySdkVersion] {
372 if clc.Name == implicitRootLib {
380 for _, clc := range clcMap[sdkVer] {
381 if clc.Name == otherClc.Name {
393 // Returns top-level libraries in the CLC (conditional CLC, i.e. compatibility libraries are not
402 for _, clc := range clcs {
403 if clc.Optional {
404 optional = append(optional, clc.Name)
406 required = append(required, clc.Name)
445 for _, clc := range clcList {
446 resultClc, modifiedClc := clc.excludeLibs(excludedLibs)
506 for _, clc := range clcs {
507 if android.InList(clc.Name, usesLibs) {
509 } else if clc.Name == AndroidTestMock && !android.InList("android.test.runner", usesLibs) {
513 fixedClcs = append(fixedClcs, clc)
534 for _, clc := range clcs {
535 if clc.Host == nil || clc.Device == UnknownInstallLibraryPath {
539 if clc.Host == nil {
540 return false, fmt.Errorf("invalid build path for <uses-library> \"%s\"", clc.Name)
542 return false, fmt.Errorf("invalid install path for <uses-library> \"%s\"", clc.Name)
546 // (this depends on the targetSdkVersion in the manifest), but the CLC is invalid.
550 if valid, err := validateClassLoaderContextRec(sdkVer, clc.Subcontexts); !valid || err != nil {
571 for _, clc := range clcs {
572 subNames, subPaths := ComputeClassLoaderContextDependenciesRec(clc.Subcontexts)
573 names = append(names, clc.Name)
574 paths = append(paths, clc.Host)
581 // Class loader contexts that come from Make via JSON dexpreopt.config. JSON CLC representation is
594 // Convert JSON CLC map to Soong represenation.
614 for _, clc := range jClcs {
616 Name: clc.Name,
617 Optional: clc.Optional,
618 Host: constructPath(ctx, clc.Host),
619 Device: clc.Device,
620 Subcontexts: fromJsonClassLoaderContextRec(ctx, clc.Subcontexts),
626 // Convert Soong CLC map to JSON representation for Make.
642 for i, clc := range clcs {
644 if clc.Host == nil {
645 // Defer build failure to when this CLC is actually used.
646 host = fmt.Sprintf("implementation-jar-for-%s-is-not-available.jar", clc.Name)
648 host = clc.Host.String()
651 Name: clc.Name,
652 Optional: clc.Optional,
654 Device: clc.Device,
655 Subcontexts: toJsonClassLoaderContextRec(clc.Subcontexts),