// exercise implicit null checking in the compiler for various field types publicclass Test7103261 { static Test7103261 null_value; static Test7103261 nonnull_value = new Test7103261(); static Test7103261 nonnull_value2 = new Test7103261();
long l; int i; float f; double d; byte b; char c; short s; boolean z;
Object o;
publicstaticvoid main(String[] args) {
constantStore();
valueTest(false);
valueTest(true);
} staticvoid constantStore() { for (int field = 0; field < 9; field++) { try {
Test7103261 o = nonnull_value; for (int i = 0; i < 100000; i++) { switch (field) { case0: o.l = 0; break; case1: o.i = 0; break; case2: o.f = 0; break; case3: o.d = 0; break; case4: o.b = 0; break; case5: o.c = 0; break; case6: o.s = 0; break; case7: o.z = false; break; case8: o.o = null; break; default: thrownew InternalError();
} if (i == 90000) { // hide nullness from optimizer
o = null_value;
}
}
} catch (NullPointerException npe) {
}
}
} staticvoid valueTest(boolean store) { for (int field = 0; field < 9; field++) { try {
Test7103261 o = nonnull_value;
Test7103261 o2 = nonnull_value2; for (int i = 0; i < 100000; i++) { switch (field) { case0: o.l = o2.l; break; case1: o.i = o2.i; break; case2: o.f = o2.f; break; case3: o.d = o2.d; break; case4: o.b = o2.b; break; case5: o.c = o2.c; break; case6: o.s = o2.s; break; case7: o.z = o2.z; break; case8: o.o = o2.o; break; default: thrownew InternalError();
} if (i == 90000) { // hide nullness from optimizer if (store)
o = null_value; else
o2 = null_value;
}
}
} catch (NullPointerException npe) {
}
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-10)
¤
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.