/** *TheClasstobeinvokedbyjtregpriorTestSuiteexecutionto *collectinformationaboutVM. *DonotuseanyAPIsthatmaynotbeavailableinalltargetVMs. *PropertiessetbythisClasswillbeavailableinthe@requiresexpressions.
*/ publicclass VMProps implements Callable<Map<String, String>> { // value known to jtreg as an indicator of error state privatestaticfinal String ERROR_STATE = "__ERROR__";
privatestaticclass SafeMap { privatefinal Map<String, String> map = new HashMap<>();
publicvoid put(String key, Supplier<String> s) {
String value; try {
value = s.get();
} catch (Throwable t) {
System.err.println("failed to get value for " + key);
t.printStackTrace(System.err);
value = ERROR_STATE + t;
}
map.put(key, value);
}
}
/** *CollectsinformationaboutVMproperties. *Thismethodwillbeinvokedbyjtreg. * *@returnMapofproperty-valuepairs.
*/
@Override public Map<String, String> call() {
SafeMap map = new SafeMap();
map.put("vm.flavor", this::vmFlavor);
map.put("vm.compMode", this::vmCompMode);
map.put("vm.bits", this::vmBits);
map.put("vm.flightRecorder", this::vmFlightRecorder);
map.put("vm.simpleArch", this::vmArch);
map.put("vm.debug", this::vmDebug);
map.put("vm.jvmci", this::vmJvmci);
map.put("vm.emulatedClient", this::vmEmulatedClient); // vm.hasSA is "true" if the VM contains the serviceability agent // and jhsdb.
map.put("vm.hasSA", this::vmHasSA); // vm.hasJFR is "true" if JFR is included in the build of the VM and // so tests can be executed.
map.put("vm.hasJFR", this::vmHasJFR);
map.put("vm.hasDTrace", this::vmHasDTrace);
map.put("vm.jvmti", this::vmHasJVMTI);
map.put("vm.cpu.features", this::cpuFeatures);
map.put("vm.pageSize", this::vmPageSize);
map.put("vm.rtm.cpu", this::vmRTMCPU);
map.put("vm.rtm.compiler", this::vmRTMCompiler); // vm.cds is true if the VM is compiled with cds support.
map.put("vm.cds", this::vmCDS);
map.put("vm.cds.custom.loaders", this::vmCDSForCustomLoaders);
map.put("vm.cds.write.archived.java.heap", this::vmCDSCanWriteArchivedJavaHeap);
map.put("vm.continuations", this::vmContinuations); // vm.graal.enabled is true if Graal is used as JIT
map.put("vm.graal.enabled", this::isGraalEnabled);
map.put("vm.compiler1.enabled", this::isCompiler1Enabled);
map.put("vm.compiler2.enabled", this::isCompiler2Enabled);
map.put("docker.support", this::dockerSupport);
map.put("vm.musl", this::isMusl);
map.put("release.implementor", this::implementor);
map.put("jdk.containerized", this::jdkContainerized);
map.put("vm.flagless", this::isFlagless);
vmGC(map); // vm.gc.X = true/false
vmGCforCDS(map); // may set vm.gc
vmOptFinalFlags(map);
/** *@returnVMtypevalueextractedfromthe"java.vm.name"property.
*/ protected String vmFlavor() { // E.g. "Java HotSpot(TM) 64-Bit Server VM"
String vmName = System.getProperty("java.vm.name"); if (vmName == null) { return errorWithMessage("Can't get 'java.vm.name' property");
}
Pattern startP = Pattern.compile(".* (\\S+) VM");
Matcher m = startP.matcher(vmName); if (m.matches()) { return m.group(1).toLowerCase();
} return errorWithMessage("Can't get VM flavor from 'java.vm.name'");
}
/** *@returnVMcompilationmodeextractedfromthe"java.vm.info"property.
*/ protected String vmCompMode() { // E.g. "mixed mode"
String vmInfo = System.getProperty("java.vm.info"); if (vmInfo == null) { return errorWithMessage("Can't get 'java.vm.info' property");
}
vmInfo = vmInfo.toLowerCase(); if (vmInfo.contains("mixed mode")) { return"Xmixed";
} elseif (vmInfo.contains("compiled mode")) { return"Xcomp";
} elseif (vmInfo.contains("interpreted mode")) { return"Xint";
} else { return errorWithMessage("Can't get compilation mode from 'java.vm.info'");
}
}
/** *@returntrueifVMsupportsJVMCIandfalseotherwise
*/ protected String vmJvmci() { // builds with jvmci have this flag if (WB.getBooleanVMFlag("EnableJVMCI") == null) { return"false";
}
// Not all GCs have full JVMCI support if (!WB.isJVMCISupportedByGC()) { return"false";
}
/** *"jtreg-vmoptions:-Dtest.cds.runtime.options=..."canbeusedtospecify *theGCtypetobeusedwhenrunningwithaCDSarchive.Set"vm.gc"accordingly, *sothatteststhatneedtoexplicitlychoosetheGCtypecanbeexcluded *with"@requiresvm.gc==null". * *@parammap-property-valuepairs
*/ protectedvoid vmGCforCDS(SafeMap map) { if (!GC.isSelectedErgonomically()) { // The GC has been explicitly specified on the command line, so // jtreg will set the "vm.gc" property. Let's not interfere with it. return;
}
/** *Asimplecheckfordockersupport * *@returntrueifdockerissupportedinagivenenvironment
*/ protected String dockerSupport() { boolean isSupported = false; if (Platform.isLinux()) { // currently docker testing is only supported for Linux, // on certain platforms
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.