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