// This class helps testing that we don't mark `InheritsBigInteger` as initialized, // given we do not expect `BigInteger` to be initialized in the boot image. class InheritsBigInteger extends BigInteger {
InheritsBigInteger(String value) { super(value);
}
}
// 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 + "/845-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");
}
}
runClassTests();
// Test that we emit an empty lock word. If we are not, then this synchronized call here would // block on a run with the runtime image. synchronized (myString) {
}
// Create a thread that makes sure `myString` is locked while the main thread is generating // the runtime image.
CyclicBarrier barrier = new CyclicBarrier(2); Thread t = new MyThread(barrier);
t.setDaemon(true);
t.start();
barrier.await();
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 + "/845-data-image.art"); while (!image.exists()) { Thread.yield();
}
}
public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { return m.invoke(obj, args);
}
}
publicstatic Itf itf = new Main(); publicstatic Itf2 itf2 = new Itf2Impl(); publicstatic ClassWithStatics statics = new ClassWithStatics(); publicstatic ClassWithStaticType staticType = new ClassWithStaticType(); publicstatic ClassWithDefaultConflict defaultConflict = new ClassWithDefaultConflict();
publicstaticvoid runClassTests() { // Test Class.getName, app images expect all strings to have hash codes.
assertEquals("Main", Main.class.getName());
// Basic tests for invokes with a copied method.
assertEquals(3, new Main().someMethod());
assertEquals(42, new Main().someDefaultMethod());
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.