0N/A/*
2362N/A * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.jdi;
0N/A
0N/Aimport com.sun.jdi.*;
0N/Aimport com.sun.jdi.request.*;
0N/Aimport com.sun.tools.jdi.JDWP;
0N/A
0N/Aimport java.util.*;
0N/A
0N/A/**
0N/A * This interface is used to create and remove Breakpoints, Watchpoints,
0N/A * etc.
0N/A * It include implementations of all the request interfaces..
0N/A */
0N/A// Warnings from List filters and List[] requestLists is hard to fix.
0N/A// Remove SuppressWarning when we fix the warnings from List filters
0N/A// and List[] requestLists. The generic array is not supported.
0N/A@SuppressWarnings("unchecked")
0N/Aclass EventRequestManagerImpl extends MirrorImpl
0N/A implements EventRequestManager
0N/A{
0N/A List[] requestLists;
0N/A private static int methodExitEventCmd = 0;
0N/A
0N/A static int JDWPtoJDISuspendPolicy(byte jdwpPolicy) {
0N/A switch(jdwpPolicy) {
0N/A case JDWP.SuspendPolicy.ALL:
0N/A return EventRequest.SUSPEND_ALL;
0N/A case JDWP.SuspendPolicy.EVENT_THREAD:
0N/A return EventRequest.SUSPEND_EVENT_THREAD;
0N/A case JDWP.SuspendPolicy.NONE:
0N/A return EventRequest.SUSPEND_NONE;
0N/A default:
0N/A throw new IllegalArgumentException("Illegal policy constant: " + jdwpPolicy);
0N/A }
0N/A }
0N/A
0N/A static byte JDItoJDWPSuspendPolicy(int jdiPolicy) {
0N/A switch(jdiPolicy) {
0N/A case EventRequest.SUSPEND_ALL:
0N/A return JDWP.SuspendPolicy.ALL;
0N/A case EventRequest.SUSPEND_EVENT_THREAD:
0N/A return JDWP.SuspendPolicy.EVENT_THREAD;
0N/A case EventRequest.SUSPEND_NONE:
0N/A return JDWP.SuspendPolicy.NONE;
0N/A default:
0N/A throw new IllegalArgumentException("Illegal policy constant: " + jdiPolicy);
0N/A }
0N/A }
0N/A
0N/A /*
0N/A * Override superclass back to default equality
0N/A */
0N/A public boolean equals(Object obj) {
0N/A return this == obj;
0N/A }
0N/A
0N/A public int hashCode() {
0N/A return System.identityHashCode(this);
0N/A }
0N/A
0N/A abstract class EventRequestImpl extends MirrorImpl implements EventRequest {
0N/A int id;
0N/A
0N/A /*
0N/A * This list is not protected by a synchronized wrapper. All
0N/A * access/modification should be protected by synchronizing on
0N/A * the enclosing instance of EventRequestImpl.
0N/A */
0N/A List filters = new ArrayList();
0N/A
0N/A boolean isEnabled = false;
0N/A boolean deleted = false;
0N/A byte suspendPolicy = JDWP.SuspendPolicy.ALL;
0N/A private Map<Object, Object> clientProperties = null;
0N/A
0N/A EventRequestImpl() {
0N/A super(EventRequestManagerImpl.this.vm);
0N/A }
0N/A
0N/A
0N/A /*
0N/A * Override superclass back to default equality
0N/A */
0N/A public boolean equals(Object obj) {
0N/A return this == obj;
0N/A }
0N/A
0N/A public int hashCode() {
0N/A return System.identityHashCode(this);
0N/A }
0N/A
0N/A abstract int eventCmd();
0N/A
0N/A InvalidRequestStateException invalidState() {
0N/A return new InvalidRequestStateException(toString());
0N/A }
0N/A
0N/A String state() {
0N/A return deleted? " (deleted)" :
0N/A (isEnabled()? " (enabled)" : " (disabled)");
0N/A }
0N/A
0N/A /**
0N/A * @return all the event request of this kind
0N/A */
0N/A List requestList() {
0N/A return EventRequestManagerImpl.this.requestList(eventCmd());
0N/A }
0N/A
0N/A /**
0N/A * delete the event request
0N/A */
0N/A void delete() {
0N/A if (!deleted) {
0N/A requestList().remove(this);
0N/A disable(); /* must do BEFORE delete */
0N/A deleted = true;
0N/A }
0N/A }
0N/A
0N/A public boolean isEnabled() {
0N/A return isEnabled;
0N/A }
0N/A
0N/A public void enable() {
0N/A setEnabled(true);
0N/A }
0N/A
0N/A public void disable() {
0N/A setEnabled(false);
0N/A }
0N/A
0N/A public synchronized void setEnabled(boolean val) {
0N/A if (deleted) {
0N/A throw invalidState();
0N/A } else {
0N/A if (val != isEnabled) {
0N/A if (isEnabled) {
0N/A clear();
0N/A } else {
0N/A set();
0N/A }
0N/A }
0N/A }
0N/A }
0N/A
0N/A public synchronized void addCountFilter(int count) {
0N/A if (isEnabled() || deleted) {
0N/A throw invalidState();
0N/A }
0N/A if (count < 1) {
0N/A throw new IllegalArgumentException("count is less than one");
0N/A }
0N/A filters.add(JDWP.EventRequest.Set.Modifier.Count.create(count));
0N/A }
0N/A
0N/A public void setSuspendPolicy(int policy) {
0N/A if (isEnabled() || deleted) {
0N/A throw invalidState();
0N/A }
0N/A suspendPolicy = JDItoJDWPSuspendPolicy(policy);
0N/A }
0N/A
0N/A public int suspendPolicy() {
0N/A return JDWPtoJDISuspendPolicy(suspendPolicy);
0N/A }
0N/A
0N/A /**
0N/A * set (enable) the event request
0N/A */
0N/A synchronized void set() {
0N/A JDWP.EventRequest.Set.Modifier[] mods =
0N/A (JDWP.EventRequest.Set.Modifier[])
0N/A filters.toArray(
0N/A new JDWP.EventRequest.Set.Modifier[filters.size()]);
0N/A try {
0N/A id = JDWP.EventRequest.Set.process(vm, (byte)eventCmd(),
0N/A suspendPolicy, mods).requestID;
0N/A } catch (JDWPException exc) {
0N/A throw exc.toJDIException();
0N/A }
0N/A isEnabled = true;
0N/A }
0N/A
0N/A synchronized void clear() {
0N/A try {
0N/A JDWP.EventRequest.Clear.process(vm, (byte)eventCmd(), id);
0N/A } catch (JDWPException exc) {
0N/A throw exc.toJDIException();
0N/A }
0N/A isEnabled = false;
0N/A }
0N/A
0N/A /**
0N/A * @return a small Map
0N/A * @see #putProperty
0N/A * @see #getProperty
0N/A */
0N/A private Map<Object, Object> getProperties() {
0N/A if (clientProperties == null) {
0N/A clientProperties = new HashMap<Object, Object>(2);
0N/A }
0N/A return clientProperties;
0N/A }
0N/A
0N/A /**
0N/A * Returns the value of the property with the specified key. Only
0N/A * properties added with <code>putProperty</code> will return
0N/A * a non-null value.
0N/A *
0N/A * @return the value of this property or null
0N/A * @see #putProperty
0N/A */
0N/A public final Object getProperty(Object key) {
0N/A if (clientProperties == null) {
0N/A return null;
0N/A } else {
0N/A return getProperties().get(key);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Add an arbitrary key/value "property" to this component.
0N/A *
0N/A * @see #getProperty
0N/A */
0N/A public final void putProperty(Object key, Object value) {
0N/A if (value != null) {
0N/A getProperties().put(key, value);
0N/A } else {
0N/A getProperties().remove(key);
0N/A }
0N/A }
0N/A }
0N/A
0N/A abstract class ThreadVisibleEventRequestImpl extends EventRequestImpl {
0N/A public synchronized void addThreadFilter(ThreadReference thread) {
0N/A validateMirror(thread);
0N/A if (isEnabled() || deleted) {
0N/A throw invalidState();
0N/A }
0N/A filters.add(JDWP.EventRequest.Set.Modifier.ThreadOnly
0N/A .create((ThreadReferenceImpl)thread));
0N/A }
0N/A }
0N/A
0N/A abstract class ClassVisibleEventRequestImpl
0N/A extends ThreadVisibleEventRequestImpl {
0N/A public synchronized void addClassFilter(ReferenceType clazz) {
0N/A validateMirror(clazz);
0N/A if (isEnabled() || deleted) {
0N/A throw invalidState();
0N/A }
0N/A filters.add(JDWP.EventRequest.Set.Modifier.ClassOnly
0N/A .create((ReferenceTypeImpl)clazz));
0N/A }
0N/A
0N/A public synchronized void addClassFilter(String classPattern) {
0N/A if (isEnabled() || deleted) {
0N/A throw invalidState();
0N/A }
0N/A if (classPattern == null) {
0N/A throw new NullPointerException();
0N/A }
0N/A filters.add(JDWP.EventRequest.Set.Modifier.ClassMatch
0N/A .create(classPattern));
0N/A }
0N/A
0N/A public synchronized void addClassExclusionFilter(String classPattern) {
0N/A if (isEnabled() || deleted) {
0N/A throw invalidState();
0N/A }
0N/A if (classPattern == null) {
0N/A throw new NullPointerException();
0N/A }
0N/A filters.add(JDWP.EventRequest.Set.Modifier.ClassExclude
0N/A .create(classPattern));
0N/A }
0N/A
0N/A public synchronized void addInstanceFilter(ObjectReference instance) {
0N/A validateMirror(instance);
0N/A if (isEnabled() || deleted) {
0N/A throw invalidState();
0N/A }
0N/A if (!vm.canUseInstanceFilters()) {
0N/A throw new UnsupportedOperationException(
0N/A "target does not support instance filters");
0N/A }
0N/A filters.add(JDWP.EventRequest.Set.Modifier.InstanceOnly
0N/A .create((ObjectReferenceImpl)instance));
0N/A }
0N/A }
0N/A
0N/A class BreakpointRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements BreakpointRequest {
0N/A private final Location location;
0N/A
0N/A BreakpointRequestImpl(Location location) {
0N/A this.location = location;
0N/A filters.add(0,JDWP.EventRequest.Set.Modifier.LocationOnly
0N/A .create(location));
0N/A requestList().add(this);
0N/A }
0N/A
0N/A public Location location() {
0N/A return location;
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.BREAKPOINT;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "breakpoint request " + location() + state();
0N/A }
0N/A }
0N/A
0N/A class ClassPrepareRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements ClassPrepareRequest {
0N/A ClassPrepareRequestImpl() {
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.CLASS_PREPARE;
0N/A }
0N/A
0N/A public synchronized void addSourceNameFilter(String sourceNamePattern) {
0N/A if (isEnabled() || deleted) {
0N/A throw invalidState();
0N/A }
0N/A if (!vm.canUseSourceNameFilters()) {
0N/A throw new UnsupportedOperationException(
0N/A "target does not support source name filters");
0N/A }
0N/A if (sourceNamePattern == null) {
0N/A throw new NullPointerException();
0N/A }
0N/A
0N/A filters.add(JDWP.EventRequest.Set.Modifier.SourceNameMatch
0N/A .create(sourceNamePattern));
0N/A }
0N/A
0N/A public String toString() {
0N/A return "class prepare request " + state();
0N/A }
0N/A }
0N/A
0N/A class ClassUnloadRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements ClassUnloadRequest {
0N/A ClassUnloadRequestImpl() {
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.CLASS_UNLOAD;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "class unload request " + state();
0N/A }
0N/A }
0N/A
0N/A class ExceptionRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements ExceptionRequest {
0N/A ReferenceType exception = null;
0N/A boolean caught = true;
0N/A boolean uncaught = true;
0N/A
0N/A ExceptionRequestImpl(ReferenceType refType,
0N/A boolean notifyCaught, boolean notifyUncaught) {
0N/A exception = refType;
0N/A caught = notifyCaught;
0N/A uncaught = notifyUncaught;
0N/A {
0N/A ReferenceTypeImpl exc;
0N/A if (exception == null) {
0N/A exc = new ClassTypeImpl(vm, 0);
0N/A } else {
0N/A exc = (ReferenceTypeImpl)exception;
0N/A }
0N/A filters.add(JDWP.EventRequest.Set.Modifier.ExceptionOnly.
0N/A create(exc, caught, uncaught));
0N/A }
0N/A requestList().add(this);
0N/A }
0N/A
0N/A public ReferenceType exception() {
0N/A return exception;
0N/A }
0N/A
0N/A public boolean notifyCaught() {
0N/A return caught;
0N/A }
0N/A
0N/A public boolean notifyUncaught() {
0N/A return uncaught;
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.EXCEPTION;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "exception request " + exception() + state();
0N/A }
0N/A }
0N/A
0N/A class MethodEntryRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements MethodEntryRequest {
0N/A MethodEntryRequestImpl() {
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.METHOD_ENTRY;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "method entry request " + state();
0N/A }
0N/A }
0N/A
0N/A class MethodExitRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements MethodExitRequest {
0N/A MethodExitRequestImpl() {
0N/A if (methodExitEventCmd == 0) {
0N/A /*
0N/A * If we can get return values, then we always get them.
0N/A * Thus, for JDI MethodExitRequests, we always use the
0N/A * same JDWP EventKind. Here we decide which to use and
0N/A * save it so that it will be used for all future
0N/A * MethodExitRequests.
0N/A *
0N/A * This call to canGetMethodReturnValues can't
0N/A * be done in the EventRequestManager ctor because that is too early.
0N/A */
0N/A if (vm.canGetMethodReturnValues()) {
0N/A methodExitEventCmd = JDWP.EventKind.METHOD_EXIT_WITH_RETURN_VALUE;
0N/A } else {
0N/A methodExitEventCmd = JDWP.EventKind.METHOD_EXIT;
0N/A }
0N/A }
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return EventRequestManagerImpl.methodExitEventCmd;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "method exit request " + state();
0N/A }
0N/A }
0N/A
0N/A class MonitorContendedEnterRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements MonitorContendedEnterRequest {
0N/A MonitorContendedEnterRequestImpl() {
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.MONITOR_CONTENDED_ENTER;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "monitor contended enter request " + state();
0N/A }
0N/A }
0N/A
0N/A class MonitorContendedEnteredRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements MonitorContendedEnteredRequest {
0N/A MonitorContendedEnteredRequestImpl() {
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.MONITOR_CONTENDED_ENTERED;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "monitor contended entered request " + state();
0N/A }
0N/A }
0N/A
0N/A class MonitorWaitRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements MonitorWaitRequest {
0N/A MonitorWaitRequestImpl() {
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.MONITOR_WAIT;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "monitor wait request " + state();
0N/A }
0N/A }
0N/A
0N/A class MonitorWaitedRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements MonitorWaitedRequest {
0N/A MonitorWaitedRequestImpl() {
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.MONITOR_WAITED;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "monitor waited request " + state();
0N/A }
0N/A }
0N/A
0N/A class StepRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements StepRequest {
0N/A ThreadReferenceImpl thread;
0N/A int size;
0N/A int depth;
0N/A
0N/A StepRequestImpl(ThreadReference thread, int size, int depth) {
0N/A this.thread = (ThreadReferenceImpl)thread;
0N/A this.size = size;
0N/A this.depth = depth;
0N/A
0N/A /*
0N/A * Translate size and depth to corresponding JDWP values.
0N/A */
0N/A int jdwpSize;
0N/A switch (size) {
0N/A case STEP_MIN:
0N/A jdwpSize = JDWP.StepSize.MIN;
0N/A break;
0N/A case STEP_LINE:
0N/A jdwpSize = JDWP.StepSize.LINE;
0N/A break;
0N/A default:
0N/A throw new IllegalArgumentException("Invalid step size");
0N/A }
0N/A
0N/A int jdwpDepth;
0N/A switch (depth) {
0N/A case STEP_INTO:
0N/A jdwpDepth = JDWP.StepDepth.INTO;
0N/A break;
0N/A case STEP_OVER:
0N/A jdwpDepth = JDWP.StepDepth.OVER;
0N/A break;
0N/A case STEP_OUT:
0N/A jdwpDepth = JDWP.StepDepth.OUT;
0N/A break;
0N/A default:
0N/A throw new IllegalArgumentException("Invalid step depth");
0N/A }
0N/A
0N/A /*
0N/A * Make sure this isn't a duplicate
0N/A */
0N/A List requests = stepRequests();
0N/A Iterator iter = requests.iterator();
0N/A while (iter.hasNext()) {
0N/A StepRequest request = (StepRequest)iter.next();
0N/A if ((request != this) &&
0N/A request.isEnabled() &&
0N/A request.thread().equals(thread)) {
0N/A throw new DuplicateRequestException(
0N/A "Only one step request allowed per thread");
0N/A }
0N/A }
0N/A
0N/A filters.add(JDWP.EventRequest.Set.Modifier.Step.
0N/A create(this.thread, jdwpSize, jdwpDepth));
0N/A requestList().add(this);
0N/A
0N/A }
0N/A public int depth() {
0N/A return depth;
0N/A }
0N/A
0N/A public int size() {
0N/A return size;
0N/A }
0N/A
0N/A public ThreadReference thread() {
0N/A return thread;
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.SINGLE_STEP;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "step request " + thread() + state();
0N/A }
0N/A }
0N/A
0N/A class ThreadDeathRequestImpl extends ThreadVisibleEventRequestImpl
0N/A implements ThreadDeathRequest {
0N/A ThreadDeathRequestImpl() {
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.THREAD_DEATH;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "thread death request " + state();
0N/A }
0N/A }
0N/A
0N/A class ThreadStartRequestImpl extends ThreadVisibleEventRequestImpl
0N/A implements ThreadStartRequest {
0N/A ThreadStartRequestImpl() {
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.THREAD_START;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "thread start request " + state();
0N/A }
0N/A }
0N/A
0N/A abstract class WatchpointRequestImpl extends ClassVisibleEventRequestImpl
0N/A implements WatchpointRequest {
0N/A final Field field;
0N/A
0N/A WatchpointRequestImpl(Field field) {
0N/A this.field = field;
0N/A filters.add(0,
0N/A JDWP.EventRequest.Set.Modifier.FieldOnly.create(
0N/A (ReferenceTypeImpl)field.declaringType(),
0N/A ((FieldImpl)field).ref()));
0N/A }
0N/A
0N/A public Field field() {
0N/A return field;
0N/A }
0N/A }
0N/A
0N/A class AccessWatchpointRequestImpl extends WatchpointRequestImpl
0N/A implements AccessWatchpointRequest {
0N/A AccessWatchpointRequestImpl(Field field) {
0N/A super(field);
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.FIELD_ACCESS;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "access watchpoint request " + field + state();
0N/A }
0N/A }
0N/A
0N/A class ModificationWatchpointRequestImpl extends WatchpointRequestImpl
0N/A implements ModificationWatchpointRequest {
0N/A ModificationWatchpointRequestImpl(Field field) {
0N/A super(field);
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.FIELD_MODIFICATION;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "modification watchpoint request " + field + state();
0N/A }
0N/A }
0N/A
0N/A class VMDeathRequestImpl extends EventRequestImpl
0N/A implements VMDeathRequest {
0N/A VMDeathRequestImpl() {
0N/A requestList().add(this);
0N/A }
0N/A
0N/A int eventCmd() {
0N/A return JDWP.EventKind.VM_DEATH;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "VM death request " + state();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Constructor.
0N/A */
0N/A EventRequestManagerImpl(VirtualMachine vm) {
0N/A super(vm);
0N/A java.lang.reflect.Field[] ekinds =
0N/A JDWP.EventKind.class.getDeclaredFields();
0N/A int highest = 0;
0N/A for (int i = 0; i < ekinds.length; ++i) {
0N/A int val;
0N/A try {
0N/A val = ekinds[i].getInt(null);
0N/A } catch (IllegalAccessException exc) {
0N/A throw new RuntimeException("Got: " + exc);
0N/A }
0N/A if (val > highest) {
0N/A highest = val;
0N/A }
0N/A }
0N/A requestLists = new List[highest+1];
0N/A for (int i=0; i <= highest; i++) {
0N/A requestLists[i] = new ArrayList();
0N/A }
0N/A }
0N/A
0N/A public ClassPrepareRequest createClassPrepareRequest() {
0N/A return new ClassPrepareRequestImpl();
0N/A }
0N/A
0N/A public ClassUnloadRequest createClassUnloadRequest() {
0N/A return new ClassUnloadRequestImpl();
0N/A }
0N/A
0N/A public ExceptionRequest createExceptionRequest(ReferenceType refType,
0N/A boolean notifyCaught,
0N/A boolean notifyUncaught) {
0N/A validateMirrorOrNull(refType);
0N/A return new ExceptionRequestImpl(refType, notifyCaught, notifyUncaught);
0N/A }
0N/A
0N/A public StepRequest createStepRequest(ThreadReference thread,
0N/A int size, int depth) {
0N/A validateMirror(thread);
0N/A return new StepRequestImpl(thread, size, depth);
0N/A }
0N/A
0N/A public ThreadDeathRequest createThreadDeathRequest() {
0N/A return new ThreadDeathRequestImpl();
0N/A }
0N/A
0N/A public ThreadStartRequest createThreadStartRequest() {
0N/A return new ThreadStartRequestImpl();
0N/A }
0N/A
0N/A public MethodEntryRequest createMethodEntryRequest() {
0N/A return new MethodEntryRequestImpl();
0N/A }
0N/A
0N/A public MethodExitRequest createMethodExitRequest() {
0N/A return new MethodExitRequestImpl();
0N/A }
0N/A
0N/A public MonitorContendedEnterRequest createMonitorContendedEnterRequest() {
0N/A if (!vm.canRequestMonitorEvents()) {
0N/A throw new UnsupportedOperationException(
0N/A "target VM does not support requesting Monitor events");
0N/A }
0N/A return new MonitorContendedEnterRequestImpl();
0N/A }
0N/A
0N/A public MonitorContendedEnteredRequest createMonitorContendedEnteredRequest() {
0N/A if (!vm.canRequestMonitorEvents()) {
0N/A throw new UnsupportedOperationException(
0N/A "target VM does not support requesting Monitor events");
0N/A }
0N/A return new MonitorContendedEnteredRequestImpl();
0N/A }
0N/A
0N/A public MonitorWaitRequest createMonitorWaitRequest() {
0N/A if (!vm.canRequestMonitorEvents()) {
0N/A throw new UnsupportedOperationException(
0N/A "target VM does not support requesting Monitor events");
0N/A }
0N/A return new MonitorWaitRequestImpl();
0N/A }
0N/A
0N/A public MonitorWaitedRequest createMonitorWaitedRequest() {
0N/A if (!vm.canRequestMonitorEvents()) {
0N/A throw new UnsupportedOperationException(
0N/A "target VM does not support requesting Monitor events");
0N/A }
0N/A return new MonitorWaitedRequestImpl();
0N/A }
0N/A
0N/A public BreakpointRequest createBreakpointRequest(Location location) {
0N/A validateMirror(location);
0N/A if (location.codeIndex() == -1) {
0N/A throw new NativeMethodException("Cannot set breakpoints on native methods");
0N/A }
0N/A return new BreakpointRequestImpl(location);
0N/A }
0N/A
0N/A public AccessWatchpointRequest
0N/A createAccessWatchpointRequest(Field field) {
0N/A validateMirror(field);
0N/A if (!vm.canWatchFieldAccess()) {
0N/A throw new UnsupportedOperationException(
0N/A "target VM does not support access watchpoints");
0N/A }
0N/A return new AccessWatchpointRequestImpl(field);
0N/A }
0N/A
0N/A public ModificationWatchpointRequest
0N/A createModificationWatchpointRequest(Field field) {
0N/A validateMirror(field);
0N/A if (!vm.canWatchFieldModification()) {
0N/A throw new UnsupportedOperationException(
0N/A "target VM does not support modification watchpoints");
0N/A }
0N/A return new ModificationWatchpointRequestImpl(field);
0N/A }
0N/A
0N/A public VMDeathRequest createVMDeathRequest() {
0N/A if (!vm.canRequestVMDeathEvent()) {
0N/A throw new UnsupportedOperationException(
0N/A "target VM does not support requesting VM death events");
0N/A }
0N/A return new VMDeathRequestImpl();
0N/A }
0N/A
0N/A public void deleteEventRequest(EventRequest eventRequest) {
0N/A validateMirror(eventRequest);
0N/A ((EventRequestImpl)eventRequest).delete();
0N/A }
0N/A
0N/A public void deleteEventRequests(List<? extends EventRequest> eventRequests) {
0N/A validateMirrors(eventRequests);
0N/A // copy the eventRequests to avoid ConcurrentModificationException
0N/A Iterator iter = (new ArrayList(eventRequests)).iterator();
0N/A while (iter.hasNext()) {
0N/A ((EventRequestImpl)iter.next()).delete();
0N/A }
0N/A }
0N/A
0N/A public void deleteAllBreakpoints() {
0N/A requestList(JDWP.EventKind.BREAKPOINT).clear();
0N/A
0N/A try {
0N/A JDWP.EventRequest.ClearAllBreakpoints.process(vm);
0N/A } catch (JDWPException exc) {
0N/A throw exc.toJDIException();
0N/A }
0N/A }
0N/A
0N/A public List<StepRequest> stepRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.SINGLE_STEP);
0N/A }
0N/A
0N/A public List<ClassPrepareRequest> classPrepareRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.CLASS_PREPARE);
0N/A }
0N/A
0N/A public List<ClassUnloadRequest> classUnloadRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.CLASS_UNLOAD);
0N/A }
0N/A
0N/A public List<ThreadStartRequest> threadStartRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.THREAD_START);
0N/A }
0N/A
0N/A public List<ThreadDeathRequest> threadDeathRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.THREAD_DEATH);
0N/A }
0N/A
0N/A public List<ExceptionRequest> exceptionRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.EXCEPTION);
0N/A }
0N/A
0N/A public List<BreakpointRequest> breakpointRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.BREAKPOINT);
0N/A }
0N/A
0N/A public List<AccessWatchpointRequest> accessWatchpointRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.FIELD_ACCESS);
0N/A }
0N/A
0N/A public List<ModificationWatchpointRequest> modificationWatchpointRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.FIELD_MODIFICATION);
0N/A }
0N/A
0N/A public List<MethodEntryRequest> methodEntryRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.METHOD_ENTRY);
0N/A }
0N/A
0N/A public List<MethodExitRequest> methodExitRequests() {
0N/A return unmodifiableRequestList(
0N/A EventRequestManagerImpl.methodExitEventCmd);
0N/A }
0N/A
0N/A public List<MonitorContendedEnterRequest> monitorContendedEnterRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.MONITOR_CONTENDED_ENTER);
0N/A }
0N/A
0N/A public List<MonitorContendedEnteredRequest> monitorContendedEnteredRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.MONITOR_CONTENDED_ENTERED);
0N/A }
0N/A
0N/A public List<MonitorWaitRequest> monitorWaitRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.MONITOR_WAIT);
0N/A }
0N/A
0N/A public List<MonitorWaitedRequest> monitorWaitedRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.MONITOR_WAITED);
0N/A }
0N/A
0N/A public List<VMDeathRequest> vmDeathRequests() {
0N/A return unmodifiableRequestList(JDWP.EventKind.VM_DEATH);
0N/A }
0N/A
0N/A List unmodifiableRequestList(int eventCmd) {
0N/A return Collections.unmodifiableList(requestList(eventCmd));
0N/A }
0N/A
0N/A EventRequest request(int eventCmd, int requestId) {
0N/A List rl = requestList(eventCmd);
0N/A for (int i = rl.size() - 1; i >= 0; i--) {
0N/A EventRequestImpl er = (EventRequestImpl)rl.get(i);
0N/A if (er.id == requestId) {
0N/A return er;
0N/A }
0N/A }
0N/A return null;
0N/A }
0N/A
0N/A List<? extends EventRequest> requestList(int eventCmd) {
0N/A return requestLists[eventCmd];
0N/A }
0N/A
0N/A}