// run the test with all possible combinations of setting java.io.tmpdir
runExperiment(null, null);
runExperiment(clientTmpDir, null);
runExperiment(clientTmpDir, targetTmpDir);
runExperiment(null, targetTmpDir);
// Test 1 - list method should list the target VM
System.out.println(" - Test: VirtualMachine.list");
List<VirtualMachineDescriptor> l = VirtualMachine.list(); boolean found = false; for (VirtualMachineDescriptor vmd: l) { if (vmd.id().equals(pid)) {
found = true; break;
}
} if (found) {
System.out.println(" - " + pid + " found.");
} else { thrownew RuntimeException(pid + " not found in VM list");
}
// Test 2 - try to attach and verify connection
System.out.println(" - Attaching to application ...");
VirtualMachine vm = VirtualMachine.attach(pid);
System.out.println(" - Test: system properties in target VM");
Properties props = vm.getSystemProperties();
String value = props.getProperty("attach.test"); if (value == null || !value.equals("true")) { thrownew RuntimeException("attach.test property not set");
}
System.out.println(" - attach.test property set as expected");
}
}
}
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.