当前位置: 首页>>代码示例>>Java>>正文


Java ThreadReference.stop方法代码示例

本文整理汇总了Java中com.sun.jdi.ThreadReference.stop方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadReference.stop方法的具体用法?Java ThreadReference.stop怎么用?Java ThreadReference.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jdi.ThreadReference的用法示例。


在下文中一共展示了ThreadReference.stop方法的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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:DebugExecutionEnvironment.java

示例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();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:LaunchJDIAgent.java

示例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();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:49,代码来源:JdiDefaultExecutionControl.java


注:本文中的com.sun.jdi.ThreadReference.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。