本文整理汇总了Java中com.sun.jdi.request.EventRequestManager.createMethodEntryRequest方法的典型用法代码示例。如果您正苦于以下问题:Java EventRequestManager.createMethodEntryRequest方法的具体用法?Java EventRequestManager.createMethodEntryRequest怎么用?Java EventRequestManager.createMethodEntryRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.request.EventRequestManager
的用法示例。
在下文中一共展示了EventRequestManager.createMethodEntryRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stopOnEntry
import com.sun.jdi.request.EventRequestManager; //导入方法依赖的package包/类
/**
* Suspend the main thread when the program enters the main method of the specified main class.
* @param debugSession
* the debug session.
* @param mainClass
* the fully qualified name of the main class.
* @return
* a {@link CompletableFuture} that contains the suspended main thread id.
*/
public static CompletableFuture<Long> stopOnEntry(IDebugSession debugSession, String mainClass) {
CompletableFuture<Long> future = new CompletableFuture<>();
EventRequestManager manager = debugSession.getVM().eventRequestManager();
MethodEntryRequest request = manager.createMethodEntryRequest();
request.addClassFilter(mainClass);
request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
debugSession.getEventHub().events().filter(debugEvent -> {
return debugEvent.event instanceof MethodEntryEvent && request.equals(debugEvent.event.request());
}).subscribe(debugEvent -> {
Method method = ((MethodEntryEvent) debugEvent.event).method();
if (method.isPublic() && method.isStatic() && method.name().equals("main")
&& method.signature().equals("([Ljava/lang/String;)V")) {
deleteEventRequestSafely(debugSession.getVM().eventRequestManager(), request);
debugEvent.shouldResume = false;
ThreadReference bpThread = ((MethodEntryEvent) debugEvent.event).thread();
future.complete(bpThread.uniqueID());
}
});
request.enable();
return future;
}
示例2: perform
import com.sun.jdi.request.EventRequestManager; //导入方法依赖的package包/类
@Override
public void perform(String[] argv, Context ctx) {
EventRequestManager manager = ctx.getVm().eventRequestManager();
MethodEntryRequest mer = manager.createMethodEntryRequest();
mer.setSuspendPolicy(EventRequest.SUSPEND_NONE);
mer.enable();
ctx.register(mer, new EventCallback() {
@Override
public void handleEvent(Event event) {
MethodEntryEvent mee = (MethodEntryEvent) event;
Method method = mee.method();
System.out.println("--" + method.name());
// mee.thread().resume();
}
});
}
示例3: createRequest
import com.sun.jdi.request.EventRequestManager; //导入方法依赖的package包/类
protected void createRequest()
{
final EventRequestManager manager = owner.getEventRequestManager();
if (manager != null)
{
try
{
if (request != null)
{
removeRequest();
}
request = manager.createMethodEntryRequest();
owner.jdiManager().modelFilter().filter(request);
request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
request.enable();
owner.addJDIEventListener(this, request);
}
catch (final RuntimeException e)
{
JiveDebugPlugin.log(e);
}
}
}
示例4: methodEntryRequests
import com.sun.jdi.request.EventRequestManager; //导入方法依赖的package包/类
private static MethodEntryRequest methodEntryRequests(
EventRequestManager manager,
String classpattern) {
MethodEntryRequest mereq = manager.createMethodEntryRequest();
mereq.addClassFilter(classpattern);
mereq.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
return mereq;
}
示例5: setEventRequests
import com.sun.jdi.request.EventRequestManager; //导入方法依赖的package包/类
/**
* Create the desired event requests, and enable
* them so that we will get events.
* @param excludes Class patterns for which we don't want events
* @param watchFields Do we want to watch assignments to fields
*/
void setEventRequests() {
EventRequestManager mgr = vm.eventRequestManager();
ExceptionRequest excReq = mgr.createExceptionRequest(null,true, true);
excReq.setSuspendPolicy(EventRequest.SUSPEND_ALL);
excReq.enable();
MethodEntryRequest menr = mgr.createMethodEntryRequest();
for (int i=0; i<excludes.size(); ++i) {
menr.addClassExclusionFilter(excludes.get(i));
}
menr.setSuspendPolicy(EventRequest.SUSPEND_ALL);
menr.enable();
MethodExitRequest mexr = mgr.createMethodExitRequest();
for (int i=0; i<excludes.size(); ++i) {
mexr.addClassExclusionFilter(excludes.get(i));
}
mexr.setSuspendPolicy(EventRequest.SUSPEND_ALL);
mexr.enable();
ThreadDeathRequest tdr = mgr.createThreadDeathRequest();
tdr.setSuspendPolicy(EventRequest.SUSPEND_ALL);
tdr.enable();
}