62 Map<String, String> map = new HashMap<>();
63 map.put("vm.flavor", vmFlavor());
64 map.put("vm.compMode", vmCompMode());
65 map.put("vm.bits", vmBits());
66 map.put("vm.flightRecorder", vmFlightRecorder());
67 map.put("vm.simpleArch", vmArch());
68 map.put("vm.debug", vmDebug());
69 map.put("vm.jvmci", vmJvmci());
70 map.put("vm.emulatedClient", vmEmulatedClient());
71 map.put("vm.cpu.features", cpuFeatures());
72 map.put("vm.rtm.cpu", vmRTMCPU());
73 map.put("vm.rtm.os", vmRTMOS());
74 map.put("vm.aot", vmAOT());
75 // vm.cds is true if the VM is compiled with cds support.
76 map.put("vm.cds", vmCDS());
77 map.put("vm.cds.custom.loaders", vmCDSForCustomLoaders());
78 map.put("vm.cds.archived.java.heap", vmCDSForArchivedJavaHeap());
79 // vm.graal.enabled is true if Graal is used as JIT
80 map.put("vm.graal.enabled", isGraalEnabled());
81 map.put("docker.support", dockerSupport());
82 vmGC(map); // vm.gc.X = true/false
83
84 VMProps.dump(map);
85 return map;
86 }
87
88 /**
89 * Prints a stack trace before returning null.
90 * Used by the various helper functions which parse information from
91 * VM properties in the case where they don't find an expected property
92 * or a propoerty doesn't conform to an expected format.
93 *
94 * @return null
95 */
96 private String nullWithException(String message) {
97 new Exception(message).printStackTrace();
98 return null;
99 }
100
101 /**
389
390 if (isSupported) {
391 try {
392 isSupported = checkDockerSupport();
393 } catch (Exception e) {
394 isSupported = false;
395 }
396 }
397
398 return (isSupported) ? "true" : "false";
399 }
400
401 private boolean checkDockerSupport() throws IOException, InterruptedException {
402 ProcessBuilder pb = new ProcessBuilder("docker", "ps");
403 Process p = pb.start();
404 p.waitFor(10, TimeUnit.SECONDS);
405
406 return (p.exitValue() == 0);
407 }
408
409
410
411 /**
412 * Dumps the map to the file if the file name is given as the property.
413 * This functionality could be helpful to know context in the real
414 * execution.
415 *
416 * @param map
417 */
418 protected static void dump(Map<String, String> map) {
419 String dumpFileName = System.getProperty("vmprops.dump");
420 if (dumpFileName == null) {
421 return;
422 }
423 List<String> lines = new ArrayList<>();
424 map.forEach((k, v) -> lines.add(k + ":" + v));
425 try {
426 Files.write(Paths.get(dumpFileName), lines, StandardOpenOption.APPEND);
427 } catch (IOException e) {
428 throw new RuntimeException("Failed to dump properties into '"
429 + dumpFileName + "'", e);
|
62 Map<String, String> map = new HashMap<>();
63 map.put("vm.flavor", vmFlavor());
64 map.put("vm.compMode", vmCompMode());
65 map.put("vm.bits", vmBits());
66 map.put("vm.flightRecorder", vmFlightRecorder());
67 map.put("vm.simpleArch", vmArch());
68 map.put("vm.debug", vmDebug());
69 map.put("vm.jvmci", vmJvmci());
70 map.put("vm.emulatedClient", vmEmulatedClient());
71 map.put("vm.cpu.features", cpuFeatures());
72 map.put("vm.rtm.cpu", vmRTMCPU());
73 map.put("vm.rtm.os", vmRTMOS());
74 map.put("vm.aot", vmAOT());
75 // vm.cds is true if the VM is compiled with cds support.
76 map.put("vm.cds", vmCDS());
77 map.put("vm.cds.custom.loaders", vmCDSForCustomLoaders());
78 map.put("vm.cds.archived.java.heap", vmCDSForArchivedJavaHeap());
79 // vm.graal.enabled is true if Graal is used as JIT
80 map.put("vm.graal.enabled", isGraalEnabled());
81 map.put("docker.support", dockerSupport());
82 map.put("vm.musl", isMusl());
83 vmGC(map); // vm.gc.X = true/false
84
85 VMProps.dump(map);
86 return map;
87 }
88
89 /**
90 * Prints a stack trace before returning null.
91 * Used by the various helper functions which parse information from
92 * VM properties in the case where they don't find an expected property
93 * or a propoerty doesn't conform to an expected format.
94 *
95 * @return null
96 */
97 private String nullWithException(String message) {
98 new Exception(message).printStackTrace();
99 return null;
100 }
101
102 /**
390
391 if (isSupported) {
392 try {
393 isSupported = checkDockerSupport();
394 } catch (Exception e) {
395 isSupported = false;
396 }
397 }
398
399 return (isSupported) ? "true" : "false";
400 }
401
402 private boolean checkDockerSupport() throws IOException, InterruptedException {
403 ProcessBuilder pb = new ProcessBuilder("docker", "ps");
404 Process p = pb.start();
405 p.waitFor(10, TimeUnit.SECONDS);
406
407 return (p.exitValue() == 0);
408 }
409
410 private String isMusl(){
411 return (WB.isMusl()) ? "true" : "false";
412 }
413
414 /**
415 * Dumps the map to the file if the file name is given as the property.
416 * This functionality could be helpful to know context in the real
417 * execution.
418 *
419 * @param map
420 */
421 protected static void dump(Map<String, String> map) {
422 String dumpFileName = System.getProperty("vmprops.dump");
423 if (dumpFileName == null) {
424 return;
425 }
426 List<String> lines = new ArrayList<>();
427 map.forEach((k, v) -> lines.add(k + ":" + v));
428 try {
429 Files.write(Paths.get(dumpFileName), lines, StandardOpenOption.APPEND);
430 } catch (IOException e) {
431 throw new RuntimeException("Failed to dump properties into '"
432 + dumpFileName + "'", e);
|