publicclass NullCheckTest { staticclass A { int f;
publicfinalvoid inlined(A a) { // This cast is intended to fail.
B b = ((B) a);
}
}
staticclass B extends A {
}
privatestaticvoid test(A a1, A a2) { // Inlined call must do a null check on a1. // However, the exlipcit NullCheck instruction is eliminated and // the null check is folded into the field load below, so the // exception in the inlined method is thrown before the null check // and the NullPointerException is not thrown.
a1.inlined(a2);
int x = a1.f;
}
publicstaticvoid main(String[] args) { // load classes new B(); try {
test(null, new A());
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.