Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 89dad336 authored by Dimitry Ivanov's avatar Dimitry Ivanov
Browse files

Create linker namespace for the system server classloader

Bug: http://b/27702070
Change-Id: I12c9448e877202937cf558de75042bcb46f6a933
(cherry picked from commit eb5866d4)
parent b1ef62bb
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -475,7 +475,9 @@ public class ZygoteInit {
        } else {
            ClassLoader cl = null;
            if (systemServerClasspath != null) {
                cl = new PathClassLoader(systemServerClasspath, ClassLoader.getSystemClassLoader());
                cl = createSystemServerClassLoader(systemServerClasspath,
                                                   parsedArgs.targetSdkVersion);

                Thread.currentThread().setContextClassLoader(cl);
            }

@@ -488,6 +490,23 @@ public class ZygoteInit {
        /* should never reach here */
    }

    /**
     * Creates a PathClassLoader for the system server. It also creates
     * a shared namespace associated with the classloader to let it access
     * platform-private native libraries.
     */
    private static PathClassLoader createSystemServerClassLoader(String systemServerClasspath,
                                                                 int targetSdkVersion) {
      String librarySearchPath = System.getProperty("java.library.path");

      return PathClassLoaderFactory.createClassLoader(systemServerClasspath,
                                                      librarySearchPath,
                                                      null /* libraryPermittedPath */,
                                                      ClassLoader.getSystemClassLoader(),
                                                      targetSdkVersion,
                                                      true /* isNamespaceShared */);
    }

    /**
     * Performs dex-opt on the elements of {@code classPath}, if needed. We
     * choose the instruction set of the current runtime.