void writeUntaggedValueChecked(Value val) throws InvalidTypeException { byte tag = ValueImpl.typeValueKey(val); if (isObjectTag(tag)) { if (val == null) { writeObjectRef(0); } else { if (!(val instanceof ObjectReference)) { throw new InvalidTypeException(); } writeObjectRef(((ObjectReferenceImpl)val).ref()); } } else { switch (tag) { case JDWP.Tag.BYTE: if(!(val instanceof ByteValue)) throw new InvalidTypeException(); writeByte(((PrimitiveValue)val).byteValue()); break; case JDWP.Tag.CHAR: if(!(val instanceof CharValue)) throw new InvalidTypeException(); writeChar(((PrimitiveValue)val).charValue()); break; case JDWP.Tag.FLOAT: if(!(val instanceof FloatValue)) throw new InvalidTypeException(); writeFloat(((PrimitiveValue)val).floatValue()); break; case JDWP.Tag.DOUBLE: if(!(val instanceof DoubleValue)) throw new InvalidTypeException(); writeDouble(((PrimitiveValue)val).doubleValue()); break; case JDWP.Tag.INT: if(!(val instanceof IntegerValue)) throw new InvalidTypeException(); writeInt(((PrimitiveValue)val).intValue()); break; case JDWP.Tag.LONG: if(!(val instanceof LongValue)) throw new InvalidTypeException(); writeLong(((PrimitiveValue)val).longValue()); break; case JDWP.Tag.SHORT: if(!(val instanceof ShortValue)) throw new InvalidTypeException(); writeShort(((PrimitiveValue)val).shortValue()); break; case JDWP.Tag.BOOLEAN: if(!(val instanceof BooleanValue)) throw new InvalidTypeException(); writeBoolean(((PrimitiveValue)val).booleanValue()); break; } } }
@Test public void testValueOf() throws Exception { Map<String, Object> options = formatter.getDefaultOptions(); Value boolVar = getVM().mirrorOf(true); Value newValue = formatter.valueOf("true", boolVar.type(), options); assertTrue("should return boolean type", newValue instanceof BooleanValue); assertTrue("should return boolean type", ((BooleanValue)newValue).value()); assertEquals("Should be able to restore boolean value.", "true", formatter.toString(newValue, options)); newValue = formatter.valueOf("True", boolVar.type(), options); assertTrue("should return boolean type", newValue instanceof BooleanValue); assertTrue("should return boolean type", ((BooleanValue)newValue).value()); newValue = formatter.valueOf("false", boolVar.type(), options); assertTrue("should return boolean type", newValue instanceof BooleanValue); assertFalse("should return boolean 'false'", ((BooleanValue)newValue).value()); newValue = formatter.valueOf("False", boolVar.type(), options); assertTrue("should return boolean type", newValue instanceof BooleanValue); assertFalse("should return boolean 'false'", ((BooleanValue)newValue).value()); newValue = formatter.valueOf("abc", boolVar.type(), options); assertTrue("should return boolean type", newValue instanceof BooleanValue); assertFalse("should return boolean 'false'", ((BooleanValue)newValue).value()); }
public Object evaluate(EvaluationContextImpl context) throws EvaluateException { Object value; while (true) { value = myConditionEvaluator.evaluate(context); if (!(value instanceof BooleanValue)) { throw EvaluateExceptionUtil.BOOLEAN_EXPECTED; } else { if (!((BooleanValue)value).booleanValue()) { break; } } if (body(context)) break; } return value; }
public Object evaluate(EvaluationContextImpl context) throws EvaluateException { Object value = context.getDebugProcess().getVirtualMachineProxy().mirrorOfVoid(); while (true) { if (body(context)) break; value = myConditionEvaluator.evaluate(context); if (!(value instanceof BooleanValue)) { throw EvaluateExceptionUtil.BOOLEAN_EXPECTED; } else { if (!((BooleanValue)value).booleanValue()) { break; } } } return value; }
public Object evaluate(EvaluationContextImpl context) throws EvaluateException { Object value = context.getDebugProcess().getVirtualMachineProxy().mirrorOfVoid(); value = evaluateInitialization(context, value); while (true) { // condition Object codition = evaluateCondition(context); if (codition instanceof Boolean) { if (!(Boolean)codition) break; } else if (codition instanceof BooleanValue) { if (!((BooleanValue)codition).booleanValue()) break; } else { throw EvaluateExceptionUtil.BOOLEAN_EXPECTED; } // body if (body(context)) break; // update value = evaluateUpdate(context, value); } return value; }
public Object evaluate(EvaluationContextImpl context) throws EvaluateException { Object value = myConditionEvaluator.evaluate(context); if(!(value instanceof BooleanValue)) { throw EvaluateExceptionUtil.BOOLEAN_EXPECTED; } else { if(((BooleanValue)value).booleanValue()) { value = myThenEvaluator.evaluate(context); myModifier = myThenEvaluator.getModifier(); } else { if(myElseEvaluator != null) { value = myElseEvaluator.evaluate(context); myModifier = myElseEvaluator.getModifier(); } else { value = context.getDebugProcess().getVirtualMachineProxy().mirrorOfVoid(); myModifier = null; } } } return value; }
public Object evaluate(EvaluationContextImpl context) throws EvaluateException { Object value = myConditionEvaluator.evaluate(context); if(!(value instanceof BooleanValue)) { throw EvaluateExceptionUtil.BOOLEAN_EXPECTED; } else { if(((BooleanValue)value).booleanValue()) { value = myThenEvaluator.evaluate(context); myModifier = myThenEvaluator.getModifier(); } else { if(myElseEvaluator != null) { value = myElseEvaluator.evaluate(context); myModifier = myElseEvaluator.getModifier(); } else { value = context.getDebugProcess().getVirtualMachineProxy().mirrorOf(); myModifier = null; } } } return value; }
@Test public void testEvaluate() throws Throwable { ObjectReference promise = remote.evaluateForked("3+4"); ThreadReference thread = ((ThreadReference) remote.invokeMethod( promise, "thread")); Value result1 = remote.invokeMethod(promise, "result"); Value ex = remote.invokeMethod(promise, "throwable"); printThreadState(); VMTargetStarter.sleep(100); printThreadState(); boolean isFinished = ((BooleanValue) remote.invokeMethod(promise, "isFinished")).booleanValue(); assertTrue(isFinished); ObjectReference result = (ObjectReference) remote.invokeMethod(promise, "result"); IntegerValue intValue = (IntegerValue) remote.invokeMethod(result, "intValue"); assertEquals(7, intValue.intValue()); }
private Data getPrimitiveObject(String name, Value value) { Data object = null; if (value instanceof BooleanValue) object = new SimpleData(name,((BooleanValue) value).booleanValue()); else if (value instanceof ByteValue) object = new SimpleData(name,((ByteValue) value).byteValue()); else if (value instanceof CharValue) object = new SimpleData(name,((CharValue) value).charValue()); else if (value instanceof DoubleValue) object = new SimpleData(name,((DoubleValue) value).doubleValue()); else if (value instanceof FloatValue) object = new SimpleData(name,((FloatValue) value).floatValue()); else if (value instanceof IntegerValue) object = new SimpleData(name,((IntegerValue) value).intValue()); else if (value instanceof LongValue) object = new SimpleData(name,((LongValue) value).longValue()); else if (value instanceof ShortValue) object = new SimpleData(name,((ShortValue)value).shortValue()); return object; }
private static void retrieveScreenshots(JPDAThreadImpl t, final ThreadReference tr, VirtualMachine vm, DebuggerEngine engine, JPDADebuggerImpl d, final List<RemoteScreenshot> screenshots) throws RetrievalException { try { final ClassType windowClass = getClass(vm, tr, "javafx.stage.Window"); Method getWindows = windowClass.concreteMethodByName("impl_getWindows", "()Ljava/util/Iterator;"); Method windowName = windowClass.concreteMethodByName("impl_getMXWindowType", "()Ljava/lang/String;"); ObjectReference iterator = (ObjectReference)windowClass.invokeMethod(tr, getWindows, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED); ClassType iteratorClass = (ClassType)iterator.referenceType(); Method hasNext = iteratorClass.concreteMethodByName("hasNext", "()Z"); Method next = iteratorClass.concreteMethodByName("next", "()Ljava/lang/Object;"); boolean nextFlag = false; do { BooleanValue bv = (BooleanValue)iterator.invokeMethod(tr, hasNext, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED); nextFlag = bv.booleanValue(); if (nextFlag) { ObjectReference window = (ObjectReference)iterator.invokeMethod(tr, next, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED); StringReference name = (StringReference)window.invokeMethod(tr, windowName, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED); SGComponentInfo windowInfo = new SGComponentInfo(t, window); screenshots.add(createRemoteFXScreenshot(engine, vm, tr, name.value(), window, windowInfo)); } } while (nextFlag); } catch (Exception e) { throw new RetrievalException(e.getMessage(), e); } }
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); } } }
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; }
private boolean evaluateCondition(Tree arg0, EvaluationContext evaluationContext, ExpressionTree condition) { Mirror conditionValue = condition.accept(this, evaluationContext); if (conditionValue instanceof ObjectReference) { conditionValue = unboxIfCan(arg0, (ObjectReference) conditionValue, evaluationContext); } if (!(conditionValue instanceof BooleanValue)) { String type = "N/A"; // NOI18N if (conditionValue instanceof Value) { type = ((Value) conditionValue).type().name(); } Assert.error(arg0, "notABoolean", condition.toString(), conditionValue, type); } return ((BooleanValue) conditionValue).value(); }
final boolean checkedBooleanValue() throws InvalidTypeException { /* * Always disallow a conversion to boolean from any other * primitive */ if (this instanceof BooleanValue) { return booleanValue(); } else { throw new InvalidTypeException("Can't convert non-boolean value to boolean"); } }
public boolean equals(Object obj) { if ((obj != null) && (obj instanceof BooleanValue)) { return (value == ((BooleanValue)obj).value()) && super.equals(obj); } else { return false; } }
@Override public Object evaluate(EvaluationContextImpl context) throws EvaluateException { Value condition = (Value)myConditionEvaluator.evaluate(context); if (condition == null || !(condition instanceof BooleanValue)) { throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.condition.expected")); } return ((BooleanValue)condition).booleanValue()? myThenEvaluator.evaluate(context) : myElseEvaluator.evaluate(context); }
public static F3Value wrap(F3VirtualMachine f3vm, Value value) { if (value == null) { return null; } if (value instanceof PrimitiveValue) { if (value instanceof BooleanValue) { return f3vm.booleanValue((BooleanValue)value); } else if (value instanceof CharValue) { return f3vm.charValue((CharValue)value); } else if (value instanceof ByteValue) { return f3vm.byteValue((ByteValue)value); } else if (value instanceof ShortValue) { return f3vm.shortValue((ShortValue)value); } else if (value instanceof IntegerValue) { return f3vm.integerValue((IntegerValue)value); } else if (value instanceof LongValue) { return f3vm.longValue((LongValue)value); } else if (value instanceof FloatValue) { return f3vm.floatValue((FloatValue)value); } else if (value instanceof DoubleValue) { return f3vm.doubleValue((DoubleValue)value); } else { throw new IllegalArgumentException("illegal primitive value : " + value); } } else if (value instanceof VoidValue) { return f3vm.voidValue(); } else if (value instanceof ObjectReference) { return wrap(f3vm, (ObjectReference)value); } else { throw new IllegalArgumentException("illegal value: " + value); } }
/** * Replace a sequence element with another value. * * Object values must be assignment compatible with the element type. * (This implies that the component type must be loaded through the * declaring class's class loader). Primitive values must be * assignment compatible with the component type. * * @param value the new value * @param index the index of the component to set. If this is beyond the * end of the sequence, the new value is appended to the sequence. * * @throws InvalidTypeException if the type of <CODE><I>value</I></CODE> * is not compatible with the declared type of sequence elements. * @throws ClassNotLoadedException if the sequence element type * has not yet been loaded through the appropriate class loader. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link com.sun.jdi.VirtualMachine#canBeModified()}. * @return a new sequence with the specified element replaced/added. */ public F3SequenceReference setValue(int index, Value value) { Types type = getElementType(); switch (type) { case INT: return setIntValue(index, (IntegerValue)value); case FLOAT: return setFloatValue(index, (FloatValue)value); case OBJECT: return setObjectValue(index, (ObjectReference)value); case DOUBLE: return setDoubleValue(index, (DoubleValue)value); case BOOLEAN: return setBooleanValue(index, (BooleanValue)value); case LONG: return setLongValue(index, (LongValue)value); case SHORT: return setShortValue(index, (ShortValue)value); case BYTE: return setByteValue(index, (ByteValue)value); case CHAR: return setCharValue(index, (CharValue)value); case OTHER: return setObjectValue(index, (ObjectReference)value); default: throw new IllegalArgumentException("Invalid sequence element type"); } }
public Object evaluate(EvaluationContextImpl context) throws EvaluateException { Value value = (Value)myOperandEvaluator.evaluate(context); if (value == null) { if (myIsPrimitive) { throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.null", myCastType)); } return null; } VirtualMachineProxyImpl vm = context.getDebugProcess().getVirtualMachineProxy(); if (DebuggerUtilsEx.isInteger(value)) { value = DebuggerUtilsEx.createValue(vm, myCastType, ((PrimitiveValue)value).longValue()); if (value == null) { throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.numeric", myCastType)); } } else if (DebuggerUtilsEx.isNumeric(value)) { value = DebuggerUtilsEx.createValue(vm, myCastType, ((PrimitiveValue)value).doubleValue()); if (value == null) { throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.numeric", myCastType)); } } else if (value instanceof BooleanValue) { value = DebuggerUtilsEx.createValue(vm, myCastType, ((BooleanValue)value).booleanValue()); if (value == null) { throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.boolean", myCastType)); } } else if (value instanceof CharValue) { value = DebuggerUtilsEx.createValue(vm, myCastType, ((CharValue)value).charValue()); if (value == null) { throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.char", myCastType)); } } return value; }
public Object evaluate(EvaluationContextImpl context) throws EvaluateException { Value condition = (Value)myConditionEvaluator.evaluate(context); if (condition == null || !(condition instanceof BooleanValue)) { throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.condition.expected")); } return ((BooleanValue)condition).booleanValue()? myThenEvaluator.evaluate(context) : myElseEvaluator.evaluate(context); }
@Test public void testDNU() throws Throwable { ObjectReference promise = remote.evaluateForked("3 fromage"); ThreadReference thread = ((ThreadReference) remote.invokeMethod( promise, "thread")); remote.invokeMethod(thread, "start"); ObjectReference state = (ObjectReference) remote.invokeMethod(thread, "getState"); StringReference str = (StringReference) remote.invokeMethod(state, "toString"); System.out.println(str.value()); printStack(thread); // assertFalse(thread.isSuspended()); printThreadState(); System.out.println("VMTargetStarter.sleep(1000)"); VMTargetStarter.sleep(1000); printStack(thread); printThreadState(); boolean isFinished = ((BooleanValue) remote.invokeMethod(promise, "isFinished")).booleanValue(); assertFalse(isFinished); printThreadState(); printStack(thread); assertTrue(thread.isAtBreakpoint()); }
/** * 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(); } } }
public static Value unbox(ObjectReference val, PrimitiveType type, ThreadReference thread, EvaluationContext context) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { ReferenceType rt = val.referenceType(); String classType = rt.name(); PrimitiveValue pv; if (classType.equals("java.lang.Boolean")) { pv = invokeUnboxingMethod(val, "booleanValue", thread, context); } else if (classType.equals("java.lang.Byte")) { pv = invokeUnboxingMethod(val, "byteValue", thread, context); } else if (classType.equals("java.lang.Character")) { pv = invokeUnboxingMethod(val, "charValue", thread, context); } else if (classType.equals("java.lang.Short")) { pv = invokeUnboxingMethod(val, "shortValue", thread, context); } else if (classType.equals("java.lang.Integer")) { pv = invokeUnboxingMethod(val, "intValue", thread, context); } else if (classType.equals("java.lang.Long")) { pv = invokeUnboxingMethod(val, "longValue", thread, context); } else if (classType.equals("java.lang.Float")) { pv = invokeUnboxingMethod(val, "floatValue", thread, context); } else if (classType.equals("java.lang.Double")) { pv = invokeUnboxingMethod(val, "doubleValue", thread, context); //throw new RuntimeException("Invalid type while unboxing: " + type.signature()); // never happens } else { return val; } VirtualMachine vm = pv.virtualMachine(); if (type instanceof BooleanType && !(pv instanceof BooleanValue)) { return vm.mirrorOf(pv.booleanValue()); } if (type instanceof ByteType && !(pv instanceof ByteValue)) { return vm.mirrorOf(pv.byteValue()); } if (type instanceof CharType && !(pv instanceof CharValue)) { return vm.mirrorOf(pv.charValue()); } if (type instanceof ShortType && !(pv instanceof ShortValue)) { return vm.mirrorOf(pv.shortValue()); } if (type instanceof IntegerType && !(pv instanceof IntegerValue)) { return vm.mirrorOf(pv.intValue()); } if (type instanceof LongType && !(pv instanceof LongValue)) { return vm.mirrorOf(pv.longValue()); } if (type instanceof FloatType && !(pv instanceof FloatValue)) { return vm.mirrorOf(pv.floatValue()); } if (type instanceof DoubleType && !(pv instanceof DoubleValue)) { return vm.mirrorOf(pv.doubleValue()); } return pv; }
/** * 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(); } } }
public BooleanValue mirrorOf(boolean value) { validateVM(); return new BooleanValueImpl(this,value); }
public F3BooleanValue(F3VirtualMachine f3vm, BooleanValue underlying) { super(f3vm, underlying); }
@Override protected BooleanValue underlying() { return (BooleanValue) super.underlying(); }
private BooleanValue getValueAsBoolean(int index) { Method getAsBooleanMethod = virtualMachine().f3SequenceType().getAsBooleanMethod(); return (BooleanValue) getElement(getAsBooleanMethod, index); }
private F3SequenceReference setBooleanValue(int index, BooleanValue value) { Method setBooleanElementMethod = virtualMachine().f3SequencesType().setBooleanElementMethod(); return setElement(setBooleanElementMethod, index, value); }
protected F3BooleanValue booleanValue(BooleanValue value) { return new F3BooleanValue(this, value); }
@Override public boolean isFinished() throws Throwable { return ((BooleanValue) invokeMethod("isFinished")).booleanValue(); }