Interface EventRequest
- All Superinterfaces:
Mirror
- All Known Subinterfaces:
AccessWatchpointRequest,BreakpointRequest,ClassPrepareRequest,ClassUnloadRequest,ExceptionRequest,MethodEntryRequest,MethodExitRequest,ModificationWatchpointRequest,MonitorContendedEnteredRequest,MonitorContendedEnterRequest,MonitorWaitedRequest,MonitorWaitRequest,StepRequest,ThreadDeathRequest,ThreadStartRequest,VMDeathRequest,WatchpointRequest
BreakpointRequest and ExceptionRequest.
When an event occurs for which an enabled request is present,
an EventSet will
be placed on the EventQueue.
The collection of existing event requests is
managed by the EventRequestManager.
The number of events generated for an event request can be controlled
through filters. Filters provide additional constraints that an event
must satisfy before it is placed on the event queue. Multiple filters can
be used by making multiple calls to filter addition methods such as
ExceptionRequest.addClassFilter(java.lang.String classPattern).
Filters are added to an event one at a time only while the event is
disabled. Multiple filters are applied with CUT-OFF AND, in the order
it was added to the request. Only events that satisfy all filters are
placed in the event queue.
The set of available filters is dependent on the event request, some examples of filters are:
- Thread filters allow control over the thread for which events are generated.
- Class filters allow control over the class in which the event occurs.
- Instance filters allow control over the instance in which the event occurs.
- Count filters allow control over the number of times an event is reported.
Any method on EventRequest which
takes EventRequest as an parameter may throw
VMDisconnectedException if the target VM is
disconnected and the VMDisconnectEvent has been or is
available to be read from the EventQueue.
Any method on EventRequest which
takes EventRequest as an parameter may throw
VMOutOfMemoryException if the target VM has run out of memory.
- Since:
- 1.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSuspend all threads when the event occursstatic final intSuspend only the thread which generated the event when the event occursstatic final intSuspend no threads when the event occurs -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCountFilter(int count) Limit the requested event to be reported at most once after a given number of occurrences.voiddisable()Same assetEnabled(false).voidenable()Same assetEnabled(true).getProperty(Object key) Returns the value of the property with the specified key.booleanDetermines if this event request is currently enabled.voidputProperty(Object key, Object value) Add an arbitrary key/value "property" to this request.voidsetEnabled(boolean val) Enables or disables this event request.voidsetSuspendPolicy(int policy) Determines the threads to suspend when the requested event occurs in the target VM.intReturns a value which describes the threads to suspend when the requested event occurs in the target VM.Methods declared in interface com.sun.jdi.Mirror
toString, virtualMachine
-
Field Details
-
SUSPEND_NONE
static final int SUSPEND_NONESuspend no threads when the event occurs- See Also:
-
SUSPEND_EVENT_THREAD
static final int SUSPEND_EVENT_THREADSuspend only the thread which generated the event when the event occurs- See Also:
-
SUSPEND_ALL
static final int SUSPEND_ALLSuspend all threads when the event occurs- See Also:
-
-
Method Details
-
isEnabled
boolean isEnabled()Determines if this event request is currently enabled.- Returns:
trueif enabled;falseotherwise.
-
setEnabled
void setEnabled(boolean val) Enables or disables this event request. While this event request is disabled, the event request will be ignored and the target VM will not be stopped if any of its threads reaches the event request. Disabled event requests still exist, and are included in event request lists such asEventRequestManager.breakpointRequests().- Parameters:
val-trueif the event request is to be enabled;falseotherwise.- Throws:
InvalidRequestStateException- if this request has been deleted.IllegalThreadStateException- if this is a StepRequest,valistrue, and the thread named in the request has died or is not yet started.
-
enable
void enable()Same assetEnabled(true).- Throws:
InvalidRequestStateException- if this request has been deleted.IllegalThreadStateException- if this is a StepRequest and the thread named in the request has died or is not yet started.
-
disable
void disable()Same assetEnabled(false).- Throws:
InvalidRequestStateException- if this request has been deleted.
-
addCountFilter
void addCountFilter(int count) Limit the requested event to be reported at most once after a given number of occurrences. The event is not reported the firstcount - 1times this filter is reached. To request a one-off event, call this method with a count of 1.Once the count reaches 0, any subsequent filters in this request are applied. If none of those filters cause the event to be suppressed, the event is reported. Otherwise, the event is not reported. In either case subsequent events are never reported for this request.
- Parameters:
count- the number of occurrences before generating an event.- Throws:
InvalidRequestStateException- if this request is currently enabled or has been deleted. Filters may be added only to disabled requests.IllegalArgumentException- ifcountis less than one.
-
setSuspendPolicy
void setSuspendPolicy(int policy) Determines the threads to suspend when the requested event occurs in the target VM. UseSUSPEND_ALLto suspend all threads in the target VM (the default). UseSUSPEND_EVENT_THREADto suspend only the thread which generated the event. UseSUSPEND_NONEto suspend no threads.Thread suspensions through events have the same functionality as explicitly requested suspensions. See
ThreadReference.suspend()andVirtualMachine.suspend()for details.- Parameters:
policy- the selected suspend policy.- Throws:
InvalidRequestStateException- if this request is currently enabled or has been deleted. Suspend policy may only be set in disabled requests.IllegalArgumentException- if the policy argument contains an illegal value.
-
suspendPolicy
int suspendPolicy()Returns a value which describes the threads to suspend when the requested event occurs in the target VM. The returned value isSUSPEND_ALL,SUSPEND_EVENT_THREAD, orSUSPEND_NONE.- Returns:
- the current suspend mode for this request
-
putProperty
Add an arbitrary key/value "property" to this request. The property can be used by a client of the JDI to associate application information with the request; These client-set properties are not used internally by the JDI.The
get/putPropertymethods provide access to a small per-instance map. This is not to be confused withProperties.If value is null this method will remove the property.
- See Also:
-
getProperty
Returns the value of the property with the specified key. Only properties added withputProperty(java.lang.Object, java.lang.Object)will return a non-null value.- Returns:
- the value of this property or null
- See Also:
-