// This is a white-box test where we fabricate a native initialization // error by calling JMV#createNative(false), which will tear down // all native structures after they are setup, as if something went wrong // at the last step. publicstaticvoid main(String... args) throws Exception {
JVM jvm = JVM.getJVM(); // Ensure that repeated failures can be handled for (int i = 1; i < 4; i++) {
System.out.println("About to try failed initialization, attempt " + i + " out of 3");
assertFailedInitialization(jvm);
System.out.println("As expected, initialization failed.");
} // Ensure that Flight Recorder can be initialized properly after failures
Configuration defConfig = Configuration.getConfiguration("default");
Recording r = new Recording(defConfig);
r.start();
r.stop();
r.dump(Paths.get("recording.jfr"));
r.close();
}
privatestaticvoid assertFailedInitialization(JVM jvm) throws Exception { try {
jvm.createFailedNativeJFR(); thrownew Exception("Expected failure when creating native JFR");
} catch (IllegalStateException ise) {
String message = ise.getMessage(); if (!message.equals("Unable to start Jfr")) { thrownew Exception("Expected failure on initialization of native JFR");
}
}
}
}
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.