publicclass Main { publicstaticvoid main(String[] args) throws Exception {
System.loadLibrary(args[0]);
// Register the dex file so that the runtime can pick up which // dex file to compile for the image.
File file = null; try {
file = createTempFile();
String codePath = DEX_LOCATION + "/846-multidex-data-image.jar";
VMRuntime.registerAppInfo( "test.app",
file.getPath(),
file.getPath(), new String[] {codePath},
VMRuntime.CODE_PATH_TYPE_PRIMARY_APK);
} finally { if (file != null) {
file.delete();
}
}
if (!hasOatFile() || !hasImage()) { // We only generate an app image if there is at least a vdex file and a boot image. return;
}
if (args.length == 2 && "--second-run".equals(args[1])) {
DexFile.OptimizationInfo info = VMRuntime.getBaseApkOptimizationInfo(); if (!info.isOptimized() && !isInImageSpace(Main.class)) { thrownew Error("Expected image to be loaded");
}
}
String filter = getCompilerFilter(Main.class); if ("speed-profile".equals(filter) || "speed".equals(filter)) { // We only generate an app image for filters that don't compile. return;
}
String instructionSet = VMRuntime.getCurrentInstructionSet(); // Wait for the file to be generated.
File image = new File(DEX_LOCATION + "/" + instructionSet + "/846-multidex-data-image.art"); while (!image.exists()) { Thread.yield();
}
// Test that we can load a class from the other dex file. We do this after creating the image to // check that the runtime can deal with a missing dex cache. Class.forName("Foo");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.