jdk/src/share/classes/com/sun/tools/jdi/EventSetImpl.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 51 6fe31bc95bbc
child 832 5484c7a35278
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 51
diff changeset
     2
 * Copyright 1998-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.jdi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import com.sun.jdi.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import com.sun.jdi.request.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
enum EventDestination {UNKNOWN_EVENT, INTERNAL_EVENT, CLIENT_EVENT};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * An EventSet is normally created by the transport reader thread when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * it reads a JDWP Composite command.  The constructor doesn't unpack
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * the events contained in the Composite command and create EventImpls
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * for them because that process might involve calling back into the back-end
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * which should not be done by the transport reader thread.  Instead,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * the raw bytes of the packet are read and stored in the EventSet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * The EventSet is then added to each EventQueue. When an EventSet is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * removed from an EventQueue, the EventSetImpl.build() method is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * This method reads the packet bytes and creates the actual EventImpl objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * build() also filters out events for our internal handler and puts them in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * their own EventSet.  This means that the EventImpls that are in the EventSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * that is on the queues are all for client requests.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public class EventSetImpl extends ArrayList<Event> implements EventSet {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private VirtualMachineImpl vm; // we implement Mirror
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private Packet pkt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private byte suspendPolicy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private EventSetImpl internalEventSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        String string = "event set, policy:" + suspendPolicy +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                        ", count:" + this.size() + " = {";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        boolean first = true;
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
    60
        for (Event event : this) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            if (!first) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                string += ", ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
            string += event.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            first = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        string += "}";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        return string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    abstract class EventImpl extends MirrorImpl implements Event {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        private final byte eventCmd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        private final int requestID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        // This is set only for client requests, not internal requests.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        private final EventRequest request;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
         * Constructor for events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        protected EventImpl(JDWP.Event.Composite.Events.EventsCommon evt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                            int requestID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            super(EventSetImpl.this.vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            this.eventCmd = evt.eventKind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            this.requestID = requestID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            EventRequestManagerImpl ermi = EventSetImpl.this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                vm.eventRequestManagerImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            this.request =  ermi.request(eventCmd, requestID);
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
         * Override superclass back to default equality
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            return this == obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            return System.identityHashCode(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
         * Constructor for VM disconnected events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        protected EventImpl(byte eventCmd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            super(EventSetImpl.this.vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            this.eventCmd = eventCmd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            this.requestID = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            this.request = null;
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 EventRequest request() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            return request;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        int requestID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            return requestID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        EventDestination destination() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
             * We need to decide if this event is for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
             * 1. an internal request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
             * 2. a client request that is no longer available, ie
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
             *    it has been deleted, or disabled and re-enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
             *    which gives it a new ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
             * 3. a current client request that is disabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
             * 4. a current enabled client request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
             * We will filter this set into a set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
             * that contains only 1s for our internal queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
             * and a set that contains only 4s for our client queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
             * If we get an EventSet that contains only 2 and 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
             * then we have to resume it if it is not SUSPEND_NONE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
             * because no one else will.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            if (requestID == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                /* An unsolicited event.  These have traditionally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                 * been treated as client events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                return EventDestination.CLIENT_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            // Is this an event for a current client request?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            if (request == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                // Nope.  Is it an event for an internal request?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                EventRequestManagerImpl ermi = this.vm.getInternalEventRequestManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                if (ermi.request(eventCmd, requestID) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                    // Yep
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                    return EventDestination.INTERNAL_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                return EventDestination.UNKNOWN_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            // We found a client request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            if (request.isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                return EventDestination.CLIENT_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            return EventDestination.UNKNOWN_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        abstract String eventName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            return eventName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    abstract class ThreadedEventImpl extends EventImpl {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        private ThreadReference thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        ThreadedEventImpl(JDWP.Event.Composite.Events.EventsCommon evt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                          int requestID, ThreadReference thread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            super(evt, requestID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            this.thread = thread;
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 ThreadReference thread() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            return thread;
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 String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            return eventName() + " in thread " + thread.name();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    abstract class LocatableEventImpl extends ThreadedEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                                            implements Locatable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        private Location location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        LocatableEventImpl(JDWP.Event.Composite.Events.EventsCommon evt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                           int requestID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                           ThreadReference thread, Location location) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            super(evt, requestID, thread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            this.location = location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        public Location location() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            return location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
         * For MethodEntry and MethodExit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        public Method method() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            return location.method();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            return eventName() + "@" + location().toString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                                 " in thread " + thread().name();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    class BreakpointEventImpl extends LocatableEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                            implements BreakpointEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        BreakpointEventImpl(JDWP.Event.Composite.Events.Breakpoint evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            super(evt, evt.requestID, evt.thread, evt.location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            return "BreakpointEvent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    class StepEventImpl extends LocatableEventImpl implements StepEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        StepEventImpl(JDWP.Event.Composite.Events.SingleStep evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            super(evt, evt.requestID, evt.thread, evt.location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            return "StepEvent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    class MethodEntryEventImpl extends LocatableEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                            implements MethodEntryEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        MethodEntryEventImpl(JDWP.Event.Composite.Events.MethodEntry evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            super(evt, evt.requestID, evt.thread, evt.location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            return "MethodEntryEvent";
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
    class MethodExitEventImpl extends LocatableEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                            implements MethodExitEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        private Value returnVal = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        MethodExitEventImpl(JDWP.Event.Composite.Events.MethodExit evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            super(evt, evt.requestID, evt.thread, evt.location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        MethodExitEventImpl(JDWP.Event.Composite.Events.MethodExitWithReturnValue evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            super(evt, evt.requestID, evt.thread, evt.location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            returnVal = evt.value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            return "MethodExitEvent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        public Value returnValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            if (!this.vm.canGetMethodReturnValues()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                "target does not support return values in MethodExit events");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            return returnVal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        }
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
    class MonitorContendedEnterEventImpl extends LocatableEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                            implements MonitorContendedEnterEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        private ObjectReference monitor = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        MonitorContendedEnterEventImpl(JDWP.Event.Composite.Events.MonitorContendedEnter evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            super(evt, evt.requestID, evt.thread, evt.location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            this.monitor = evt.object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            return "MonitorContendedEnter";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        public ObjectReference  monitor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            return monitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    class MonitorContendedEnteredEventImpl extends LocatableEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                            implements MonitorContendedEnteredEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        private ObjectReference monitor = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        MonitorContendedEnteredEventImpl(JDWP.Event.Composite.Events.MonitorContendedEntered evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            super(evt, evt.requestID, evt.thread, evt.location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            this.monitor = evt.object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            return "MonitorContendedEntered";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        public ObjectReference  monitor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            return monitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    class MonitorWaitEventImpl extends LocatableEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                            implements MonitorWaitEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        private ObjectReference monitor = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        private long timeout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        MonitorWaitEventImpl(JDWP.Event.Composite.Events.MonitorWait evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            super(evt, evt.requestID, evt.thread, evt.location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            this.monitor = evt.object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            this.timeout = evt.timeout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            return "MonitorWait";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        public ObjectReference  monitor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            return monitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        public long timeout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            return timeout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    class MonitorWaitedEventImpl extends LocatableEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                            implements MonitorWaitedEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        private ObjectReference monitor = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        private boolean timed_out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        MonitorWaitedEventImpl(JDWP.Event.Composite.Events.MonitorWaited evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            super(evt, evt.requestID, evt.thread, evt.location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            this.monitor = evt.object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            this.timed_out = evt.timed_out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            return "MonitorWaited";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        public ObjectReference  monitor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            return monitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        public boolean timedout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            return timed_out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    class ClassPrepareEventImpl extends ThreadedEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                            implements ClassPrepareEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        private ReferenceType referenceType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        ClassPrepareEventImpl(JDWP.Event.Composite.Events.ClassPrepare evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            super(evt, evt.requestID, evt.thread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            referenceType = this.vm.referenceType(evt.typeID, evt.refTypeTag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                                                  evt.signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            ((ReferenceTypeImpl)referenceType).setStatus(evt.status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        public ReferenceType referenceType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            return referenceType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            return "ClassPrepareEvent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    class ClassUnloadEventImpl extends EventImpl implements ClassUnloadEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        private String classSignature;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        ClassUnloadEventImpl(JDWP.Event.Composite.Events.ClassUnload evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            super(evt, evt.requestID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            this.classSignature = evt.signature;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        public String className() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            return classSignature.substring(1, classSignature.length()-1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                .replace('/', '.');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        public String classSignature() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            return classSignature;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            return "ClassUnloadEvent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    class ExceptionEventImpl extends LocatableEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                                             implements ExceptionEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        private ObjectReference exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        private Location catchLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        ExceptionEventImpl(JDWP.Event.Composite.Events.Exception evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            super(evt, evt.requestID, evt.thread, evt.location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            this.exception = evt.exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            this.catchLocation = evt.catchLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        public ObjectReference exception() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            return exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        public Location catchLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            return catchLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            return "ExceptionEvent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    class ThreadDeathEventImpl extends ThreadedEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                                        implements ThreadDeathEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        ThreadDeathEventImpl(JDWP.Event.Composite.Events.ThreadDeath evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            super(evt, evt.requestID, evt.thread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            return "ThreadDeathEvent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    class ThreadStartEventImpl extends ThreadedEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                                        implements ThreadStartEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        ThreadStartEventImpl(JDWP.Event.Composite.Events.ThreadStart evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            super(evt, evt.requestID, evt.thread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            return "ThreadStartEvent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    class VMStartEventImpl extends ThreadedEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                                        implements VMStartEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        VMStartEventImpl(JDWP.Event.Composite.Events.VMStart evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            super(evt, evt.requestID, evt.thread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            return "VMStartEvent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    class VMDeathEventImpl extends EventImpl implements VMDeathEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        VMDeathEventImpl(JDWP.Event.Composite.Events.VMDeath evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            super(evt, evt.requestID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            return "VMDeathEvent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    class VMDisconnectEventImpl extends EventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                                         implements VMDisconnectEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        VMDisconnectEventImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            super((byte)JDWP.EventKind.VM_DISCONNECTED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            return "VMDisconnectEvent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    abstract class WatchpointEventImpl extends LocatableEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                                            implements WatchpointEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        private final ReferenceTypeImpl refType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        private final long fieldID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        private final ObjectReference object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        private Field field = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        WatchpointEventImpl(JDWP.Event.Composite.Events.EventsCommon evt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                            int requestID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                            ThreadReference thread, Location location,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                            byte refTypeTag, long typeID, long fieldID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                            ObjectReference object) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            super(evt, requestID, thread, location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            this.refType = this.vm.referenceType(typeID, refTypeTag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            this.fieldID = fieldID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            this.object = object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        public Field field() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            if (field == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                field = refType.getFieldMirror(fieldID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            return field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        public ObjectReference object() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
            return object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        public Value valueCurrent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            if (object == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                return refType.getValue(field());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                return object.getValue(field());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    class AccessWatchpointEventImpl extends WatchpointEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                                            implements AccessWatchpointEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        AccessWatchpointEventImpl(JDWP.Event.Composite.Events.FieldAccess evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            super(evt, evt.requestID, evt.thread, evt.location,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                  evt.refTypeTag, evt.typeID, evt.fieldID, evt.object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            return "AccessWatchpoint";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    class ModificationWatchpointEventImpl extends WatchpointEventImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                           implements ModificationWatchpointEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        Value newValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        ModificationWatchpointEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                        JDWP.Event.Composite.Events.FieldModification evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            super(evt, evt.requestID, evt.thread, evt.location,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                  evt.refTypeTag, evt.typeID, evt.fieldID, evt.object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            this.newValue = evt.valueToBe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        public Value valueToBe() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            return newValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        String eventName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            return "ModificationWatchpoint";
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * Events are constructed on the thread which reads all data from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * transport. This means that the packet cannot be converted to real
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * JDI objects as that may involve further communications with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * back end which would deadlock.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * Hence the {@link #build()} method below called by EventQueue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    EventSetImpl(VirtualMachine aVm, Packet pkt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        // From "MirrorImpl":
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        // Yes, its a bit of a hack. But by doing it this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        // way, this is the only place we have to change
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        // typing to substitute a new impl.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        vm = (VirtualMachineImpl)aVm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        this.pkt = pkt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * Constructor for special events like VM disconnected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    EventSetImpl(VirtualMachine aVm, byte eventCmd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        this(aVm, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        suspendPolicy = JDWP.SuspendPolicy.NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        switch (eventCmd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            case JDWP.EventKind.VM_DISCONNECTED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                addEvent(new VMDisconnectEventImpl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                throw new InternalException("Bad singleton event code");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    private void addEvent(EventImpl evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        // Note that this class has a public add method that throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        // an exception so that clients can't modify the EventSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        super.add(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * Complete the construction of an EventSet.  This is called from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * an event handler thread.  It upacks the JDWP events inside
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * the packet and creates EventImpls for them.  The EventSet is already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * on EventQueues when this is called, so it has to be synch.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    synchronized void build() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        if (pkt == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        PacketStream ps = new PacketStream(vm, pkt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        JDWP.Event.Composite compEvt = new JDWP.Event.Composite(vm, ps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        suspendPolicy = compEvt.suspendPolicy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        if ((vm.traceFlags & vm.TRACE_EVENTS) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            switch(suspendPolicy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                case JDWP.SuspendPolicy.ALL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                    vm.printTrace("EventSet: SUSPEND_ALL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                case JDWP.SuspendPolicy.EVENT_THREAD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                    vm.printTrace("EventSet: SUSPEND_EVENT_THREAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                case JDWP.SuspendPolicy.NONE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                    vm.printTrace("EventSet: SUSPEND_NONE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                    break;
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
        ThreadReference fix6485605 = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        for (int i = 0; i < compEvt.events.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            EventImpl evt = createEvent(compEvt.events[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            if ((vm.traceFlags & vm.TRACE_EVENTS) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                    vm.printTrace("Event: " + evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                } catch (VMDisconnectedException ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                    // ignore - see bug 6502716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            switch (evt.destination()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                case UNKNOWN_EVENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                    // Ignore disabled, deleted, unknown events, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                    // save the thread if there is one since we might
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                    // have to resume it.  Note that events for different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                    // threads can't be in the same event set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                    if (evt instanceof ThreadedEventImpl &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                        suspendPolicy == JDWP.SuspendPolicy.EVENT_THREAD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                        fix6485605 = ((ThreadedEventImpl)evt).thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                case CLIENT_EVENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                    addEvent(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                case INTERNAL_EVENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                    if (internalEventSet == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                        internalEventSet = new EventSetImpl(this.vm, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                    internalEventSet.addEvent(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                    throw new InternalException("Invalid event destination");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        pkt = null; // No longer needed - free it up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        // Avoid hangs described in 6296125, 6293795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        if (super.size() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            // This set has no client events.  If we don't do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
            // needed resumes, no one else is going to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            if (suspendPolicy == JDWP.SuspendPolicy.ALL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                vm.resume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            } else if (suspendPolicy == JDWP.SuspendPolicy.EVENT_THREAD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                // See bug 6485605.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                if (fix6485605 != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                    fix6485605.resume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                    // apparently, there is nothing to resume.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            suspendPolicy = JDWP.SuspendPolicy.NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * Filter out internal events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    EventSet userFilter() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * Filter out user events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    EventSet internalFilter() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        return this.internalEventSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    EventImpl createEvent(JDWP.Event.Composite.Events evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        JDWP.Event.Composite.Events.EventsCommon comm = evt.aEventsCommon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        switch (evt.eventKind) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
            case JDWP.EventKind.THREAD_START:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
                return new ThreadStartEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                      (JDWP.Event.Composite.Events.ThreadStart)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            case JDWP.EventKind.THREAD_END:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                return new ThreadDeathEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                      (JDWP.Event.Composite.Events.ThreadDeath)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            case JDWP.EventKind.EXCEPTION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                return new ExceptionEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                      (JDWP.Event.Composite.Events.Exception)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            case JDWP.EventKind.BREAKPOINT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                return new BreakpointEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                      (JDWP.Event.Composite.Events.Breakpoint)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            case JDWP.EventKind.METHOD_ENTRY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                return new MethodEntryEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                      (JDWP.Event.Composite.Events.MethodEntry)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
            case JDWP.EventKind.METHOD_EXIT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                return new MethodExitEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                      (JDWP.Event.Composite.Events.MethodExit)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
            case JDWP.EventKind.METHOD_EXIT_WITH_RETURN_VALUE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                return new MethodExitEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                      (JDWP.Event.Composite.Events.MethodExitWithReturnValue)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
            case JDWP.EventKind.FIELD_ACCESS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                return new AccessWatchpointEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                      (JDWP.Event.Composite.Events.FieldAccess)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
            case JDWP.EventKind.FIELD_MODIFICATION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                return new ModificationWatchpointEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                      (JDWP.Event.Composite.Events.FieldModification)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
            case JDWP.EventKind.SINGLE_STEP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                return new StepEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                      (JDWP.Event.Composite.Events.SingleStep)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            case JDWP.EventKind.CLASS_PREPARE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                return new ClassPrepareEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                      (JDWP.Event.Composite.Events.ClassPrepare)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
            case JDWP.EventKind.CLASS_UNLOAD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                return new ClassUnloadEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                      (JDWP.Event.Composite.Events.ClassUnload)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
            case JDWP.EventKind.MONITOR_CONTENDED_ENTER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                return new MonitorContendedEnterEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                      (JDWP.Event.Composite.Events.MonitorContendedEnter)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            case JDWP.EventKind.MONITOR_CONTENDED_ENTERED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                return new MonitorContendedEnteredEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                      (JDWP.Event.Composite.Events.MonitorContendedEntered)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
            case JDWP.EventKind.MONITOR_WAIT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                return new MonitorWaitEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                      (JDWP.Event.Composite.Events.MonitorWait)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
            case JDWP.EventKind.MONITOR_WAITED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                return new MonitorWaitedEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                      (JDWP.Event.Composite.Events.MonitorWaited)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            case JDWP.EventKind.VM_START:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                return new VMStartEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                      (JDWP.Event.Composite.Events.VMStart)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
            case JDWP.EventKind.VM_DEATH:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                return new VMDeathEventImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                      (JDWP.Event.Composite.Events.VMDeath)comm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                // Ignore unknown event types
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                System.err.println("Ignoring event cmd " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                                   evt.eventKind + " from the VM");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    public VirtualMachine virtualMachine() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        return vm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    public int suspendPolicy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        return EventRequestManagerImpl.JDWPtoJDISuspendPolicy(suspendPolicy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    private ThreadReference eventThread() {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   788
        for (Event event : this) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
            if (event instanceof ThreadedEventImpl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                return ((ThreadedEventImpl)event).thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    public void resume() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        switch (suspendPolicy()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            case EventRequest.SUSPEND_ALL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                vm.resume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            case EventRequest.SUSPEND_EVENT_THREAD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                ThreadReference thread = eventThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                if (thread == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                    throw new InternalException("Inconsistent suspend policy");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                thread.resume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
            case EventRequest.SUSPEND_NONE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                // Do nothing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                throw new InternalException("Invalid suspend policy");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    public Iterator<Event> iterator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        return new Itr();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    public EventIterator eventIterator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        return new Itr();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
    public class Itr implements EventIterator {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
         * Index of element to be returned by subsequent call to next.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        int cursor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        public boolean hasNext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
            return cursor != size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        public Event next() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                Event nxt = get(cursor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                ++cursor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                return nxt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
            } catch(IndexOutOfBoundsException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                throw new NoSuchElementException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        public Event nextEvent() {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   845
            return next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        public void remove() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    /* below make this unmodifiable */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    public boolean add(Event o){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    public boolean remove(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    public boolean addAll(Collection<? extends Event> coll) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    public boolean removeAll(Collection<?> coll) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    public boolean retainAll(Collection<?> coll) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
    public void clear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
}