Java 类com.sun.jdi.VirtualMachine 实例源码

项目:incubator-netbeans    文件:AWTGrabHandler.java   
public boolean solveGrabbing(VirtualMachine vm) {
    if (vm == null) return true;
    if (Boolean.FALSE.equals(doGrabCheck)) {
        return true;
    }
    if (GraphicsEnvironment.isHeadless()) {
        doGrabCheck = Boolean.FALSE;
        return true;
    }
    // Check if AWT-EventQueue thread is suspended and a window holds a grab
    List<ThreadReference> allThreads = VirtualMachineWrapper.allThreads0(vm);
    for (ThreadReference t : allThreads) {
        if (!t.isSuspended()) continue;
        boolean success = solveGrabbing(t);
        if (!success) {
            return false;
        }
    }
    return true;
}
项目:incubator-netbeans    文件:AWTGrabHandler.java   
private boolean ungrabWindowAWT(ThreadReference tr, ObjectReference grabbedWindow) {
    // Call XBaseWindow.ungrabInput()
    try {
        VirtualMachine vm = MirrorWrapper.virtualMachine(grabbedWindow);
        List<ReferenceType> xbaseWindowClassesByName = VirtualMachineWrapper.classesByName(vm, "sun.awt.X11.XBaseWindow");
        if (xbaseWindowClassesByName.isEmpty()) {
            logger.info("Unable to release X grab, no XBaseWindow class in target VM "+VirtualMachineWrapper.description(vm));
            return false;
        }
        ClassType XBaseWindowClass = (ClassType) xbaseWindowClassesByName.get(0);
        Method ungrabInput = XBaseWindowClass.concreteMethodByName("ungrabInput", "()V");
        if (ungrabInput == null) {
            logger.info("Unable to release X grab, method ungrabInput not found in target VM "+VirtualMachineWrapper.description(vm));
            return false;
        }
        XBaseWindowClass.invokeMethod(tr, ungrabInput, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
    } catch (VMDisconnectedExceptionWrapper vmdex) {
        return true; // Disconnected, all is good.
    } catch (Exception ex) {
        logger.log(Level.INFO, "Unable to release X grab.", ex);
        return false;
    }
    return true;
}
项目:openjdk-jdk10    文件:VirtualMachineImpl.java   
public long[] instanceCounts(List<? extends ReferenceType> classes) {
    if (!canGetInstanceInfo()) {
        throw new UnsupportedOperationException(
            "target does not support getting instances");
    }
    long[] retValue ;
    ReferenceTypeImpl[] rtArray = new ReferenceTypeImpl[classes.size()];
    int ii = 0;
    for (ReferenceType rti: classes) {
        validateMirror(rti);
        rtArray[ii++] = (ReferenceTypeImpl)rti;
    }
    try {
        retValue = JDWP.VirtualMachine.InstanceCounts.
                            process(vm, rtArray).counts;
    } catch (JDWPException exc) {
        throw exc.toJDIException();
    }

    return retValue;
}
项目:openjdk-jdk10    文件:MethodImpl.java   
static MethodImpl createMethodImpl(VirtualMachine vm,
                                   ReferenceTypeImpl declaringType,
                                   long ref,
                                   String name,
                                   String signature,
                                   String genericSignature,
                                   int modifiers) {
    if ((modifiers & (VMModifiers.NATIVE | VMModifiers.ABSTRACT)) != 0) {
        return new NonConcreteMethodImpl(vm, declaringType, ref,
                                         name, signature,
                                         genericSignature,
                                         modifiers);
    } else {
        return new ConcreteMethodImpl(vm, declaringType, ref,
                                      name, signature,
                                      genericSignature,
                                      modifiers);
    }
}
项目:incubator-netbeans    文件:RemoteServices.java   
private static ObjectReference getQuantumTookitClassLoader(VirtualMachine vm) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper {
    ClassType classQuantumToolkit = getClass(vm, "com.sun.javafx.tk.quantum.QuantumToolkit");
    if (classQuantumToolkit == null) {
        return null;
    }
    ClassLoaderReference cl = ReferenceTypeWrapper.classLoader(classQuantumToolkit);
    return cl;
}
项目:incubator-netbeans    文件:RemoteServices.java   
static ArrayType getArrayClass(VirtualMachine vm, String name) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper {
    List<ReferenceType> classList = VirtualMachineWrapper.classesByName(vm, name);
    ReferenceType clazz = null;
    for (ReferenceType c : classList) {
        if (ReferenceTypeWrapper.classLoader(c) == null) {
            clazz = c;
            break;
        }
    }
    return (ArrayType) clazz;
}
项目:openjdk-jdk10    文件:TypeComponentImpl.java   
TypeComponentImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,
                  long ref, String name, String signature,
                  String genericSignature, int modifiers) {
    // The generic signature is set when this is created.
    super(vm);
    this.declaringType = declaringType;
    this.ref = ref;
    this.name = name;
    this.signature = signature;
    if (genericSignature != null && genericSignature.length() != 0) {
        this.genericSignature = genericSignature;
    } else {
        this.genericSignature = null;
    }
    this.modifiers = modifiers;
}
项目:incubator-netbeans    文件:VariableMirrorTranslator.java   
private static ReferenceType getOrLoadClass(VirtualMachine vm, String name) {
    List<ReferenceType> types = vm.classesByName(name);
    if (types.size() > 0) {
        if (types.size() == 1) {
            return types.get(0);
        }
        try {
            ReferenceType preferedType = JPDAUtils.getPreferredReferenceType(types, null);
            if (preferedType != null) {
                return preferedType;
            }
        } catch (VMDisconnectedExceptionWrapper ex) {
            throw ex.getCause();
        }
        // No preferred, just take the first one:
        return types.get(0);
    }
    // DO NOT TRY TO LOAD CLASSES AT ALL! See http://www.netbeans.org/issues/show_bug.cgi?id=168949
    return null;
}
项目:incubator-netbeans    文件:StartActionProvider.java   
private Operator createOperator (
    VirtualMachine virtualMachine,
    final Object startLock
) {
    return new Operator (
        virtualMachine,
        debuggerImpl,
        new Executor () {
            @Override
            public boolean exec(Event event) {
                synchronized(startLock) {
                    startLock.notify();
                }
                return false;
            }

            @Override
            public void removed(EventRequest eventRequest) {}

        },
        new Runnable () {
            @Override
            public void run () {
                debuggerImpl.finish();
            }
        },
        debuggerImpl.accessLock
    );
}
项目:java-debug    文件:NumericFormatterTest.java   
@Test
public void testToString() throws Exception {
    Value i = this.getLocalValue("i");
    assertEquals("NumericFormatter should be able to format int correctly.", "111", formatter.toString(i, new HashMap<>()));


    VirtualMachine vm = getVM();

    assertEquals("NumericFormatter should be able to format double correctly.", "111.000000",
        formatter.toString(vm.mirrorOf(111.0), new HashMap<>()));
    assertEquals("NumericFormatter should be able to format float correctly.", "111.000000",
        formatter.toString(vm.mirrorOf(111.0f), new HashMap<>()));

    Map<String, Object> options = formatter.getDefaultOptions();
    options.put(NUMERIC_PRECISION_OPTION, 1);
    assertEquals("NumericFormatter should be able to format double correctly.", "111.0",
        formatter.toString(vm.mirrorOf(111.0), options));
    assertEquals("NumericFormatter should be able to format float correctly.", "111.0",
        formatter.toString(vm.mirrorOf(111.0f), options));

    options.put(NUMERIC_PRECISION_OPTION, -1);
    assertEquals("NumericFormatter should be able to format double correctly.", "111.000000",
        formatter.toString(vm.mirrorOf(111.0), options));
}
项目:incubator-netbeans    文件:RemoteServices.java   
private static ClassType getClass(VirtualMachine vm, String name) throws InternalExceptionWrapper,
                                                                         ObjectCollectedExceptionWrapper,
                                                                         VMDisconnectedExceptionWrapper {
    List<ReferenceType> classList = VirtualMachineWrapper.classesByName(vm, name);
    ReferenceType clazz = null;
    for (ReferenceType c : classList) {
        if (ReferenceTypeWrapper.classLoader(c) == null) {
            clazz = c;
            break;
        }
    }
    if (clazz == null && classList.size() > 0) {
        clazz = classList.get(0);
    }
    return (ClassType) clazz;
}
项目:openjdk-jdk10    文件:VirtualMachineManagerImpl.java   
public synchronized VirtualMachine createVirtualMachine(
                                    Connection connection,
                                    Process process) throws IOException {

    if (!connection.isOpen()) {
        throw new IllegalStateException("connection is not open");
    }

    VirtualMachine vm;
    try {
        vm = new VirtualMachineImpl(this, connection, process,
                                               ++vmSequenceNumber);
    } catch (VMDisconnectedException e) {
        throw new IOException(e.getMessage());
    }
    targets.add(vm);
    return vm;
}
项目:OpenJSharp    文件:RawCommandLineLauncher.java   
public VirtualMachine
    launch(Map<String,? extends Connector.Argument> arguments)
    throws IOException, IllegalConnectorArgumentsException,
           VMStartException
{
    String command = argument(ARG_COMMAND, arguments).value();
    String address = argument(ARG_ADDRESS, arguments).value();

    String quote = argument(ARG_QUOTE, arguments).value();

    if (quote.length() > 1) {
        throw new IllegalConnectorArgumentsException("Invalid length",
                                                     ARG_QUOTE);
    }

    TransportService.ListenKey listener = transportService.startListening(address);

    try {
        return launch(tokenizeCommand(command, quote.charAt(0)),
                      address, listener, transportService);
    } finally {
        transportService.stopListening(listener);
    }
}
项目:MaxSim    文件:SACoreAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String javaExec, String corefile)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByCoreMethod = vmImplClass.getMethod(
                             "createVirtualMachineForCorefile",
                              new Class[] {
                                  VirtualMachineManager.class,
                                  String.class, String.class,
                                  Integer.TYPE
                              });
    return (VirtualMachine) connectByCoreMethod.invoke(null,
                              new Object[] {
                                  Bootstrap.virtualMachineManager(),
                                  javaExec,
                                  corefile,
                                  new Integer(0)
                              });
}
项目:incubator-netbeans    文件:AWTGrabHandler.java   
private boolean ungrabWindowFX(ThreadReference tr) {
    // javafx.stage.Window.impl_getWindows() - Iterator<Window>
    // while (iterator.hasNext()) {
    //     Window w = iterator.next();
    //     ungrabWindowFX(w);
    // }
    try {
        VirtualMachine vm = MirrorWrapper.virtualMachine(tr);
        List<ReferenceType> windowClassesByName = VirtualMachineWrapper.classesByName(vm, "javafx.stage.Window");
        if (windowClassesByName.isEmpty()) {
            logger.info("Unable to release FX X grab, no javafx.stage.Window class in target VM "+VirtualMachineWrapper.description(vm));
            return true; // We do not know whether there was any grab
        }
        ClassType WindowClass = (ClassType) windowClassesByName.get(0);
        Method getWindowsMethod = WindowClass.concreteMethodByName("impl_getWindows", "()Ljava/util/Iterator;");
        if (getWindowsMethod == null) {
            logger.info("Unable to release FX X grab, no impl_getWindows() method in "+WindowClass);
            return true; // We do not know whether there was any grab
        }
        ObjectReference windowsIterator = (ObjectReference) WindowClass.invokeMethod(tr, getWindowsMethod, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
        if (windowsIterator == null) {
            return true; // We do not know whether there was any grab
        }
        InterfaceType IteratorClass = (InterfaceType) VirtualMachineWrapper.classesByName(vm, Iterator.class.getName()).get(0);
        Method hasNext = IteratorClass.methodsByName("hasNext", "()Z").get(0);
        Method next = IteratorClass.methodsByName("next", "()Ljava/lang/Object;").get(0);
        while (hasNext(hasNext, tr, windowsIterator)) {
            ObjectReference w = next(next, tr, windowsIterator);
            ungrabWindowFX(WindowClass, w, tr);
        }
    } catch (VMDisconnectedExceptionWrapper vmdex) {
        return true; // Disconnected, all is good.
    } catch (Exception ex) {
        logger.log(Level.INFO, "Unable to release FX X grab (if any).", ex);
        return true; // We do not know whether there was any grab
    }
    return true;
}
项目:incubator-netbeans    文件:RemoteFXScreenshot.java   
private static void pauseMedia(ThreadReference tr, VirtualMachine vm) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException {
    final ClassType audioClipClass = getClass(vm, tr, "com.sun.media.jfxmedia.AudioClip");
    final ClassType mediaManagerClass = getClass(vm, tr, "com.sun.media.jfxmedia.MediaManager");
    final InterfaceType mediaPlayerClass = getInterface(vm, tr, "com.sun.media.jfxmedia.MediaPlayer");
    final ClassType playerStateEnum = getClass(vm, tr, "com.sun.media.jfxmedia.events.PlayerStateEvent$PlayerState");

    if (audioClipClass != null) {
        Method stopAllClips = audioClipClass.concreteMethodByName("stopAllClips", "()V");
        audioClipClass.invokeMethod(tr, stopAllClips, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
    }

    if (mediaManagerClass != null && mediaPlayerClass != null && playerStateEnum != null) {
        Method getAllPlayers = mediaManagerClass.concreteMethodByName("getAllMediaPlayers", "()Ljava/util/List;");

        ObjectReference plList = (ObjectReference)mediaManagerClass.invokeMethod(tr, getAllPlayers, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);

        if (plList != null) {
            ClassType listType = (ClassType)plList.referenceType();
            Method iterator = listType.concreteMethodByName("iterator", "()Ljava/util/Iterator;");
            ObjectReference plIter = (ObjectReference)plList.invokeMethod(tr, iterator, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);

            ClassType iterType = (ClassType)plIter.referenceType();
            Method hasNext = iterType.concreteMethodByName("hasNext", "()Z");
            Method next = iterType.concreteMethodByName("next", "()Ljava/lang/Object;");


            Field playingState = playerStateEnum.fieldByName("PLAYING");

            Method getState = mediaPlayerClass.methodsByName("getState", "()Lcom/sun/media/jfxmedia/events/PlayerStateEvent$PlayerState;").get(0);
            Method pausePlayer = mediaPlayerClass.methodsByName("pause", "()V").get(0);
            boolean hasNextFlag = false;
            do {
                BooleanValue v = (BooleanValue)plIter.invokeMethod(tr, hasNext, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
                hasNextFlag = v.booleanValue();
                if (hasNextFlag) {
                    ObjectReference player = (ObjectReference)plIter.invokeMethod(tr, next, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
                    ObjectReference curState = (ObjectReference)player.invokeMethod(tr, getState, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
                    if (playingState.equals(curState)) {
                        player.invokeMethod(tr, pausePlayer, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
                        pausedPlayers.add(player);
                    }
                }
            } while (hasNextFlag);
        }
    }
}
项目:incubator-netbeans    文件:RemoteFXScreenshot.java   
private static void resumeMedia(ThreadReference tr, VirtualMachine vm) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException {
    if (!pausedPlayers.isEmpty()) {
        final InterfaceType mediaPlayerClass = getInterface(vm, tr, "com.sun.media.jfxmedia.MediaPlayer");
        List<Method> play = mediaPlayerClass.methodsByName("play", "()V");
        if (play.isEmpty()) {
            return;
        }
        Method p = play.iterator().next();
        for(ObjectReference pR : pausedPlayers) {
            pR.invokeMethod(tr, p, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
        }
    }
}
项目:openjdk-jdk10    文件:FieldMonitor.java   
private static void addClassWatch(VirtualMachine vm) {
  EventRequestManager erm = vm.eventRequestManager();
  ClassPrepareRequest classPrepareRequest = erm
      .createClassPrepareRequest();
  classPrepareRequest.addClassFilter(CLASS_NAME);
  classPrepareRequest.setEnabled(true);
}
项目:openjdk-jdk10    文件:VirtualMachineImpl.java   
public StringReference mirrorOf(String value) {
    validateVM();
    try {
        return JDWP.VirtualMachine.CreateString.
            process(vm, value).stringObject;
    } catch (JDWPException exc) {
        throw exc.toJDIException();
    }
}
项目:incubator-netbeans    文件:RemoteServices.java   
static ClassType getClass(VirtualMachine vm, String name) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper {
    List<ReferenceType> classList = VirtualMachineWrapper.classesByName(vm, name);
    ReferenceType clazz = null;
    for (ReferenceType c : classList) {
        if (ReferenceTypeWrapper.classLoader(c) == null) {
            clazz = c;
            break;
        }
    }
    if (clazz == null && classList.size() > 0) {
        clazz = classList.get(0);
    }
    return (ClassType) clazz;
}
项目:incubator-netbeans    文件:RemoteServices.java   
private static ArrayReference createTargetBytes(VirtualMachine vm, byte[] bytes,
                                                ByteValue[] mirrorBytesCache) throws InvalidTypeException,
                                                                                     ClassNotLoadedException,
                                                                                     InternalExceptionWrapper,
                                                                                     VMDisconnectedExceptionWrapper,
                                                                                     ObjectCollectedExceptionWrapper,
                                                                                     UnsupportedOperationExceptionWrapper {
    ArrayType bytesArrayClass = getArrayClass(vm, "byte[]");
    ArrayReference array = null;
    boolean disabledCollection = false;
    while (!disabledCollection) {
        array = ArrayTypeWrapper.newInstance(bytesArrayClass, bytes.length);
        try {
            ObjectReferenceWrapper.disableCollection(array);
            disabledCollection = true;
        } catch (ObjectCollectedExceptionWrapper ocex) {
            // Collected too soon, try again...
        }
    }
    List<Value> values = new ArrayList<Value>(bytes.length);
    for (int i = 0; i < bytes.length; i++) {
        byte b = bytes[i];
        ByteValue mb = mirrorBytesCache[128 + b];
        if (mb == null) {
            mb = VirtualMachineWrapper.mirrorOf(vm, b);
            mirrorBytesCache[128 + b] = mb;
        }
        values.add(mb);
    }
    ArrayReferenceWrapper.setValues(array, values);
    return array;
}
项目:incubator-netbeans    文件:VisualDebuggerListener.java   
/**
 * JavaFX runtime is boobietrapped with various checks for {@linkplain com.sun.javafx.runtime.SystemProperties#isDebug() }
 * which lead to spurious NPEs. Need to make it happy and force the runtime into debug mode
 */
private static void setFxDebug(VirtualMachine vm, ThreadReference tr) {
    ClassType sysPropClass = getClass(vm, tr, "com.sun.javafx.runtime.SystemProperties");
    try {
        Field debugFld = ReferenceTypeWrapper.fieldByName(sysPropClass, "isDebug"); // NOI18N
        sysPropClass.setValue(debugFld, VirtualMachineWrapper.mirrorOf(vm, true));
    } catch (VMDisconnectedExceptionWrapper vmdex) {
    } catch (InternalExceptionWrapper iex) {
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }
}
项目:incubator-netbeans    文件:VisualDebuggerListener.java   
private static ClassType getClass(VirtualMachine vm, ThreadReference tr, String name) {
    ReferenceType t = getType(vm, tr, name);
    if (t instanceof ClassType) {
        return (ClassType)t;
    }
    logger.log(Level.WARNING, "{0} is not a class but {1}", new Object[]{name, t}); // NOI18N
    return null;
}
项目:incubator-netbeans    文件:AttachingDICookie.java   
/**
 * Creates a new instance of VirtualMachine for this DebuggerInfo Cookie.
 *
 * @return a new instance of VirtualMachine for this DebuggerInfo Cookie
 * @throws java.io.IOException when unable to attach.
 * @throws IllegalConnectorArgumentsException when some connector argument is invalid.
 */
@Override
public VirtualMachine getVirtualMachine () throws IOException,
IllegalConnectorArgumentsException {
    try {
        return attachingConnector.attach (args);
    } catch (IOException ioex) {
        String msg = "Attaching Connector = "+attachingConnector+", arguments = "+args; // NOI18N
        logger.log(Level.INFO, msg, ioex);
        throw ioex;
    }
}
项目:incubator-netbeans    文件:ShellLaunchManager.java   
private void waitVirtualMachine(JPDADebugger debugger, Session session) throws DebuggerStartException {
    LOG.log(Level.FINE, "Waiting for debugger to create VM for project {0} in thread {1}", new Object[] { project, Thread.currentThread() });
    debugger.waitRunning();
    VirtualMachine vm = ((JPDADebuggerImpl)debugger).getVirtualMachine();
    LOG.log(Level.FINE, "Debugger VirtualMachine created for project {0} in thread {1}", new Object[] { project, Thread.currentThread() });
    synchronized (ShellLaunchManager.this) {
        // add first, so if there's a race between agent and us, the agent will also query the debugger. We cannot hold lock over the remote call.
        uninitializedDebuggers.add(this);
    }
}
项目:openjdk-jdk10    文件:AbstractLauncher.java   
protected VirtualMachine launch(String[] commandArray, String address,
                                TransportService.ListenKey listenKey,
                                TransportService ts)
                                throws IOException, VMStartException {
    Helper helper = new Helper(commandArray, address, listenKey, ts);
    helper.launchAndAccept();

    VirtualMachineManager manager =
        Bootstrap.virtualMachineManager();

    return manager.createVirtualMachine(helper.connection(),
                                        helper.process());
}
项目:incubator-netbeans    文件:LaunchJDIAgent.java   
/**
 * Create an instance.
 *
 * @param cmdout the output for commands
 * @param cmdin the input for responses
 */
private LaunchJDIAgent(ObjectOutput cmdout, ObjectInput cmdin,
        VirtualMachine vm, Process process, List<Consumer<String>> deathListeners) {
    this(cmdout, cmdin, vm);
    this.process = process;
    deathListeners.add(s -> disposeVM());
}
项目:incubator-netbeans    文件:JPDADebuggerImpl.java   
@Override
public boolean canBeModified() {
    VirtualMachine vm = getVirtualMachine ();
    if (vm == null) {
        return false;
    }
    synchronized (canBeModifiedLock) {
        if (canBeModified == null) {
            canBeModified = vm.canBeModified();
        }
        return canBeModified.booleanValue();
    }
}
项目:incubator-netbeans    文件:VariableMirrorTranslator.java   
private static ObjectReference getDeclaredOrInheritedField(ClassType clazz, String name, VirtualMachine vm, ThreadReference thread) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ClassNotPreparedExceptionWrapper, ClassNotLoadedException, ObjectCollectedExceptionWrapper, IncompatibleThreadStateException, UnsupportedOperationExceptionWrapper, InvalidTypeException {
    //try {
    //    java.lang.reflect.Field field = clazz.getDeclaredField(name);
    //    return field;
    //} catch (NoSuchFieldException ex) {}
    ClassType classType = (ClassType) getOrLoadClass(vm, "java.lang.Class");
    com.sun.jdi.Method getDeclaredFieldMethod = ClassTypeWrapper.concreteMethodByName(
            classType, "getDeclaredField", "(Ljava/lang/String;)Ljava/lang/reflect/Field;");
    try {
        ObjectReference fieldRef = (ObjectReference)
            ObjectReferenceWrapper.invokeMethod(ReferenceTypeWrapper.classObject(clazz),
                                                thread,
                                                getDeclaredFieldMethod,
                                                Collections.singletonList(vm.mirrorOf(name)),
                                                ClassType.INVOKE_SINGLE_THREADED);
        return fieldRef;
    } catch (InvocationException ex) {
        // Likely NoSuchFieldException, try the super class...
    }
    //Class superClass = clazz.getSuperclass();
    ClassType superClass = ClassTypeWrapper.superclass(clazz);
    if (superClass != null) {
        return getDeclaredOrInheritedField(superClass, name, vm, thread);
    } else {
        return null;
    }
}
项目:incubator-netbeans    文件:ThreadsCache.java   
public ThreadsCache(JPDADebuggerImpl debugger) {
    this.debugger = debugger;
    //groupMap = new HashMap<ThreadGroupReference, List<ThreadGroupReference>>();
    //threadMap = new HashMap<ThreadGroupReference, List<ThreadReference>>();
    allThreads = new ArrayList<ThreadReference>();
    VirtualMachine vm = debugger.getVirtualMachine();
    if (vm != null) {
        setVirtualMachine(vm);
    }
}
项目:openjdk-jdk10    文件:VirtualMachineImpl.java   
public void setDefaultStratum(String stratum) {
    defaultStratum = stratum;
    if (stratum == null) {
        stratum = "";
    }
    try {
        JDWP.VirtualMachine.SetDefaultStratum.process(vm,
                                                      stratum);
    } catch (JDWPException exc) {
        throw exc.toJDIException();
    }
}
项目:openjdk-jdk10    文件:JdiExecutionControl.java   
private static ReferenceType nameToRef(VirtualMachine vm, String name) {
    List<ReferenceType> rtl = vm.classesByName(name);
    if (rtl.size() != 1) {
        return null;
    }
    return rtl.get(0);
}
项目:incubator-netbeans    文件:BreakpointImpl.java   
protected EventRequestManager getEventRequestManager () throws VMDisconnectedExceptionWrapper, InternalExceptionWrapper {
    VirtualMachine vm = getVirtualMachine();
    if (vm == null) {
        // Already disconnected
        throw new VMDisconnectedExceptionWrapper(new VMDisconnectedException());
    }
    return VirtualMachineWrapper.eventRequestManager (vm);
}
项目:openjdk-jdk10    文件:VirtualMachineImpl.java   
private JDWP.VirtualMachine.Capabilities capabilities() {
    if (capabilities == null) {
        try {
            capabilities = JDWP.VirtualMachine
                             .Capabilities.process(vm);
        } catch (JDWPException exc) {
            throw exc.toJDIException();
        }
    }
    return capabilities;
}
项目:openjdk-jdk10    文件:VirtualMachineImpl.java   
public void suspend() {
    validateVM();
    try {
        JDWP.VirtualMachine.Suspend.process(vm);
    } catch (JDWPException exc) {
        throw exc.toJDIException();
    }
    notifySuspend();
}
项目:openjdk-jdk10    文件:VirtualMachineImpl.java   
private JDWP.VirtualMachine.CapabilitiesNew capabilitiesNew() {
    if (capabilitiesNew == null) {
        try {
            capabilitiesNew = JDWP.VirtualMachine
                             .CapabilitiesNew.process(vm);
        } catch (JDWPException exc) {
            throw exc.toJDIException();
        }
    }
    return capabilitiesNew;
}
项目:openjdk-jdk10    文件:VirtualMachineImpl.java   
public void exit(int exitCode) {
    validateVM();
    shutdown = true;
    try {
        JDWP.VirtualMachine.Exit.process(vm, exitCode);
    } catch (JDWPException exc) {
        throw exc.toJDIException();
    }
    target.stopListening();
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
private static ReferenceType getClassType(Tree tree, TypeMirror type, EvaluationContext evaluationContext) {
    String className = ElementUtilities.getBinaryName((TypeElement) ((DeclaredType) type).asElement());
    VirtualMachine vm = evaluationContext.getDebugger().getVirtualMachine();
    if (vm == null) {
        return null;
    }
    ReferenceType clazz = getOrLoadClass(vm, className, evaluationContext);
    if (clazz == null) {
        Assert.error(tree, "unknownType", className);
    }
    return clazz;
}
项目:openjdk-jdk10    文件:EventSetImpl.java   
/**
 * Constructor for special events like VM disconnected
 */
EventSetImpl(VirtualMachine aVm, byte eventCmd) {
    this(aVm, null);
    suspendPolicy = JDWP.SuspendPolicy.NONE;
    switch (eventCmd) {
        case JDWP.EventKind.VM_DISCONNECTED:
            addEvent(new VMDisconnectEventImpl());
            break;

        default:
            throw new InternalException("Bad singleton event code");
    }
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
private Value getEnumConstant(Tree arg0, VariableElement ve, EvaluationContext evaluationContext) {
    String constantName = ve.getSimpleName().toString();
    ReferenceType enumType = getClassType(arg0, ve.asType(), evaluationContext);
    Method valueOfMethod = enumType.methodsByName("valueOf").get(0);
    VirtualMachine vm = evaluationContext.getDebugger().getVirtualMachine();
    if (vm == null) {
        return null;
    }
    StringReference constantNameRef = createStringMirrorWithDisabledCollection(constantName, vm, evaluationContext);
    Value enumValue = invokeMethod(arg0, valueOfMethod, true, (ClassType) enumType, null,
                 Collections.singletonList((Value) constantNameRef), evaluationContext, false);
    return enumValue;
}