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

Commit eb5866d4 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
parent 5d7d777f
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -458,7 +458,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);
            }

@@ -471,6 +473,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.