staticabstractclass AC implements I { publicvoid m() {}
}
staticclass T extends AC { int i = 0;
static { // Run the test while T is not fully initialized yet. for (int i = 0; i < 20_000; i++) {
test(new T(){});
test(new T(){});
test(new T(){});
}
}
}
staticvoid test(T t) { // Interface I has unique implementor AC. // CHA reports AC::m and the callee is guarded by a type check against its holder (AC).
// No upcasts (to class AC) on t after the call. // Otherwise, field access fires an assert.
t.i = 1;
}
}
staticclass Test2 { interface I { void m(); } interface J extends I { defaultvoid m() {}
}
staticabstractclass AC implements I {
}
staticabstractclass T extends AC { int i = 0;
static { // Run the test while T is not fully initialized yet. for (int i = 0; i < 20_000; i++) {
test(new T1(){});
test(new T2(){});
test(new T3(){});
}
}
}
staticclass T1 extends T implements J {} staticclass T2 extends T implements J {} staticclass T3 extends T implements J {}
staticvoid test(T t) { // Interface I has unique implementor AC. // CHA reports J::m and the callee is guarded by a type check against its holder (J).
// No upcasts (to interface J) on t after the call. // Otherwise, field access fires an assert.
t.i = 1;
}
staticvoid run() { for (int i = 0; i < 20_000; i++) {
test(new T() {});
test(new T() {});
test(new T() {});
}
}
}
staticclass Test4 { interface I { defaultvoid m() {}}
staticclass T { int i = 0;
}
staticclass D extends T implements I {}
staticvoid test(T t) { if (t instanceof I) {
((I)t).m();
// No upcasts (to interface J) on t after the call. // Otherwise, field access fires an assert.
t.i = 1;
} else { thrownew InternalError();
}
}
staticvoid run() { for (int i = 0; i < 20_000; i++) {
test(new D() {});
test(new D() {});
test(new D() {});
}
}
}
publicstaticvoid main(String[] args) { new Test1.T(); // trigger initialization of class T new Test2.T1(); // trigger initialization of class T
Test3.run();
Test4.run();
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-10-01)
¤
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.