use of com.sun.jdi.event.EventQueue in project gravel by gravel-st.
the class VMRemoteTarget method eventLoop.
private void eventLoop() throws InterruptedException {
System.out.println("eventLoop started");
EventQueue eventQueue = vm.eventQueue();
boolean isRunning = true;
while (isRunning) {
EventSet eventSet = eventQueue.remove();
boolean mayResume = true;
for (Event event : eventSet) {
System.out.println(event);
if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
isRunning = false;
} else if (event instanceof ExceptionEvent) {
mayResume = false;
}
}
if (mayResume)
eventSet.resume();
}
}
use of com.sun.jdi.event.EventQueue in project gravel by gravel-st.
the class VMTargetStarter method createJVM.
public VMRemoteTarget createJVM() throws IOException, InterruptedException, IncompatibleThreadStateException {
Process process = startSecondJVM(VMLocalTarget.class);
sleep(90);
// connect
VirtualMachine vm = new VMAcquirer().connect(debugPort);
ClassPrepareRequest createClassPrepareRequest = vm.eventRequestManager().createClassPrepareRequest();
createClassPrepareRequest.addClassFilter(VMLocalTarget.class.getName());
createClassPrepareRequest.enable();
vm.resume();
List<ThreadReference> allThreads = vm.allThreads();
for (ThreadReference threadReference : allThreads) {
System.out.println(threadReference + " isSuspended: " + threadReference.isSuspended() + " suspendCount: " + threadReference.suspendCount());
}
// process events
EventQueue eventQueue = vm.eventQueue();
while (true) {
EventSet eventSet = eventQueue.remove();
for (Event event : eventSet) {
if (event instanceof ClassPrepareEvent) {
event.request().disable();
installHaltPoint(vm);
}
if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
return null;
}
if (event instanceof BreakpointEvent) {
event.request().disable();
ThreadReference thread = ((BreakpointEvent) event).thread();
return new VMRemoteTarget(process, vm, thread, debugPort);
}
}
eventSet.resume();
}
}
Aggregations