本文整理汇总了Java中com.sun.jdi.ThreadReference.frames方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadReference.frames方法的具体用法?Java ThreadReference.frames怎么用?Java ThreadReference.frames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.ThreadReference
的用法示例。
在下文中一共展示了ThreadReference.frames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendStopUserCode
import com.sun.jdi.ThreadReference; //导入方法依赖的package包/类
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;
}
示例2: stop
import com.sun.jdi.ThreadReference; //导入方法依赖的package包/类
/**
* 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();
}
}
}
示例3: stop
import com.sun.jdi.ThreadReference; //导入方法依赖的package包/类
/**
* 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();
}
}
}