jdk/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java
author jbachorik
Tue, 29 Apr 2014 11:15:21 +0200
changeset 24125 b85eeaae56c7
parent 14342 8435a30053c1
child 25798 0b2f54e47bc4
permissions -rw-r--r--
8031195: Support default and static interface methods in JDI, JDWP and JDB Reviewed-by: sla, sspitsyn, dcubed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 11277
diff changeset
     2
 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.jdi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import com.sun.jdi.request.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import com.sun.tools.jdi.JDWP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * This interface is used to create and remove Breakpoints, Watchpoints,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * It include implementations of all the request interfaces..
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
// Warnings from List filters and List[] requestLists is  hard to fix.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
// Remove SuppressWarning when we fix the warnings from List filters
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
// and List[] requestLists. The generic array is not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
@SuppressWarnings("unchecked")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
class EventRequestManagerImpl extends MirrorImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
                                       implements EventRequestManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
{
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
    46
    List<? extends EventRequest>[] requestLists;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private static int methodExitEventCmd = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    static int JDWPtoJDISuspendPolicy(byte jdwpPolicy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        switch(jdwpPolicy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
            case JDWP.SuspendPolicy.ALL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
                return EventRequest.SUSPEND_ALL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            case JDWP.SuspendPolicy.EVENT_THREAD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
                return EventRequest.SUSPEND_EVENT_THREAD;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        case JDWP.SuspendPolicy.NONE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                return EventRequest.SUSPEND_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                throw new IllegalArgumentException("Illegal policy constant: " + jdwpPolicy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    static byte JDItoJDWPSuspendPolicy(int jdiPolicy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        switch(jdiPolicy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
            case EventRequest.SUSPEND_ALL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                return JDWP.SuspendPolicy.ALL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            case EventRequest.SUSPEND_EVENT_THREAD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                return JDWP.SuspendPolicy.EVENT_THREAD;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            case EventRequest.SUSPEND_NONE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                return JDWP.SuspendPolicy.NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                throw new IllegalArgumentException("Illegal policy constant: " + jdiPolicy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Override superclass back to default equality
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        return this == obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        return System.identityHashCode(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    abstract class EventRequestImpl extends MirrorImpl implements EventRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        int id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
         * This list is not protected by a synchronized wrapper. All
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
         * access/modification should be protected by synchronizing on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
         * the enclosing instance of EventRequestImpl.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
         */
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
    94
        List<Object> filters = new ArrayList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        boolean isEnabled = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        boolean deleted = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        byte suspendPolicy = JDWP.SuspendPolicy.ALL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        private Map<Object, Object> clientProperties = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        EventRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            super(EventRequestManagerImpl.this.vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
         * Override superclass back to default equality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            return this == obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            return System.identityHashCode(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        abstract int eventCmd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        InvalidRequestStateException invalidState() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            return new InvalidRequestStateException(toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        String state() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            return deleted? " (deleted)" :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                (isEnabled()? " (enabled)" : " (disabled)");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
         * @return all the event request of this kind
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        List requestList() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            return EventRequestManagerImpl.this.requestList(eventCmd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
         * delete the event request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        void delete() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            if (!deleted) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                requestList().remove(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                disable(); /* must do BEFORE delete */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                deleted = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            return isEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        public void enable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            setEnabled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        public void disable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            setEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        public synchronized void setEnabled(boolean val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            if (deleted) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                throw invalidState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                if (val != isEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                    if (isEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                        clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                        set();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        public synchronized void addCountFilter(int count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            if (isEnabled() || deleted) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                throw invalidState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            if (count < 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                throw new IllegalArgumentException("count is less than one");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            filters.add(JDWP.EventRequest.Set.Modifier.Count.create(count));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        public void setSuspendPolicy(int policy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            if (isEnabled() || deleted) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                throw invalidState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            suspendPolicy = JDItoJDWPSuspendPolicy(policy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        public int suspendPolicy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            return JDWPtoJDISuspendPolicy(suspendPolicy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
         * set (enable) the event request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        synchronized void set() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            JDWP.EventRequest.Set.Modifier[] mods =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                filters.toArray(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    new JDWP.EventRequest.Set.Modifier[filters.size()]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                id = JDWP.EventRequest.Set.process(vm, (byte)eventCmd(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                                                   suspendPolicy, mods).requestID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            isEnabled = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        synchronized void clear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                JDWP.EventRequest.Clear.process(vm, (byte)eventCmd(), id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            isEnabled = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
         * @return a small Map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
         * @see #putProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
         * @see #getProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        private Map<Object, Object> getProperties() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            if (clientProperties == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                clientProperties = new HashMap<Object, Object>(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            return clientProperties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
         * Returns the value of the property with the specified key.  Only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
         * properties added with <code>putProperty</code> will return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
         * a non-null value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
         * @return the value of this property or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
         * @see #putProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        public final Object getProperty(Object key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            if (clientProperties == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                return getProperties().get(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
         * Add an arbitrary key/value "property" to this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
         * @see #getProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        public final void putProperty(Object key, Object value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            if (value != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                getProperties().put(key, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                getProperties().remove(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    abstract class ThreadVisibleEventRequestImpl extends EventRequestImpl {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        public synchronized void addThreadFilter(ThreadReference thread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            validateMirror(thread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            if (isEnabled() || deleted) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                throw invalidState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            filters.add(JDWP.EventRequest.Set.Modifier.ThreadOnly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                      .create((ThreadReferenceImpl)thread));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    abstract class ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                                  extends ThreadVisibleEventRequestImpl {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        public synchronized void addClassFilter(ReferenceType clazz) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            validateMirror(clazz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            if (isEnabled() || deleted) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                throw invalidState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            filters.add(JDWP.EventRequest.Set.Modifier.ClassOnly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                                      .create((ReferenceTypeImpl)clazz));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        public synchronized void addClassFilter(String classPattern) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            if (isEnabled() || deleted) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                throw invalidState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            if (classPattern == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            filters.add(JDWP.EventRequest.Set.Modifier.ClassMatch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                                      .create(classPattern));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        public synchronized void addClassExclusionFilter(String classPattern) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            if (isEnabled() || deleted) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                throw invalidState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            if (classPattern == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            filters.add(JDWP.EventRequest.Set.Modifier.ClassExclude
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                                      .create(classPattern));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        public synchronized void addInstanceFilter(ObjectReference instance) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            validateMirror(instance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            if (isEnabled() || deleted) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                throw invalidState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            if (!vm.canUseInstanceFilters()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                     "target does not support instance filters");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            filters.add(JDWP.EventRequest.Set.Modifier.InstanceOnly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                                      .create((ObjectReferenceImpl)instance));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    class BreakpointRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                                     implements BreakpointRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        private final Location location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        BreakpointRequestImpl(Location location) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            this.location = location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            filters.add(0,JDWP.EventRequest.Set.Modifier.LocationOnly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                                                 .create(location));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        public Location location() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            return location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            return JDWP.EventKind.BREAKPOINT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            return "breakpoint request " + location() + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    class ClassPrepareRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                                     implements ClassPrepareRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        ClassPrepareRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            return JDWP.EventKind.CLASS_PREPARE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        public synchronized void addSourceNameFilter(String sourceNamePattern) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            if (isEnabled() || deleted) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                throw invalidState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            if (!vm.canUseSourceNameFilters()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                     "target does not support source name filters");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            if (sourceNamePattern == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            filters.add(JDWP.EventRequest.Set.Modifier.SourceNameMatch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                                      .create(sourceNamePattern));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            return "class prepare request " + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    class ClassUnloadRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                                     implements ClassUnloadRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        ClassUnloadRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            return JDWP.EventKind.CLASS_UNLOAD;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            return "class unload request " + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    class ExceptionRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                                      implements ExceptionRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        ReferenceType exception = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        boolean caught = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        boolean uncaught = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        ExceptionRequestImpl(ReferenceType refType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                          boolean notifyCaught, boolean notifyUncaught) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            exception = refType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            caught = notifyCaught;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            uncaught = notifyUncaught;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                ReferenceTypeImpl exc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                if (exception == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                    exc = new ClassTypeImpl(vm, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                    exc = (ReferenceTypeImpl)exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                filters.add(JDWP.EventRequest.Set.Modifier.ExceptionOnly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                            create(exc, caught, uncaught));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        public ReferenceType exception() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            return exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        public boolean notifyCaught() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            return caught;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        public boolean notifyUncaught() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            return uncaught;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            return JDWP.EventKind.EXCEPTION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            return "exception request " + exception() + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    class MethodEntryRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                                      implements MethodEntryRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        MethodEntryRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            return JDWP.EventKind.METHOD_ENTRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            return "method entry request " + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    class MethodExitRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                                      implements MethodExitRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        MethodExitRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            if (methodExitEventCmd == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                 * If we can get return values, then we always get them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                 * Thus, for JDI MethodExitRequests, we always use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                 * same JDWP EventKind.  Here we decide which to use and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                 * save it so that it will be used for all future
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                 * MethodExitRequests.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                 * This call to canGetMethodReturnValues can't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                 * be done in the EventRequestManager ctor because that is too early.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                if (vm.canGetMethodReturnValues()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                    methodExitEventCmd = JDWP.EventKind.METHOD_EXIT_WITH_RETURN_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                    methodExitEventCmd = JDWP.EventKind.METHOD_EXIT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            return EventRequestManagerImpl.methodExitEventCmd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            return "method exit request " + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    class MonitorContendedEnterRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                                      implements MonitorContendedEnterRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        MonitorContendedEnterRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            return JDWP.EventKind.MONITOR_CONTENDED_ENTER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            return "monitor contended enter request " + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    class MonitorContendedEnteredRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                                      implements MonitorContendedEnteredRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        MonitorContendedEnteredRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            return JDWP.EventKind.MONITOR_CONTENDED_ENTERED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            return "monitor contended entered request " + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    class MonitorWaitRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                                 implements MonitorWaitRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        MonitorWaitRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            return JDWP.EventKind.MONITOR_WAIT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            return "monitor wait request " + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    class MonitorWaitedRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                                 implements MonitorWaitedRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        MonitorWaitedRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            return JDWP.EventKind.MONITOR_WAITED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            return "monitor waited request " + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    class StepRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                                      implements StepRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        ThreadReferenceImpl thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        int size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        int depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        StepRequestImpl(ThreadReference thread, int size, int depth) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
            this.thread = (ThreadReferenceImpl)thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            this.size = size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            this.depth = depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
             * Translate size and depth to corresponding JDWP values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            int jdwpSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            switch (size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                case STEP_MIN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                    jdwpSize = JDWP.StepSize.MIN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                case STEP_LINE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                    jdwpSize = JDWP.StepSize.LINE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                    throw new IllegalArgumentException("Invalid step size");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            int jdwpDepth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            switch (depth) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                case STEP_INTO:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                    jdwpDepth = JDWP.StepDepth.INTO;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                case STEP_OVER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                    jdwpDepth = JDWP.StepDepth.OVER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                case STEP_OUT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                    jdwpDepth = JDWP.StepDepth.OUT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                    throw new IllegalArgumentException("Invalid step depth");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
             * Make sure this isn't a duplicate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
             */
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   584
            List<StepRequest> requests = stepRequests();
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   585
            Iterator<StepRequest> iter = requests.iterator();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            while (iter.hasNext()) {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   587
                StepRequest request = iter.next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                if ((request != this) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                        request.isEnabled() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                        request.thread().equals(thread)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                    throw new DuplicateRequestException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                        "Only one step request allowed per thread");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            filters.add(JDWP.EventRequest.Set.Modifier.Step.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                        create(this.thread, jdwpSize, jdwpDepth));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        public int depth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            return depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        public int size() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
            return size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        public ThreadReference thread() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            return thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            return JDWP.EventKind.SINGLE_STEP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            return "step request " + thread() + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    class ThreadDeathRequestImpl extends ThreadVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                                      implements ThreadDeathRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        ThreadDeathRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            return JDWP.EventKind.THREAD_DEATH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            return "thread death request " + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    class ThreadStartRequestImpl extends ThreadVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                                      implements ThreadStartRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        ThreadStartRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            return JDWP.EventKind.THREAD_START;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            return "thread start request " + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    abstract class WatchpointRequestImpl extends ClassVisibleEventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                                      implements WatchpointRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        final Field field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        WatchpointRequestImpl(Field field) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
            this.field = field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            filters.add(0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                   JDWP.EventRequest.Set.Modifier.FieldOnly.create(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                    (ReferenceTypeImpl)field.declaringType(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                    ((FieldImpl)field).ref()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        public Field field() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
            return field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    class AccessWatchpointRequestImpl extends WatchpointRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                                  implements AccessWatchpointRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        AccessWatchpointRequestImpl(Field field) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            super(field);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
            return JDWP.EventKind.FIELD_ACCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            return "access watchpoint request " + field + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    class ModificationWatchpointRequestImpl extends WatchpointRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                                  implements ModificationWatchpointRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        ModificationWatchpointRequestImpl(Field field) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            super(field);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            return JDWP.EventKind.FIELD_MODIFICATION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            return "modification watchpoint request " + field + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    class VMDeathRequestImpl extends EventRequestImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                                        implements VMDeathRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        VMDeathRequestImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            requestList().add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        int eventCmd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            return JDWP.EventKind.VM_DEATH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            return "VM death request " + state();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * Constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    EventRequestManagerImpl(VirtualMachine vm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        super(vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        java.lang.reflect.Field[] ekinds =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
            JDWP.EventKind.class.getDeclaredFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        int highest = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        for (int i = 0; i < ekinds.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
            int val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
                val = ekinds[i].getInt(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            } catch (IllegalAccessException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                throw new RuntimeException("Got: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
            if (val > highest) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                highest = val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        requestLists = new List[highest+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        for (int i=0; i <= highest; i++) {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   737
            requestLists[i] = new ArrayList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    public ClassPrepareRequest createClassPrepareRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        return new ClassPrepareRequestImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    public ClassUnloadRequest createClassUnloadRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        return new ClassUnloadRequestImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    public ExceptionRequest createExceptionRequest(ReferenceType refType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
                                                   boolean notifyCaught,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                                                   boolean notifyUncaught) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        validateMirrorOrNull(refType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        return new ExceptionRequestImpl(refType, notifyCaught, notifyUncaught);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    public StepRequest createStepRequest(ThreadReference thread,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                                         int size, int depth) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        validateMirror(thread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        return new StepRequestImpl(thread, size, depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    public ThreadDeathRequest createThreadDeathRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        return new ThreadDeathRequestImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    public ThreadStartRequest createThreadStartRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        return new ThreadStartRequestImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    public MethodEntryRequest createMethodEntryRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        return new MethodEntryRequestImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
    public MethodExitRequest createMethodExitRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        return new MethodExitRequestImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    public MonitorContendedEnterRequest createMonitorContendedEnterRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        if (!vm.canRequestMonitorEvents()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
            throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
          "target VM does not support requesting Monitor events");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        return new MonitorContendedEnterRequestImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    public MonitorContendedEnteredRequest createMonitorContendedEnteredRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        if (!vm.canRequestMonitorEvents()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
            throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
          "target VM does not support requesting Monitor events");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        return new MonitorContendedEnteredRequestImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    public MonitorWaitRequest createMonitorWaitRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        if (!vm.canRequestMonitorEvents()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
            throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
          "target VM does not support requesting Monitor events");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        return new MonitorWaitRequestImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    public MonitorWaitedRequest createMonitorWaitedRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        if (!vm.canRequestMonitorEvents()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
            throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
          "target VM does not support requesting Monitor events");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        return new MonitorWaitedRequestImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    public BreakpointRequest createBreakpointRequest(Location location) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        validateMirror(location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        if (location.codeIndex() == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            throw new NativeMethodException("Cannot set breakpoints on native methods");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        return new BreakpointRequestImpl(location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    public AccessWatchpointRequest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                              createAccessWatchpointRequest(Field field) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        validateMirror(field);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        if (!vm.canWatchFieldAccess()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
            throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
          "target VM does not support access watchpoints");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        return new AccessWatchpointRequestImpl(field);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    public ModificationWatchpointRequest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                        createModificationWatchpointRequest(Field field) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        validateMirror(field);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        if (!vm.canWatchFieldModification()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
          "target VM does not support modification watchpoints");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        return new ModificationWatchpointRequestImpl(field);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    public VMDeathRequest createVMDeathRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        if (!vm.canRequestVMDeathEvent()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
            throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
          "target VM does not support requesting VM death events");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        return new VMDeathRequestImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    public void deleteEventRequest(EventRequest eventRequest) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        validateMirror(eventRequest);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        ((EventRequestImpl)eventRequest).delete();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    public void deleteEventRequests(List<? extends EventRequest> eventRequests) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        validateMirrors(eventRequests);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        // copy the eventRequests to avoid ConcurrentModificationException
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   854
        Iterator<? extends EventRequest> iter = (new ArrayList<>(eventRequests)).iterator();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            ((EventRequestImpl)iter.next()).delete();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    public void deleteAllBreakpoints() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        requestList(JDWP.EventKind.BREAKPOINT).clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
            JDWP.EventRequest.ClearAllBreakpoints.process(vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
            throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
    public List<StepRequest> stepRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   871
        return (List<StepRequest>)unmodifiableRequestList(JDWP.EventKind.SINGLE_STEP);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    public List<ClassPrepareRequest> classPrepareRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   875
        return (List<ClassPrepareRequest>)unmodifiableRequestList(JDWP.EventKind.CLASS_PREPARE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    public List<ClassUnloadRequest> classUnloadRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   879
        return (List<ClassUnloadRequest>)unmodifiableRequestList(JDWP.EventKind.CLASS_UNLOAD);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    public List<ThreadStartRequest> threadStartRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   883
        return (List<ThreadStartRequest>)unmodifiableRequestList(JDWP.EventKind.THREAD_START);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
    public List<ThreadDeathRequest> threadDeathRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   887
        return (List<ThreadDeathRequest>)unmodifiableRequestList(JDWP.EventKind.THREAD_DEATH);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    public List<ExceptionRequest> exceptionRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   891
        return (List<ExceptionRequest>)unmodifiableRequestList(JDWP.EventKind.EXCEPTION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    public List<BreakpointRequest> breakpointRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   895
        return (List<BreakpointRequest>)unmodifiableRequestList(JDWP.EventKind.BREAKPOINT);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    public List<AccessWatchpointRequest> accessWatchpointRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   899
        return (List<AccessWatchpointRequest>)unmodifiableRequestList(JDWP.EventKind.FIELD_ACCESS);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    public List<ModificationWatchpointRequest> modificationWatchpointRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   903
        return (List<ModificationWatchpointRequest>)unmodifiableRequestList(JDWP.EventKind.FIELD_MODIFICATION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    public List<MethodEntryRequest> methodEntryRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   907
        return (List<MethodEntryRequest>)unmodifiableRequestList(JDWP.EventKind.METHOD_ENTRY);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    public List<MethodExitRequest> methodExitRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   911
        return (List<MethodExitRequest>)unmodifiableRequestList(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
                               EventRequestManagerImpl.methodExitEventCmd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    public List<MonitorContendedEnterRequest> monitorContendedEnterRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   916
        return (List<MonitorContendedEnterRequest>)unmodifiableRequestList(JDWP.EventKind.MONITOR_CONTENDED_ENTER);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
    public List<MonitorContendedEnteredRequest> monitorContendedEnteredRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   920
        return (List<MonitorContendedEnteredRequest>)unmodifiableRequestList(JDWP.EventKind.MONITOR_CONTENDED_ENTERED);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    public List<MonitorWaitRequest> monitorWaitRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   924
        return (List<MonitorWaitRequest>)unmodifiableRequestList(JDWP.EventKind.MONITOR_WAIT);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
    public List<MonitorWaitedRequest> monitorWaitedRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   928
        return (List<MonitorWaitedRequest>)unmodifiableRequestList(JDWP.EventKind.MONITOR_WAITED);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    public List<VMDeathRequest> vmDeathRequests() {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   932
        return (List<VMDeathRequest>)unmodifiableRequestList(JDWP.EventKind.VM_DEATH);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   935
    List<? extends EventRequest> unmodifiableRequestList(int eventCmd) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        return Collections.unmodifiableList(requestList(eventCmd));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    EventRequest request(int eventCmd, int requestId) {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
   940
        List<? extends EventRequest> rl = requestList(eventCmd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        for (int i = rl.size() - 1; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
            EventRequestImpl er = (EventRequestImpl)rl.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
            if (er.id == requestId) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                return er;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
    List<? extends EventRequest>  requestList(int eventCmd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
        return requestLists[eventCmd];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
}