Java 类com.sun.jdi.event.EventQueue 实例源码

项目:jdivisitor    文件:EventThread.java   
/**
 * Run the event handling thread.
 * 
 * As long as the thread remains connected to the VM, events are removed
 * from the queue and dispatched.
 */
@Override
public void run() {
    EventQueue queue = vm.eventQueue();

    while (connected) {
        try {
            EventSet eventSet = queue.remove();

            EventIterator eventIterator = eventSet.eventIterator();
            while (eventIterator.hasNext()) {
                handleEvent(eventIterator.nextEvent());
            }
            eventSet.resume();
        } catch (InterruptedException ie) {
            vm.dispose();
            break;
        } catch (VMDisconnectedException vmde) {
            handleDisconnectedException();
            break;
        }
    }
}
项目:gravel    文件:VMRemoteTarget.java   
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();
    }
}
项目:JavaTracer    文件:EventThread.java   
/***
* A VMDisconnectedException has happened while dealing with
* another event. We need to flush the event queue, dealing only
* with exit events (VMDeath, VMDisconnect) so that we terminate
* correctly.
*/
   synchronized void handleDisconnectedException() {
       EventQueue queue = vm.eventQueue();
       while (connected) {
           try {
               EventSet eventSet = queue.remove();
               EventIterator iter = eventSet.eventIterator();
               while (iter.hasNext()) {
                   Event event = iter.nextEvent();
                   if (event instanceof VMDeathEvent) {
                       vmDeathManager.vmDeathEvent((VMDeathEvent)event,enableProfiling);
                   } else if (event instanceof VMDisconnectEvent) {
                       connected=disconnect.vmDisconnectEvent((VMDisconnectEvent)event);
                   }
               }
               eventSet.resume(); // Resume the VM

           } catch (InterruptedException exc) {
               exc.printStackTrace();
           }
       }
   }
项目:OpenJSharp    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:jdk8u-jdk    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:openjdk-jdk10    文件:TargetVM.java   
void notifyDequeueEventSet() {
    int maxQueueSize = 0;
    synchronized(eventQueues) {
        Iterator<EventQueue> iter = eventQueues.iterator();
        while (iter.hasNext()) {
            EventQueueImpl queue = (EventQueueImpl)iter.next();
            maxQueueSize = Math.max(maxQueueSize, queue.size());
        }
    }
    controlEventFlow(maxQueueSize);
}
项目:openjdk-jdk10    文件:TargetVM.java   
private void queueEventSet(EventSet eventSet) {
    int maxQueueSize = 0;

    synchronized(eventQueues) {
        Iterator<EventQueue> iter = eventQueues.iterator();
        while (iter.hasNext()) {
            EventQueueImpl queue = (EventQueueImpl)iter.next();
            queue.enqueue(eventSet);
            maxQueueSize = Math.max(maxQueueSize, queue.size());
        }
    }

    controlEventFlow(maxQueueSize);
}
项目:openjdk-jdk10    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:acdebugger    文件:PermissionDebugger.java   
private void loop(BreakpointRequest br, Field contextField) throws Exception {
  int lineNumber = br.location().lineNumber();

  br.setSuspendPolicy(BreakpointRequest.SUSPEND_EVENT_THREAD);
  br.enable();
  EventQueue evtQueue = vm.eventQueue();
  boolean run = true;
  while (run) {
    EventSet evtSet = evtQueue.remove();
    EventIterator evtIter = evtSet.eventIterator();
    while (evtIter.hasNext()) {
      try {
        Event evt = evtIter.next();
        EventRequest evtReq = evt.request();
        if (evtReq instanceof BreakpointRequest
            && ((BreakpointRequest) evtReq).location().lineNumber() == lineNumber) {
          new BreakpointProcessor(missingPerms)
              .processBreakpoint(contextField, (BreakpointEvent) evt);

          // TODO: 12/20/17 Remove when full loop processing is restored
          // run = false;
          System.out.println(missingPerms);
          missingPerms.clear();
        }
      } finally {
        evtSet.resume();
      }
    }
  }

  //    System.out.println(missingPerms);
  //    printPerms(missingPerms);
}
项目:openjdk9    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:jdk8u_jdk    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:lookaside_java-1.8.0-openjdk    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:intellij-ce-playground    文件:VirtualMachineProxyImpl.java   
public EventQueue eventQueue() {
  return myVirtualMachine.eventQueue();
}
项目:che    文件:EventsCollector.java   
EventsCollector(EventQueue queue, EventsHandler handler) {
  this.queue = queue;
  this.handler = handler;

  thread = new Thread(this);
  running = true;
  thread.start();
}
项目:form-follows-function    文件:F3EventQueue.java   
public F3EventQueue(F3VirtualMachine f3vm, EventQueue underlying) {
    super(f3vm, underlying);

    eventsToBePassed.add(F3ClassPrepareEvent.class);
    eventsToBePassed.add(F3VMDeathEvent.class);
    eventsToBePassed.add(F3VMDisconnectEvent.class);
    eventsToBePassed.add(F3VMStartEvent.class);
}
项目:form-follows-function    文件:VirtualMachineTest.java   
@Test
public void testEventQueueNotNull() {
    EventQueue evtQ = getVM().eventQueue();
    if (evtQ == null) {
        Assert.fail("EventQueue is null!");
    }
}
项目:infobip-open-jdk-8    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:jdk8u-dev-jdk    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:jdk7-jdk    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:openjdk-source-code-learn    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:jdivisitor    文件:EventThread.java   
/**
 * A {@link VMDisconnectedException} has happened while dealing with another
 * event. We need to flush the event queue, dealing only with exit events (
 * {@link VMDeatEvent} and {@link VMDisconnectEvent}) so that we terminate
 * correctly.
 */
private void handleDisconnectedException() {
    EventQueue queue = vm.eventQueue();

    while (connected) {
        try {
            EventSet eventSet = queue.remove();

            EventIterator eventIterator = eventSet.eventIterator();
            while (eventIterator.hasNext()) {
                Event event = eventIterator.nextEvent();

                if (event instanceof VMDeathEvent) {
                    handleEvent(event);
                } else if (event instanceof VMDisconnectEvent) {
                    handleEvent(event);
                    connected = false;
                }
            }
            eventSet.resume();
        } catch (InterruptedException ie) {
            vm.dispose();
            break;
        } catch (VMDisconnectedException vmde) {
            break;
        }
    }
}
项目:OLD-OpenJDK8    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:openjdk-jdk7u-jdk    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:openjdk-icedtea7    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    /*
     * No VM validation here. We allow access to the event queue
     * after disconnection, so that there is access to the terminating
     * events.
     */
    return eventQueue;
}
项目:JavaTracer    文件:EventThread.java   
/**
* Run the event handling thread.
* As long as we are connected, get event sets off
* the queue and dispatch the events within them.
*/

   public void run() {
       EventQueue queue = vm.eventQueue();

       while (connected && !forceExit) {
           try {

                EventSet eventSet = queue.remove();
                EventIterator it = eventSet.eventIterator();
                while (it.hasNext())
                 handleEvent(it.nextEvent());
                eventSet.resume();

           } catch (InterruptedException exc) {
              exc.printStackTrace();
           } catch (VMDisconnectedException discExc) {
            discExc.printStackTrace();
               handleDisconnectedException();
               break;
           }
       }

       if (forceExit){
        vm.exit(-1);
        if (!enableProfiling)
            writer.close();
        tracer.finishedTrace();
       }
   }
项目:MaxSim    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    throwNotReadOnlyException("VirtualMachine.eventQueue()");
    return null;
}
项目:java-debug    文件:EventHub.java   
/**
 * Starts retrieving events from the event queue of the specified virtual machine.
 *
 * @param vm
 *            the target virtual machine.
 */
@Override
public void start(VirtualMachine vm) {
    if (isClosed) {
        throw new IllegalStateException("This event hub is already closed.");
    }

    workingThread = new Thread(() -> {
        EventQueue queue = vm.eventQueue();
        while (true) {
            try {
                if (Thread.interrupted()) {
                    subject.onComplete();
                    return;
                }

                EventSet set = queue.remove();

                boolean shouldResume = true;
                for (Event event : set) {
                    try {
                        logger.fine("\nJDI Event: " + event + "\n");
                    } catch (VMDisconnectedException e) {
                        // do nothing
                    }
                    DebugEvent dbgEvent = new DebugEvent();
                    dbgEvent.event = event;
                    dbgEvent.eventSet = set;
                    subject.onNext(dbgEvent);
                    shouldResume &= dbgEvent.shouldResume;
                }

                if (shouldResume) {
                    set.resume();
                }
            } catch (InterruptedException e) {
                isClosed = true;
                subject.onComplete();
                return;
            } catch (VMDisconnectedException e) {
                isClosed = true;
                subject.onError(e);
                return;
            }
        }
    }, "Event Hub");

    workingThread.start();
}
项目:openjdk9    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    throwNotReadOnlyException("VirtualMachine.eventQueue()");
    return null;
}
项目:lookaside_java-1.8.0-openjdk    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    throwNotReadOnlyException("VirtualMachine.eventQueue()");
    return null;
}
项目:lookaside_java-1.8.0-openjdk    文件:FieldMonitor.java   
public static void main(String[] args)
    throws IOException, InterruptedException {

  //VirtualMachine vm = launchTarget(sb.toString());
  VirtualMachine vm = launchTarget(CLASS_NAME);

  System.out.println("Vm launched");

  // process events
  EventQueue eventQueue = vm.eventQueue();
  // resume the vm

  Process process = vm.process();


  // Copy target's output and error to our output and error.
  Thread outThread = new StreamRedirectThread("out reader", process.getInputStream());
  Thread errThread = new StreamRedirectThread("error reader", process.getErrorStream());

  errThread.start();
  outThread.start();

  boolean connected = true;
  int watched = 0;
  while (connected) {
    EventSet eventSet = eventQueue.remove();
    for (Event event : eventSet) {
      System.out.println("FieldMonitor-main receives: "+event);
      if (event instanceof VMStartEvent) {
        addClassWatch(vm);
      } else if (event instanceof VMDeathEvent
          || event instanceof VMDisconnectEvent) {
        // exit
        connected = false;
      } else if (event instanceof ClassPrepareEvent) {
        // watch field on loaded class
        System.out.println("ClassPrepareEvent");
        ClassPrepareEvent classPrepEvent = (ClassPrepareEvent) event;
        ReferenceType refType = classPrepEvent
            .referenceType();
        addFieldWatch(vm, refType);
      } else if (event instanceof ModificationWatchpointEvent) {
        watched++;
        System.out.println("sleep for 500 ms");
        Thread.sleep(500);

        ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent) event;
        System.out.println("old="
            + modEvent.valueCurrent());
        System.out.println("new=" + modEvent.valueToBe());
      }
    }
    System.out.println("resume...");
    eventSet.resume();
  }
  // Shutdown begins when event thread terminates
  try {
      errThread.join(); // Make sure output is forwarded
      outThread.join();
  } catch (InterruptedException exc) {
      // we don't interrupt
  }

  if (watched != 11) { // init + 10 modifications in TestPostFieldModification class
      throw new Error("Expected to receive 11 times ModificationWatchpointEvent, but got "+watched);
  }
}
项目:form-follows-function    文件:F3Wrapper.java   
public static F3EventQueue wrap(F3VirtualMachine f3vm, EventQueue evtQueue) {
    return (evtQueue == null)? null : new F3EventQueue(f3vm, evtQueue);
}
项目:form-follows-function    文件:F3EventQueue.java   
@Override
protected EventQueue underlying() {
    return (EventQueue) super.underlying();
}
项目:infobip-open-jdk-8    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    throwNotReadOnlyException("VirtualMachine.eventQueue()");
    return null;
}
项目:infobip-open-jdk-8    文件:FieldMonitor.java   
public static void main(String[] args)
    throws IOException, InterruptedException {

  //VirtualMachine vm = launchTarget(sb.toString());
  VirtualMachine vm = launchTarget(CLASS_NAME);

  System.out.println("Vm launched");

  // process events
  EventQueue eventQueue = vm.eventQueue();
  // resume the vm

  Process process = vm.process();


  // Copy target's output and error to our output and error.
  Thread outThread = new StreamRedirectThread("out reader", process.getInputStream());
  Thread errThread = new StreamRedirectThread("error reader", process.getErrorStream());

  errThread.start();
  outThread.start();

  boolean connected = true;
  int watched = 0;
  while (connected) {
    EventSet eventSet = eventQueue.remove();
    for (Event event : eventSet) {
      System.out.println("FieldMonitor-main receives: "+event);
      if (event instanceof VMStartEvent) {
        addClassWatch(vm);
      } else if (event instanceof VMDeathEvent
          || event instanceof VMDisconnectEvent) {
        // exit
        connected = false;
      } else if (event instanceof ClassPrepareEvent) {
        // watch field on loaded class
        System.out.println("ClassPrepareEvent");
        ClassPrepareEvent classPrepEvent = (ClassPrepareEvent) event;
        ReferenceType refType = classPrepEvent
            .referenceType();
        addFieldWatch(vm, refType);
      } else if (event instanceof ModificationWatchpointEvent) {
        watched++;
        System.out.println("sleep for 500 ms");
        Thread.sleep(500);

        ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent) event;
        System.out.println("old="
            + modEvent.valueCurrent());
        System.out.println("new=" + modEvent.valueToBe());
      }
    }
    System.out.println("resume...");
    eventSet.resume();
  }
  // Shutdown begins when event thread terminates
  try {
      errThread.join(); // Make sure output is forwarded
      outThread.join();
  } catch (InterruptedException exc) {
      // we don't interrupt
  }

  if (watched != 11) { // init + 10 modifications in TestPostFieldModification class
      throw new Error("Expected to receive 11 times ModificationWatchpointEvent, but got "+watched);
  }
}
项目:openjdk-source-code-learn    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    throwNotReadOnlyException("VirtualMachine.eventQueue()");
    return null;
}
项目:OLD-OpenJDK8    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    throwNotReadOnlyException("VirtualMachine.eventQueue()");
    return null;
}
项目:tools-idea    文件:VirtualMachineProxyImpl.java   
public EventQueue eventQueue() {
  return myVirtualMachine.eventQueue();
}
项目:openjdk-icedtea7    文件:VirtualMachineImpl.java   
public EventQueue eventQueue() {
    throwNotReadOnlyException("VirtualMachine.eventQueue()");
    return null;
}
项目:gravel    文件:VMTargetStarter.java   
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();
    }
}
项目:form-follows-function    文件:Debugger.java   
/**
 * Returns the event queue of the target VM.
 */
public EventQueue eventQueue() {
    return vm().eventQueue();
}