publicclass Main { publicstaticvoid main(String[] args) {
System.loadLibrary(args[0]);
// Jit compile HashMap.hash method, so that instrumentation stubs // will deoptimize it.
ensureJitCompiled(HashMap.class, "hash");
Main key = new Main();
Integer value = new Integer(10);
HashMap<Main, Integer> map = new HashMap<>();
map.put(key, value);
Integer res = map.get(key); if (!value.equals(res)) { thrownew Error("Expected 10, got " + res);
}
}
publicint hashCode() { // The call stack at this point is: // Main.main // HashMap.put // HashMap.hash // Main.hashCode // // The opcode at HashMap.hash is invoke-virtual-quick which the // instrumentation code did not expect and used to fetch the wrong // method index for it.
deoptimizeAll(); return42;
}
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.