Skip to content
Permalink
Browse files
HeapMonitorVMEventsTest.java updated to demonstrate deadlock when Get…
…Trace is used from SampledObjectAllocEvent
  • Loading branch information
lmesnik committed Mar 20, 2021
1 parent 238e5e9 commit 2ffa8e290e845fc2a8f3030cb7dbde484697e169
Showing 1 changed file with 23 additions and 3 deletions.
@@ -37,7 +37,19 @@
* @requires !vm.graal.enabled
* @run main/othervm/native -XX:+UnlockDiagnosticVMOptions
* -XX:DisableIntrinsic=_clone
* -agentlib:HeapMonitorTest MyPackage.HeapMonitorVMEventsTest
* -agentlib:HeapMonitorTest MyPackage.HeapMonitorVMEventsTest kernel
*/

/**
* @test
* @summary Verifies that when the VM event is sent, sampled events are also collected.
* @build Frame HeapMonitor
* @compile HeapMonitorVMEventsTest.java
* @requires vm.jvmti
* @requires !vm.graal.enabled
* @run main/othervm/native -XX:+UnlockDiagnosticVMOptions
* -XX:DisableIntrinsic=_clone
* -agentlib:HeapMonitorTest MyPackage.HeapMonitorVMEventsTest virtual
*/

public class HeapMonitorVMEventsTest implements Cloneable {
@@ -94,12 +106,20 @@ private static void compareSampledAndVM() {
checkDifference(onlySampleCount, vmCount);
}

public static void main(String[] args) {
public static void main(String[] args) throws Exception {
if (!HeapMonitor.eventStorageIsEmpty()) {
throw new RuntimeException("Storage is not empty at test start...");
}

HeapMonitor.sampleEverything();
compareSampledAndVM();

if(args[0].equals("virtual")) {
Thread t = Thread.ofVirtual().start(() -> {
compareSampledAndVM();
});
t.join();
} else {
compareSampledAndVM();
}
}
}

0 comments on commit 2ffa8e2

Please sign in to comment.