From 813579d06877fed67c2c62054213d8efcff6d37b Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Wed, 6 Aug 2014 20:04:34 +0100 Subject: Use absolute path when opening dex files. The device always sees absolute paths so this will be no-op but on host this enables testing with relative paths (which is much more convenient). Bug: 16644204 Bug: 16930747 (cherry picked from commit e05ad6f7a1e2e34db62587269a066d479dc8e0ad) Change-Id: I4855c7ffa1935a777e19f0f9842c0bd837818f07 --- dalvik/src/main/java/dalvik/system/DexFile.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'dalvik') diff --git a/dalvik/src/main/java/dalvik/system/DexFile.java b/dalvik/src/main/java/dalvik/system/DexFile.java index 3965b81..7aeba87 100644 --- a/dalvik/src/main/java/dalvik/system/DexFile.java +++ b/dalvik/src/main/java/dalvik/system/DexFile.java @@ -281,6 +281,18 @@ public final class DexFile { } } + + /* + * Open a DEX file. The value returned is a magic VM cookie. On + * failure, an IOException is thrown. + */ + private static long openDexFile(String sourceName, String outputName, int flags) throws IOException { + // Use absolute paths to enable the use of relative paths when testing on host. + return openDexFileNative(new File(sourceName).getAbsolutePath(), + (outputName == null) ? null : new File(outputName).getAbsolutePath(), + flags); + } + private static native void closeDexFile(long cookie); private static native Class defineClassNative(String name, ClassLoader loader, long cookie) throws ClassNotFoundException, NoClassDefFoundError; @@ -289,7 +301,7 @@ public final class DexFile { * Open a DEX file. The value returned is a magic VM cookie. On * failure, an IOException is thrown. */ - private static native long openDexFile(String sourceName, String outputName, int flags); + private static native long openDexFileNative(String sourceName, String outputName, int flags); /** * Returns true if the VM believes that the apk/jar file is out of date -- cgit v1.1