Search in sources :

Example 31 with PathClassLoader

use of dalvik.system.PathClassLoader in project platform_frameworks_base by android.

the class ApplicationLoaders method addPath.

/**
     * Adds a new path the classpath of the given loader.
     * @throws IllegalStateException if the provided class loader is not a {@link PathClassLoader}.
     */
void addPath(ClassLoader classLoader, String dexPath) {
    if (!(classLoader instanceof PathClassLoader)) {
        throw new IllegalStateException("class loader is not a PathClassLoader");
    }
    final PathClassLoader baseDexClassLoader = (PathClassLoader) classLoader;
    baseDexClassLoader.addDexPath(dexPath);
}
Also used : PathClassLoader(dalvik.system.PathClassLoader)

Example 32 with PathClassLoader

use of dalvik.system.PathClassLoader in project android_frameworks_base by ParanoidAndroid.

the class FilterFactory method addFilterLibrary.

/**
     * Adds a new Java library to the list to be scanned for filters.
     * libraryPath must be an absolute path of the jar file.  This needs to be
     * static because only one classloader per process can open a shared native
     * library, which a filter may well have.
     */
public static void addFilterLibrary(String libraryPath) {
    if (mLogVerbose)
        Log.v(TAG, "Adding filter library " + libraryPath);
    synchronized (mClassLoaderGuard) {
        if (mLibraries.contains(libraryPath)) {
            if (mLogVerbose)
                Log.v(TAG, "Library already added");
            return;
        }
        mLibraries.add(libraryPath);
        // Chain another path loader to the current chain
        mCurrentClassLoader = new PathClassLoader(libraryPath, mCurrentClassLoader);
    }
}
Also used : PathClassLoader(dalvik.system.PathClassLoader)

Example 33 with PathClassLoader

use of dalvik.system.PathClassLoader in project android_frameworks_base by ParanoidAndroid.

the class ZygoteConnection method handleChildProc.

/**
     * Handles post-fork setup of child proc, closing sockets as appropriate,
     * reopen stdio as appropriate, and ultimately throwing MethodAndArgsCaller
     * if successful or returning if failed.
     *
     * @param parsedArgs non-null; zygote args
     * @param descriptors null-ok; new file descriptors for stdio if available.
     * @param pipeFd null-ok; pipe for communication back to Zygote.
     * @param newStderr null-ok; stream to use for stderr until stdio
     * is reopened.
     *
     * @throws ZygoteInit.MethodAndArgsCaller on success to
     * trampoline to code that invokes static main.
     */
private void handleChildProc(Arguments parsedArgs, FileDescriptor[] descriptors, FileDescriptor pipeFd, PrintStream newStderr) throws ZygoteInit.MethodAndArgsCaller {
    closeSocket();
    ZygoteInit.closeServerSocket();
    if (descriptors != null) {
        try {
            ZygoteInit.reopenStdio(descriptors[0], descriptors[1], descriptors[2]);
            for (FileDescriptor fd : descriptors) {
                IoUtils.closeQuietly(fd);
            }
            newStderr = System.err;
        } catch (IOException ex) {
            Log.e(TAG, "Error reopening stdio", ex);
        }
    }
    if (parsedArgs.niceName != null) {
        Process.setArgV0(parsedArgs.niceName);
    }
    if (parsedArgs.runtimeInit) {
        if (parsedArgs.invokeWith != null) {
            WrapperInit.execApplication(parsedArgs.invokeWith, parsedArgs.niceName, parsedArgs.targetSdkVersion, pipeFd, parsedArgs.remainingArgs);
        } else {
            RuntimeInit.zygoteInit(parsedArgs.targetSdkVersion, parsedArgs.remainingArgs);
        }
    } else {
        String className;
        try {
            className = parsedArgs.remainingArgs[0];
        } catch (ArrayIndexOutOfBoundsException ex) {
            logAndPrintError(newStderr, "Missing required class name argument", null);
            return;
        }
        String[] mainArgs = new String[parsedArgs.remainingArgs.length - 1];
        System.arraycopy(parsedArgs.remainingArgs, 1, mainArgs, 0, mainArgs.length);
        if (parsedArgs.invokeWith != null) {
            WrapperInit.execStandalone(parsedArgs.invokeWith, parsedArgs.classpath, className, mainArgs);
        } else {
            ClassLoader cloader;
            if (parsedArgs.classpath != null) {
                cloader = new PathClassLoader(parsedArgs.classpath, ClassLoader.getSystemClassLoader());
            } else {
                cloader = ClassLoader.getSystemClassLoader();
            }
            try {
                ZygoteInit.invokeStaticMain(cloader, className, mainArgs);
            } catch (RuntimeException ex) {
                logAndPrintError(newStderr, "Error starting.", ex);
            }
        }
    }
}
Also used : PathClassLoader(dalvik.system.PathClassLoader) PathClassLoader(dalvik.system.PathClassLoader) IOException(java.io.IOException) FileDescriptor(java.io.FileDescriptor)

Example 34 with PathClassLoader

use of dalvik.system.PathClassLoader in project platform_frameworks_base by android.

the class FilterFactory method addFilterLibrary.

/**
     * Adds a new Java library to the list to be scanned for filters.
     * libraryPath must be an absolute path of the jar file.  This needs to be
     * static because only one classloader per process can open a shared native
     * library, which a filter may well have.
     */
public static void addFilterLibrary(String libraryPath) {
    if (mLogVerbose)
        Log.v(TAG, "Adding filter library " + libraryPath);
    synchronized (mClassLoaderGuard) {
        if (mLibraries.contains(libraryPath)) {
            if (mLogVerbose)
                Log.v(TAG, "Library already added");
            return;
        }
        mLibraries.add(libraryPath);
        // Chain another path loader to the current chain
        mCurrentClassLoader = new PathClassLoader(libraryPath, mCurrentClassLoader);
    }
}
Also used : PathClassLoader(dalvik.system.PathClassLoader)

Example 35 with PathClassLoader

use of dalvik.system.PathClassLoader in project robovm by robovm.

the class PathClassLoaderTest method testLibraryPathSearchOrder.

/**
     * Make sure we're searching the application library path first.
     * http://b/issue?id=2933456
     */
public void testLibraryPathSearchOrder() throws IOException {
    File tmp = new File(System.getProperty("java.io.tmpdir"));
    File systemLibPath = new File(tmp, "systemLibPath");
    File applicationLibPath = new File(tmp, "applicationLibPath");
    makeTempFile(systemLibPath, "libduplicated.so");
    File applicationLib = makeTempFile(applicationLibPath, "libduplicated.so");
    System.setProperty("java.library.path", systemLibPath.toString());
    PathClassLoader pathClassLoader = new PathClassLoader(applicationLibPath.toString(), applicationLibPath.toString(), getClass().getClassLoader());
    String path = pathClassLoader.findLibrary("duplicated");
    assertEquals(applicationLib.toString(), path);
}
Also used : PathClassLoader(dalvik.system.PathClassLoader) File(java.io.File)

Aggregations

PathClassLoader (dalvik.system.PathClassLoader)57 File (java.io.File)14 DexClassLoader (dalvik.system.DexClassLoader)8 IOException (java.io.IOException)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 TargetApi (android.annotation.TargetApi)4 Context (android.content.Context)4 RemoteException (android.os.RemoteException)4 Method (java.lang.reflect.Method)3 ZipFile (java.util.zip.ZipFile)3 ActivityManagerInternal (android.app.ActivityManagerInternal)2 INotificationManager (android.app.INotificationManager)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 Intent (android.content.Intent)2 IntentFilter (android.content.IntentFilter)2 Configuration (android.content.res.Configuration)2 Resources (android.content.res.Resources)2 Theme (android.content.res.Resources.Theme)2 CameraAccessException (android.hardware.camera2.CameraAccessException)2 InputManagerInternal (android.hardware.input.InputManagerInternal)2