// This class is used by the test SharedStrings.java // It should be launched in CDS mode publicclass SharedStringsWb { publicstaticvoid main(String[] args) throws Exception {
WhiteBox wb = WhiteBox.getWhiteBox();
if (!wb.areSharedStringsMapped()) {
System.out.println("Shared strings are not mapped, assuming PASS"); return;
}
// The string below is known to be added to CDS archive
String s = "<init>";
String internedS = s.intern();
// Check that it's a valid string if (s.getClass() != String.class || !(s instanceof String)) { thrownew RuntimeException("Shared string is not a valid String: FAIL");
}
if (wb.isSharedInternedString(internedS)) {
System.out.println("Found shared string, result: PASS");
} else { thrownew RuntimeException("String is not shared, result: FAIL");
}
}
}
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.