publicclass Main { publicstaticvoid main(String[] args) {
System.loadLibrary(args[0]);
// Get all methods. We cannot call getDeclaredMethod("foo") as // that would make "foo" a strong root.
Method[] methods = Main.class.getDeclaredMethods();
// Call getName on the methods, which is implemented by using the dex // cache and calling setResolvedString. for (int i = 0; i < methods.length; i++) {
methods[i].getName();
}
// Compile Main.foo. "foo" needs to be a strong root for JIT compilation. // We stress test this: // - avoid strongly interning "foo" by doing "f" + "oo" // - call GC so that weaks can be collected. // - invoke foo() to make sure "foo" hasn't been collected.
ensureJitCompiled(Main.class, "f" + "oo");
Runtime.getRuntime().gc();
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.