jdk/src/share/classes/com/sun/tools/example/debug/tty/EventHandler.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 51 6fe31bc95bbc
child 5506 202f599c92aa
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.example.debug.tty;
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.EventRequestManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import com.sun.jdi.request.EventRequest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.PrintStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.StringTokenizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Collection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class EventHandler implements Runnable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    EventNotifier notifier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    Thread thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    volatile boolean connected = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    boolean completed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    String shutdownMessageKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    boolean stopOnVMStart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    EventHandler(EventNotifier notifier, boolean stopOnVMStart) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        this.notifier = notifier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        this.stopOnVMStart = stopOnVMStart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        this.thread = new Thread(this, "event-handler");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        this.thread.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    synchronized void shutdown() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        connected = false;  // force run() loop termination
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        thread.interrupt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        while (!completed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            try {wait();} catch (InterruptedException exc) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        EventQueue queue = Env.vm().eventQueue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        while (connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                EventSet eventSet = queue.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                boolean resumeStoppedApp = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                EventIterator it = eventSet.eventIterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                while (it.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                    resumeStoppedApp |= !handleEvent(it.nextEvent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                if (resumeStoppedApp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                    eventSet.resume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                } else if (eventSet.suspendPolicy() == EventRequest.SUSPEND_ALL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                    setCurrentThread(eventSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                    notifier.vmInterrupted();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            } catch (InterruptedException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                // Do nothing. Any changes will be seen at top of loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            } catch (VMDisconnectedException discExc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                handleDisconnectedException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            completed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            notifyAll();
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
    private boolean handleEvent(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        notifier.receivedEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        if (event instanceof ExceptionEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            return exceptionEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        } else if (event instanceof BreakpointEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            return breakpointEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        } else if (event instanceof WatchpointEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            return fieldWatchEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        } else if (event instanceof StepEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            return stepEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        } else if (event instanceof MethodEntryEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            return methodEntryEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        } else if (event instanceof MethodExitEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            return methodExitEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        } else if (event instanceof ClassPrepareEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            return classPrepareEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        } else if (event instanceof ClassUnloadEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            return classUnloadEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        } else if (event instanceof ThreadStartEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            return threadStartEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        } else if (event instanceof ThreadDeathEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            return threadDeathEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        } else if (event instanceof VMStartEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            return vmStartEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            return handleExitEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    private boolean vmDied = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    private boolean handleExitEvent(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (event instanceof VMDeathEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            vmDied = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            return vmDeathEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        } else if (event instanceof VMDisconnectEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            connected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            if (!vmDied) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                vmDisconnectEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            Env.shutdown(shutdownMessageKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            throw new InternalError(MessageOutput.format("Unexpected event type",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                                                         new Object[] {event.getClass()}));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    synchronized void handleDisconnectedException() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
         * A VMDisconnectedException has happened while dealing with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
         * another event. We need to flush the event queue, dealing only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
         * with exit events (VMDeath, VMDisconnect) so that we terminate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
         * correctly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        EventQueue queue = Env.vm().eventQueue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        while (connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                EventSet eventSet = queue.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                EventIterator iter = eventSet.eventIterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                while (iter.hasNext()) {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   153
                    handleExitEvent(iter.next());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            } catch (InterruptedException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                // ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            } catch (InternalError exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                // ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    private ThreadReference eventThread(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        if (event instanceof ClassPrepareEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            return ((ClassPrepareEvent)event).thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        } else if (event instanceof LocatableEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            return ((LocatableEvent)event).thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        } else if (event instanceof ThreadStartEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            return ((ThreadStartEvent)event).thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        } else if (event instanceof ThreadDeathEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            return ((ThreadDeathEvent)event).thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        } else if (event instanceof VMStartEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            return ((VMStartEvent)event).thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    private void setCurrentThread(EventSet set) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        ThreadReference thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        if (set.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
             * If any event in the set has a thread associated with it,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
             * they all will, so just grab the first one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
             */
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   186
            Event event = set.iterator().next(); // Is there a better way?
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            thread = eventThread(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            thread = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        setCurrentThread(thread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    private void setCurrentThread(ThreadReference thread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        ThreadInfo.invalidateAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        ThreadInfo.setCurrentThread(thread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    private boolean vmStartEvent(Event event)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        VMStartEvent se = (VMStartEvent)event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        notifier.vmStartEvent(se);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return stopOnVMStart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    private boolean breakpointEvent(Event event)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        BreakpointEvent be = (BreakpointEvent)event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        notifier.breakpointEvent(be);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    private boolean methodEntryEvent(Event event)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        MethodEntryEvent me = (MethodEntryEvent)event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        notifier.methodEntryEvent(me);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    private boolean methodExitEvent(Event event)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        MethodExitEvent me = (MethodExitEvent)event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return notifier.methodExitEvent(me);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    private boolean fieldWatchEvent(Event event)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        WatchpointEvent fwe = (WatchpointEvent)event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        notifier.fieldWatchEvent(fwe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    private boolean stepEvent(Event event)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        StepEvent se = (StepEvent)event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        notifier.stepEvent(se);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    private boolean classPrepareEvent(Event event)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        ClassPrepareEvent cle = (ClassPrepareEvent)event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        notifier.classPrepareEvent(cle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        if (!Env.specList.resolve(cle)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            MessageOutput.lnprint("Stopping due to deferred breakpoint errors.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    private boolean classUnloadEvent(Event event)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        ClassUnloadEvent cue = (ClassUnloadEvent)event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        notifier.classUnloadEvent(cue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    private boolean exceptionEvent(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        ExceptionEvent ee = (ExceptionEvent)event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        notifier.exceptionEvent(ee);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    private boolean threadDeathEvent(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        ThreadDeathEvent tee = (ThreadDeathEvent)event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        ThreadInfo.removeThread(tee.thread());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    private boolean threadStartEvent(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        ThreadStartEvent tse = (ThreadStartEvent)event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        ThreadInfo.addThread(tse.thread());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        notifier.threadStartEvent(tse);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    public boolean vmDeathEvent(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        shutdownMessageKey = "The application exited";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        notifier.vmDeathEvent((VMDeathEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    public boolean vmDisconnectEvent(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        shutdownMessageKey = "The application has been disconnected";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        notifier.vmDisconnectEvent((VMDisconnectEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
}