if (!checkAppImageLoaded("660-clinit")) {
System.out.println("AppImage not loaded.");
} if (!checkAppImageContains(ClInit.class)) {
System.out.println("ClInit class is not in app image!");
}
if (c.a != 101) {
System.out.println("a != 101");
}
try {
ClinitE e = new ClinitE();
} catch (Error err) { }
return;
}
staticvoid expectPreInit(Class<?> klass) { if (checkInitialized(klass) == false) {
System.out.println(klass.getName() + " should be initialized!");
}
}
staticvoid expectNotPreInit(Class<?> klass) { if (checkInitialized(klass) == true) {
System.out.println(klass.getName() + " should not be initialized!");
}
}
class A { publicstaticint a = 2; static {
a = 5; // self-updating, pass
}
}
class B { publicstaticint b; static {
A.a = 10; // write other's static field, fail
b = A.a; // read other's static field, fail
}
}
class C { publicstaticint c; static {
c = A.a; // read other's static field, fail
}
}
class E { publicstaticfinalint e; static {
e = 100;
}
}
class G { static G g; staticint i; static {
g = new Gss(); // fail because recursive dependency
i = A.a; // read other's static field, fail
}
}
// Gs will be successfully initialized as G's status is initializing at that point, which will // later aborted but Gs' transaction is already committed. // Instantiation of Gs will fail because we try to invoke G's <init> // but G's status will be StatusVerified. INVOKE_DIRECT will not initialize class. class Gs extends G {} // fail because super class can't be initialized class Gss extends Gs {}
// pruned because holding reference to non-image class class ObjectRef { staticClass<?> klazz[] = newClass<?>[]{Add.class, Mul.class};
}
// non-image class Add { staticint exec(int a, int b) { return a + b;
}
}
class InImage { staticint exec(int a, int b) { return a + b;
}
}
// test of INVOKE_STATIC instruction class InvokeStatic { staticint a; staticint b; static {
a = InImage.exec(10, 20);
b = InImage.exec(10, 20);
}
}
// non-image class Mul { staticint exec(int a, int b) { return a * b;
}
}
class ClinitE { static { if (Math.sin(3) < 0.5) { // throw anyway, can't initialized thrownew ExceptionInInitializerError("Can't initialize this class!");
}
}
}
// fail because JNI class Print { static {
System.out.println("hello world");
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-29)
¤
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.