Methods Summary |
---|
private static java.lang.String | expandDirectories(java.lang.String dexPath)
String[] parts = dexPath.split(":");
StringBuilder outPath = new StringBuilder(dexPath.length());
// A filename filter accepting *.jar and *.apk
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".jar") || name.endsWith(".apk");
}
};
for (String part: parts) {
File f = new File(part);
if (f.isFile()) {
outPath.append(part);
outPath.append(':");
} else if (f.isDirectory()) {
String[] filenames = f.list(filter);
if (filenames == null) {
System.err.println("I/O error with directory: " + part);
continue;
}
for (String filename: filenames) {
outPath.append(part);
outPath.append(File.separatorChar);
outPath.append(filename);
outPath.append(':");
}
} else {
System.err.println("File not found: " + part);
}
}
return outPath.toString();
|
public static void | main(java.lang.String[] args)The entry point for the child process. args[0] can be a colon-separated
path list, or "-" to read from stdin.
Alternatively, if we're invoked directly from the command line we
just start here (skipping the fork/exec stuff).
if ("-".equals(args[0])) {
BufferedReader in = new BufferedReader(
new InputStreamReader(System.in), 256);
String line;
try {
while ((line = in.readLine()) != null) {
prepFiles(line);
}
} catch (IOException ex) {
throw new RuntimeException ("Error processing stdin");
}
} else {
prepFiles(args[0]);
}
System.out.println(" Prep complete");
|
private static void | prepFiles(java.lang.String dexPath)
System.out.println(" Prepping: " + dexPath);
TouchDexLoader loader
= new TouchDexLoader(expandDirectories(dexPath), null);
try {
/* By looking for a nonexistent class, we'll trick TouchDexLoader
* into trying to load something from every file on dexPath,
* optimizing all of them as a side-effect.
*
* The optimization happens implicitly in the VM the first time
* someone tries to load a class from an unoptimized dex file.
*/
loader.loadClass("com.google.NonexistentClassNeverFound");
throw new RuntimeException("nonexistent class loaded?!");
} catch (ClassNotFoundException cnfe) {
//System.out.println("got expected dnfe");
}
|
public static int | start(java.lang.String dexFiles)Forks a process, makes sure the DEX files are prepared, and returns
when everything is finished.
The filenames must be the same as will be used when the files are
actually opened, because the dalvik-cache filename is based upon
this filename. (The absolute path to the JAR/ZIP/APK should work.)
return trampoline(dexFiles, System.getProperty("java.boot.class.path"));
|
private static native int | trampoline(java.lang.String dexFiles, java.lang.String bcp)This calls fork() and then, in the child, calls cont(dexFiles).
|