Java Code Examples for com.sun.jdi.ObjectReference#getValue()
The following examples show how to use
com.sun.jdi.ObjectReference#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AWTGrabHandler.java From netbeans with Apache License 2.0 | 6 votes |
private void ungrabWindowFX(ClassType WindowClass, ObjectReference w, ThreadReference tr) throws Exception { // javafx.stage.Window w // w.focusGrabCounter // while (focusGrabCounter-- > 0) { // w.impl_getPeer().ungrabFocus(); OR: w.impl_peer.ungrabFocus(); // } Field focusGrabCounterField = WindowClass.fieldByName("focusGrabCounter"); if (focusGrabCounterField == null) { logger.info("Unable to release FX X grab, no focusGrabCounter field in "+w); return ; } Value focusGrabCounterValue = w.getValue(focusGrabCounterField); if (!(focusGrabCounterValue instanceof IntegerValue)) { logger.info("Unable to release FX X grab, focusGrabCounter does not have an integer value in "+w); return ; } int focusGrabCounter = ((IntegerValue) focusGrabCounterValue).intValue(); if (logger.isLoggable(Level.FINE)) { logger.fine("Focus grab counter of "+w+" is: "+focusGrabCounter); } while (focusGrabCounter-- > 0) { //Method impl_getPeerMethod = WindowClass.concreteMethodByName("impl_getPeer", ""); Field impl_peerField = WindowClass.fieldByName("impl_peer"); if (impl_peerField == null) { logger.info("Unable to release FX X grab, no impl_peer field in "+w); return ; } ObjectReference impl_peer = (ObjectReference) w.getValue(impl_peerField); if (impl_peer == null) { continue; } InterfaceType TKStageClass = (InterfaceType) w.virtualMachine().classesByName("com.sun.javafx.tk.TKStage").get(0); Method ungrabFocusMethod = TKStageClass.methodsByName("ungrabFocus", "()V").get(0); impl_peer.invokeMethod(tr, ungrabFocusMethod, Collections.<Value>emptyList(), ObjectReference.INVOKE_SINGLE_THREADED); if (logger.isLoggable(Level.FINE)) { logger.fine("FX Window "+w+" was successfully ungrabbed."); } } }
Example 2
Source File: DebugExecutionEnvironment.java From netbeans with Apache License 2.0 | 5 votes |
public boolean sendStopUserCode() throws IllegalStateException { if (closed) { return false; } vm.suspend(); try { ObjectReference myRef = getAgentObjectReference(); OUTER: for (ThreadReference thread : vm.allThreads()) { // could also tag the thread (e.g. using name), to find it easier AGENT: for (StackFrame frame : thread.frames()) { if (REMOTE_AGENT_CLASS.equals(frame.location().declaringType().name())) { String n = frame.location().method().name(); if (AGENT_INVOKE_METHOD.equals(n) || AGENT_VARVALUE_METHOD.equals(n)) { ObjectReference thiz = frame.thisObject(); if (myRef != null && myRef != thiz) { break AGENT; } if (((BooleanValue) thiz.getValue(thiz.referenceType().fieldByName("inClientCode"))).value()) { thiz.setValue(thiz.referenceType().fieldByName("expectingStop"), vm.mirrorOf(true)); ObjectReference stopInstance = (ObjectReference) thiz.getValue(thiz.referenceType().fieldByName("stopException")); vm.resume(); thread.stop(stopInstance); thiz.setValue(thiz.referenceType().fieldByName("expectingStop"), vm.mirrorOf(false)); } return true; } } } } } catch (ClassNotLoadedException | IncompatibleThreadStateException | InvalidTypeException ex) { throw new IllegalStateException(ex); } finally { vm.resume(); } return false; }
Example 3
Source File: JavaLogicalStructure.java From java-debug with Eclipse Public License 1.0 | 5 votes |
private static Value getValueByField(ObjectReference thisObject, String fieldName, ThreadReference thread) { Field targetField = thisObject.referenceType().fieldByName(fieldName); if (targetField == null) { return null; } return thisObject.getValue(targetField); }
Example 4
Source File: LaunchJDIAgent.java From netbeans with Apache License 2.0 | 4 votes |
/** * Interrupts a running remote invoke by manipulating remote variables * and sending a stop via JDI. * * @throws EngineTerminationException the execution engine has terminated * @throws InternalException an internal problem occurred */ @Override public void stop() throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException { synchronized (STOP_LOCK) { if (!userCodeRunning) { return; } vm().suspend(); try { OUTER: for (ThreadReference thread : vm().allThreads()) { // could also tag the thread (e.g. using name), to find it easier for (StackFrame frame : thread.frames()) { if (REMOTE_AGENT.equals(frame.location().declaringType().name()) && ( "invoke".equals(frame.location().method().name()) || "varValue".equals(frame.location().method().name()))) { ObjectReference thiz = frame.thisObject(); com.sun.jdi.Field inClientCode = thiz.referenceType().fieldByName("inClientCode"); com.sun.jdi.Field expectingStop = thiz.referenceType().fieldByName("expectingStop"); com.sun.jdi.Field stopException = thiz.referenceType().fieldByName("stopException"); if (((BooleanValue) thiz.getValue(inClientCode)).value()) { thiz.setValue(expectingStop, vm().mirrorOf(true)); ObjectReference stopInstance = (ObjectReference) thiz.getValue(stopException); vm().resume(); debug("Attempting to stop the client code...\n"); thread.stop(stopInstance); thiz.setValue(expectingStop, vm().mirrorOf(false)); } break OUTER; } } } } catch (ClassNotLoadedException | IncompatibleThreadStateException | InvalidTypeException ex) { throw new ExecutionControl.InternalException("Exception on remote stop: " + ex); } finally { vm().resume(); } } }
Example 5
Source File: JdiDefaultExecutionControl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Interrupts a running remote invoke by manipulating remote variables * and sending a stop via JDI. * * @throws EngineTerminationException the execution engine has terminated * @throws InternalException an internal problem occurred */ @Override public void stop() throws EngineTerminationException, InternalException { synchronized (STOP_LOCK) { if (!userCodeRunning) { return; } vm().suspend(); try { OUTER: for (ThreadReference thread : vm().allThreads()) { // could also tag the thread (e.g. using name), to find it easier for (StackFrame frame : thread.frames()) { if (remoteAgent.equals(frame.location().declaringType().name()) && ( "invoke".equals(frame.location().method().name()) || "varValue".equals(frame.location().method().name()))) { ObjectReference thiz = frame.thisObject(); Field inClientCode = thiz.referenceType().fieldByName("inClientCode"); Field expectingStop = thiz.referenceType().fieldByName("expectingStop"); Field stopException = thiz.referenceType().fieldByName("stopException"); if (((BooleanValue) thiz.getValue(inClientCode)).value()) { thiz.setValue(expectingStop, vm().mirrorOf(true)); ObjectReference stopInstance = (ObjectReference) thiz.getValue(stopException); vm().resume(); debug("Attempting to stop the client code...\n"); thread.stop(stopInstance); thiz.setValue(expectingStop, vm().mirrorOf(false)); } break OUTER; } } } } catch (ClassNotLoadedException | IncompatibleThreadStateException | InvalidTypeException ex) { throw new InternalException("Exception on remote stop: " + ex); } finally { vm().resume(); } } }