jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 51 6fe31bc95bbc
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
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.connect.spi.Connection;
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
import com.sun.jdi.request.BreakpointRequest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import com.sun.jdi.event.EventQueue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.text.MessageFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.lang.ref.ReferenceQueue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.lang.ref.Reference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.lang.ref.SoftReference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.lang.ref.WeakReference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
class VirtualMachineImpl extends MirrorImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
             implements PathSearchingVirtualMachine, ThreadListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    // VM Level exported variables, these
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    // are unique to a given vm
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    public final int sizeofFieldRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    public final int sizeofMethodRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    public final int sizeofObjectRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    public final int sizeofClassRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    public final int sizeofFrameRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    final int sequenceNumber;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private final TargetVM target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private final EventQueueImpl eventQueue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private final EventRequestManagerImpl internalEventRequestManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private final EventRequestManagerImpl eventRequestManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    final VirtualMachineManagerImpl vmManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private final ThreadGroup threadGroupForJDI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    // Allow direct access to this field so that that tracing code slows down
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    // JDI as little as possible when not enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    int traceFlags = TRACE_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    static int TRACE_RAW_SENDS     = 0x01000000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    static int TRACE_RAW_RECEIVES  = 0x02000000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    boolean traceReceives = false;   // pre-compute because of frequency
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    // ReferenceType access - updated with class prepare and unload events
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    // Protected by "synchronized(this)". "retrievedAllTypes" may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    // tested unsynchronized (since once true, it stays true), but must
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    // be set synchronously
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private Map<Long, ReferenceType> typesByID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private TreeSet<ReferenceType> typesBySignature;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private boolean retrievedAllTypes = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    // For other languages support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    private String defaultStratum = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    // ObjectReference cache
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    // "objectsByID" protected by "synchronized(this)".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private final Map<Long, SoftObjectReference> objectsByID = new HashMap<Long, SoftObjectReference>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    private final ReferenceQueue<ObjectReferenceImpl> referenceQueue = new ReferenceQueue<ObjectReferenceImpl>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    static private final int DISPOSE_THRESHOLD = 50;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    private final List<SoftObjectReference> batchedDisposeRequests =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            Collections.synchronizedList(new ArrayList<SoftObjectReference>(DISPOSE_THRESHOLD + 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    // These are cached once for the life of the VM
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private JDWP.VirtualMachine.Version versionInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private JDWP.VirtualMachine.ClassPaths pathInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    private JDWP.VirtualMachine.Capabilities capabilities = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private JDWP.VirtualMachine.CapabilitiesNew capabilitiesNew = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    // Per-vm singletons for primitive types and for void.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    // singleton-ness protected by "synchronized(this)".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private BooleanType theBooleanType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    private ByteType    theByteType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    private CharType    theCharType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private ShortType   theShortType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private IntegerType theIntegerType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    private LongType    theLongType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private FloatType   theFloatType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    private DoubleType  theDoubleType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    private VoidType    theVoidType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    private VoidValue voidVal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    // Launched debuggee process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    private Process process;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    // coordinates state changes and corresponding listener notifications
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    private VMState state = new VMState(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    private Object initMonitor = new Object();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    private boolean initComplete = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    private boolean shutdown = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    private void notifyInitCompletion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        synchronized(initMonitor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            initComplete = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            initMonitor.notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    void waitInitCompletion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        synchronized(initMonitor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            while (!initComplete) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                    initMonitor.wait();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                } catch (InterruptedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                    // ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    VMState state() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        return state;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * ThreadListener implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public boolean threadResumable(ThreadAction action) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
         * If any thread is resumed, the VM is considered not suspended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        state.thaw();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    VirtualMachineImpl(VirtualMachineManager manager,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                       Connection connection, Process process,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                       int sequenceNumber) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        super(null);  // Can't use super(this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        vm = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        this.vmManager = (VirtualMachineManagerImpl)manager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        this.process = process;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        this.sequenceNumber = sequenceNumber;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        /* Create ThreadGroup to be used by all threads servicing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
         * this VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        threadGroupForJDI = new ThreadGroup(vmManager.mainGroupForJDI(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                            "JDI [" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                            this.hashCode() + "]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
         * Set up a thread to communicate with the target VM over
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
         * the specified transport.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        target = new TargetVM(this, connection);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
         * Set up a thread to handle events processed internally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
         * the JDI implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        EventQueueImpl internalEventQueue = new EventQueueImpl(this, target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        new InternalEventHandler(this, internalEventQueue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
         * Initialize client access to event setting and handling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        eventQueue = new EventQueueImpl(this, target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        eventRequestManager = new EventRequestManagerImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        target.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
         * Many ids are variably sized, depending on target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
         * Find out the sizes right away.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        JDWP.VirtualMachine.IDSizes idSizes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            idSizes = JDWP.VirtualMachine.IDSizes.process(vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        sizeofFieldRef  = idSizes.fieldIDSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        sizeofMethodRef = idSizes.methodIDSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        sizeofObjectRef = idSizes.objectIDSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        sizeofClassRef = idSizes.referenceTypeIDSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        sizeofFrameRef  = idSizes.frameIDSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
         * Set up requests needed by internal event handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
         * Make sure they are distinguished by creating them with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
         * an internal event request manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
         * Warning: create events only with SUSPEND_NONE policy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
         * In the current implementation other policies will not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
         * be handled correctly when the event comes in. (notfiySuspend()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
         * will not be properly called, and if the event is combined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
         * with external events in the same set, suspend policy is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
         * correctly determined for the internal vs. external event sets)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        internalEventRequestManager = new EventRequestManagerImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        EventRequest er = internalEventRequestManager.createClassPrepareRequest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        er.setSuspendPolicy(EventRequest.SUSPEND_NONE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        er.enable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        er = internalEventRequestManager.createClassUnloadRequest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        er.setSuspendPolicy(EventRequest.SUSPEND_NONE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        er.enable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
         * Tell other threads, notably TargetVM, that initialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
         * is complete.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        notifyInitCompletion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    EventRequestManagerImpl getInternalEventRequestManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        return internalEventRequestManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    void validateVM() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
         * We no longer need to do this.  The spec now says
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
         * that a VMDisconnected _may_ be thrown in these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
         * cases, not that it _will_ be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
         * So, to simplify things we will just let the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
         * caller's of this method proceed with their business.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
         * If the debuggee is disconnected, either because it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
         * crashed or finished or something, or because the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
         * debugger called exit() or dispose(), then if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
         * we end up trying to communicate with the debuggee,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
         * code in TargetVM will throw a VMDisconnectedException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
         * This means that if we can satisfy a request without
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
         * talking to the debuggee, (eg, with cached data) then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
         * VMDisconnectedException will _not_ be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
         * if (shutdown) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
         *    throw new VMDisconnectedException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
         * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        return this == obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        return System.identityHashCode(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    public List<ReferenceType> classesByName(String className) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        String signature = JNITypeParser.typeNameToSignature(className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        List<ReferenceType> list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        if (retrievedAllTypes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
           list = findReferenceTypes(signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
           list = retrieveClassesBySignature(signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        return Collections.unmodifiableList(list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    public List<ReferenceType> allClasses() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        if (!retrievedAllTypes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            retrieveAllClasses();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        ArrayList<ReferenceType> a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            a = new ArrayList<ReferenceType>(typesBySignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        return Collections.unmodifiableList(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    public void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        redefineClasses(Map<? extends ReferenceType,byte[]> classToBytes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        int cnt = classToBytes.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        JDWP.VirtualMachine.RedefineClasses.ClassDef[] defs =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            new JDWP.VirtualMachine.RedefineClasses.ClassDef[cnt];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        if (!canRedefineClasses()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        Iterator it = classToBytes.entrySet().iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        for (int i = 0; it.hasNext(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            Map.Entry entry = (Map.Entry)it.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            ReferenceTypeImpl refType = (ReferenceTypeImpl)entry.getKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            validateMirror(refType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            defs[i] = new JDWP.VirtualMachine.RedefineClasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                       .ClassDef(refType, (byte[])entry.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        // flush caches and disable caching until the next suspend
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        vm.state().thaw();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            JDWP.VirtualMachine.RedefineClasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                process(vm, defs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            switch (exc.errorCode()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            case JDWP.Error.INVALID_CLASS_FORMAT :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                throw new ClassFormatError(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                        "class not in class file format");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            case JDWP.Error.CIRCULAR_CLASS_DEFINITION :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                throw new ClassCircularityError(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
       "circularity has been detected while initializing a class");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            case JDWP.Error.FAILS_VERIFICATION :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                throw new VerifyError(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
   "verifier detected internal inconsistency or security problem");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            case JDWP.Error.UNSUPPORTED_VERSION :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                throw new UnsupportedClassVersionError(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                    "version numbers of class are not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            case JDWP.Error.ADD_METHOD_NOT_IMPLEMENTED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                              "add method not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            case JDWP.Error.SCHEMA_CHANGE_NOT_IMPLEMENTED :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                              "schema change not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            case JDWP.Error.HIERARCHY_CHANGE_NOT_IMPLEMENTED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                              "hierarchy change not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            case JDWP.Error.DELETE_METHOD_NOT_IMPLEMENTED :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                              "delete method not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            case JDWP.Error.CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                       "changes to class modifiers not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            case JDWP.Error.METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                       "changes to method modifiers not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            case JDWP.Error.NAMES_DONT_MATCH :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                throw new NoClassDefFoundError(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                              "class names do not match");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        // Delete any record of the breakpoints
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        List<BreakpointRequest> toDelete = new ArrayList<BreakpointRequest>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        EventRequestManager erm = eventRequestManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        it = erm.breakpointRequests().iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        while (it.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            BreakpointRequest req = (BreakpointRequest)it.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            if (classToBytes.containsKey(req.location().declaringType())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                toDelete.add(req);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        erm.deleteEventRequests(toDelete);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        // Invalidate any information cached for the classes just redefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        it = classToBytes.keySet().iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        while (it.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            ReferenceTypeImpl rti = (ReferenceTypeImpl)it.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            rti.noticeRedefineClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    public List<ThreadReference> allThreads() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        return state.allThreads();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    public List<ThreadGroupReference> topLevelThreadGroups() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        return state.topLevelThreadGroups();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * Sends a command to the back end which is defined to do an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * implicit vm-wide resume. The VM can no longer be considered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * suspended, so certain cached data must be invalidated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    PacketStream sendResumingCommand(CommandSender sender) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        return state.thawCommand(sender);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * The VM has been suspended. Additional caching can be done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * as long as there are no pending resumes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    void notifySuspend() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        state.freeze();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    public void suspend() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            JDWP.VirtualMachine.Suspend.process(vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        notifySuspend();
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 void resume() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        CommandSender sender =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            new CommandSender() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                public PacketStream send() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                    return JDWP.VirtualMachine.Resume.enqueueCommand(vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            PacketStream stream = state.thawCommand(sender);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            JDWP.VirtualMachine.Resume.waitForReply(vm, stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        } catch (VMDisconnectedException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
             * If the debugger makes a VMDeathRequest with SUSPEND_ALL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
             * then when it does an EventSet.resume after getting the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
             * VMDeathEvent, the normal flow of events is that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
             * BE shuts down, but the waitForReply comes back ok.  In this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
             * case, the run loop in TargetVM that is waiting for a packet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
             * gets an EOF because the socket closes. It generates a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
             * VMDisconnectedEvent and everyone is happy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
             * However, sometimes, the BE gets shutdown before this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
             * waitForReply completes.  In this case, TargetVM.waitForReply
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
             * gets awakened with no reply and so gens a VMDisconnectedException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
             * which is not what we want.  It might be possible to fix this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
             * in the BE, but it is ok to just ignore the VMDisconnectedException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
             * here.  This will allow the VMDisconnectedEvent to be generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
             * correctly.  And, if the debugger should happen to make another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
             * request, it will get a VMDisconnectedException at that time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            switch (exc.errorCode()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                case JDWP.Error.VM_DEAD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                    throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    public EventQueue eventQueue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
         * No VM validation here. We allow access to the event queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
         * after disconnection, so that there is access to the terminating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
         * events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        return eventQueue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    public EventRequestManager eventRequestManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        return eventRequestManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    EventRequestManagerImpl eventRequestManagerImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        return eventRequestManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    public BooleanValue mirrorOf(boolean value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        return new BooleanValueImpl(this,value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    public ByteValue mirrorOf(byte value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        return new ByteValueImpl(this,value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    public CharValue mirrorOf(char value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        return new CharValueImpl(this,value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    public ShortValue mirrorOf(short value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        return new ShortValueImpl(this,value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    public IntegerValue mirrorOf(int value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        return new IntegerValueImpl(this,value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    public LongValue mirrorOf(long value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        return new LongValueImpl(this,value);
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 FloatValue mirrorOf(float value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        return new FloatValueImpl(this,value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    public DoubleValue mirrorOf(double value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        return new DoubleValueImpl(this,value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    public StringReference mirrorOf(String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            return (StringReference)JDWP.VirtualMachine.CreateString.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                             process(vm, value).stringObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            throw exc.toJDIException();
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
    public VoidValue mirrorOfVoid() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        if (voidVal == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            voidVal = new VoidValueImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        return voidVal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    public long[] instanceCounts(List<? extends ReferenceType> classes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        if (!canGetInstanceInfo()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                "target does not support getting instances");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        long[] retValue ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        ReferenceTypeImpl[] rtArray = new ReferenceTypeImpl[classes.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        int ii = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        for (ReferenceType rti: classes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            validateMirror(rti);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            rtArray[ii++] = (ReferenceTypeImpl)rti;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            retValue = JDWP.VirtualMachine.InstanceCounts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                                process(vm, rtArray).counts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        return retValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        shutdown = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            JDWP.VirtualMachine.Dispose.process(vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        target.stopListening();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    public void exit(int exitCode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        shutdown = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            JDWP.VirtualMachine.Exit.process(vm, exitCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        target.stopListening();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    public Process process() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        return process;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    private JDWP.VirtualMachine.Version versionInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
       try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
           if (versionInfo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
               // Need not be synchronized since it is static information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
               versionInfo = JDWP.VirtualMachine.Version.process(vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
           }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
           return versionInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
       } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
           throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    public String description() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        return MessageFormat.format(vmManager.getString("version_format"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                                    "" + vmManager.majorInterfaceVersion(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                                    "" + vmManager.minorInterfaceVersion(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                                     versionInfo().description);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    public String version() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        return versionInfo().vmVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    public String name() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        return versionInfo().vmName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    public boolean canWatchFieldModification() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        return capabilities().canWatchFieldModification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    public boolean canWatchFieldAccess() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        return capabilities().canWatchFieldAccess;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    public boolean canGetBytecodes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        return capabilities().canGetBytecodes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    public boolean canGetSyntheticAttribute() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        return capabilities().canGetSyntheticAttribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    public boolean canGetOwnedMonitorInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        return capabilities().canGetOwnedMonitorInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    public boolean canGetCurrentContendedMonitor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        return capabilities().canGetCurrentContendedMonitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    public boolean canGetMonitorInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        return capabilities().canGetMonitorInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    private boolean hasNewCapabilities() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        return versionInfo().jdwpMajor > 1 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            versionInfo().jdwpMinor >= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    boolean canGet1_5LanguageFeatures() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        return versionInfo().jdwpMajor > 1 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            versionInfo().jdwpMinor >= 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    public boolean canUseInstanceFilters() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            capabilitiesNew().canUseInstanceFilters;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    public boolean canRedefineClasses() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
            capabilitiesNew().canRedefineClasses;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    public boolean canAddMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
            capabilitiesNew().canAddMethod;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    public boolean canUnrestrictedlyRedefineClasses() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            capabilitiesNew().canUnrestrictedlyRedefineClasses;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    public boolean canPopFrames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            capabilitiesNew().canPopFrames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    public boolean canGetMethodReturnValues() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        return versionInfo().jdwpMajor > 1 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            versionInfo().jdwpMinor >= 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    public boolean canGetInstanceInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        if (versionInfo().jdwpMajor < 1 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
            versionInfo().jdwpMinor < 6) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
            capabilitiesNew().canGetInstanceInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    public boolean canUseSourceNameFilters() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        if (versionInfo().jdwpMajor < 1 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            versionInfo().jdwpMinor < 6) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    public boolean canForceEarlyReturn() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            capabilitiesNew().canForceEarlyReturn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    public boolean canBeModified() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    public boolean canGetSourceDebugExtension() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
            capabilitiesNew().canGetSourceDebugExtension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    public boolean canGetClassFileVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        if ( versionInfo().jdwpMajor < 1 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
             versionInfo().jdwpMinor  < 6) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    public boolean canGetConstantPool() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            capabilitiesNew().canGetConstantPool;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    public boolean canRequestVMDeathEvent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
            capabilitiesNew().canRequestVMDeathEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    public boolean canRequestMonitorEvents() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
            capabilitiesNew().canRequestMonitorEvents;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    public boolean canGetMonitorFrameInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        return hasNewCapabilities() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            capabilitiesNew().canGetMonitorFrameInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    public void setDebugTraceMode(int traceFlags) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        validateVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        this.traceFlags = traceFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        this.traceReceives = (traceFlags & TRACE_RECEIVES) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    void printTrace(String string) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        System.err.println("[JDI: " + string + "]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    void printReceiveTrace(int depth, String string) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        StringBuffer sb = new StringBuffer("Receiving:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        for (int i = depth; i > 0; --i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
            sb.append("    ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        sb.append(string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        printTrace(sb.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    private synchronized ReferenceTypeImpl addReferenceType(long id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                                                       int tag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                                                       String signature) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        if (typesByID == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
            initReferenceTypes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        ReferenceTypeImpl type = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        switch(tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
            case JDWP.TypeTag.CLASS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                type = new ClassTypeImpl(vm, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            case JDWP.TypeTag.INTERFACE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                type = new InterfaceTypeImpl(vm, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            case JDWP.TypeTag.ARRAY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                type = new ArrayTypeImpl(vm, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                throw new InternalException("Invalid reference type tag");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
         * If a signature was specified, make sure to set it ASAP, to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
         * prevent any needless JDWP command to retrieve it. (for example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
         * typesBySignature.add needs the signature, to maintain proper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
         * ordering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        if (signature != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
            type.setSignature(signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        typesByID.put(new Long(id), type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        typesBySignature.add(type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
           vm.printTrace("Caching new ReferenceType, sig=" + signature +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                         ", id=" + id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        return type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    synchronized void removeReferenceType(String signature) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        if (typesByID == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
         * There can be multiple classes with the same name. Since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
         * we can't differentiate here, we first remove all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
         * matching classes from our cache...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        Iterator iter = typesBySignature.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        int matches = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
            ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
            int comp = signature.compareTo(type.signature());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
            if (comp == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                matches++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                iter.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                typesByID.remove(new Long(type.ref()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                   vm.printTrace("Uncaching ReferenceType, sig=" + signature +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                                 ", id=" + type.ref());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
/* fix for 4359077 , don't break out. list is no longer sorted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        in the order we think
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
         * ...and if there was more than one, re-retrieve the classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
         * with that name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        if (matches > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            retrieveClassesBySignature(signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    private synchronized List<ReferenceType> findReferenceTypes(String signature) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        if (typesByID == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
            return new ArrayList<ReferenceType>(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        Iterator iter = typesBySignature.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        List<ReferenceType> list = new ArrayList<ReferenceType>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
            ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
            int comp = signature.compareTo(type.signature());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
            if (comp == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                list.add(type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
/* fix for 4359077 , don't break out. list is no longer sorted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        in the order we think
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        return list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    private void initReferenceTypes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        typesByID = new HashMap<Long, ReferenceType>(300);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        typesBySignature = new TreeSet<ReferenceType>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    ReferenceTypeImpl referenceType(long ref, byte tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        return referenceType(ref, tag, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    ClassTypeImpl classType(long ref) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        return (ClassTypeImpl)referenceType(ref, JDWP.TypeTag.CLASS, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    InterfaceTypeImpl interfaceType(long ref) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        return (InterfaceTypeImpl)referenceType(ref, JDWP.TypeTag.INTERFACE, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    ArrayTypeImpl arrayType(long ref) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        return (ArrayTypeImpl)referenceType(ref, JDWP.TypeTag.ARRAY, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    ReferenceTypeImpl referenceType(long id, int tag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                                                 String signature) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
            StringBuffer sb = new StringBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            sb.append("Looking up ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            if (tag == JDWP.TypeTag.CLASS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                sb.append("Class");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
            } else if (tag == JDWP.TypeTag.INTERFACE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
                sb.append("Interface");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            } else if (tag == JDWP.TypeTag.ARRAY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                sb.append("ArrayType");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
                sb.append("UNKNOWN TAG: " + tag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
            if (signature != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
                sb.append(", signature='" + signature + "'");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
            sb.append(", id=" + id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            vm.printTrace(sb.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        if (id == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
            ReferenceTypeImpl retType = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
            synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
                if (typesByID != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
                    retType = (ReferenceTypeImpl)typesByID.get(new Long(id));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                if (retType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                    retType = addReferenceType(id, tag, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
            return retType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    private JDWP.VirtualMachine.Capabilities capabilities() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        if (capabilities == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                capabilities = JDWP.VirtualMachine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                                 .Capabilities.process(vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
        return capabilities;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
    private JDWP.VirtualMachine.CapabilitiesNew capabilitiesNew() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        if (capabilitiesNew == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                capabilitiesNew = JDWP.VirtualMachine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                                 .CapabilitiesNew.process(vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
            } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        return capabilitiesNew;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    private List<ReferenceType> retrieveClassesBySignature(String signature) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            vm.printTrace("Retrieving matching ReferenceTypes, sig=" + signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        JDWP.VirtualMachine.ClassesBySignature.ClassInfo[] cinfos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
            cinfos = JDWP.VirtualMachine.ClassesBySignature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                                      process(vm, signature).classes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
            throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
        int count = cinfos.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        List<ReferenceType> list = new ArrayList<ReferenceType>(count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        // Hold lock during processing to improve performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            for (int i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                JDWP.VirtualMachine.ClassesBySignature.ClassInfo ci =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                                                               cinfos[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                ReferenceTypeImpl type = referenceType(ci.typeID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
                                                       ci.refTypeTag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
                                                       signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                type.setStatus(ci.status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                list.add(type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        return list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
    private void retrieveAllClasses1_4() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        JDWP.VirtualMachine.AllClasses.ClassInfo[] cinfos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
            cinfos = JDWP.VirtualMachine.AllClasses.process(vm).classes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
            throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
        // Hold lock during processing to improve performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        // and to have safe check/set of retrievedAllTypes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
            if (!retrievedAllTypes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                // Number of classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                int count = cinfos.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                for (int i=0; i<count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                    JDWP.VirtualMachine.AllClasses.ClassInfo ci =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                                                               cinfos[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                    ReferenceTypeImpl type = referenceType(ci.typeID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                                                           ci.refTypeTag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                                                           ci.signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
                    type.setStatus(ci.status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
                retrievedAllTypes = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
    private void retrieveAllClasses() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
        if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
            vm.printTrace("Retrieving all ReferenceTypes");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
        if (!vm.canGet1_5LanguageFeatures()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
            retrieveAllClasses1_4();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
         * To save time (assuming the caller will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
         * using then) we will get the generic sigs too.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        JDWP.VirtualMachine.AllClassesWithGeneric.ClassInfo[] cinfos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
            cinfos = JDWP.VirtualMachine.AllClassesWithGeneric.process(vm).classes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
            throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
        // Hold lock during processing to improve performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
        // and to have safe check/set of retrievedAllTypes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
            if (!retrievedAllTypes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
                // Number of classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                int count = cinfos.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                for (int i=0; i<count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
                    JDWP.VirtualMachine.AllClassesWithGeneric.ClassInfo ci =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
                                                               cinfos[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
                    ReferenceTypeImpl type = referenceType(ci.typeID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
                                                           ci.refTypeTag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                                                           ci.signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
                    type.setGenericSignature(ci.genericSignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
                    type.setStatus(ci.status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
                retrievedAllTypes = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
    void sendToTarget(Packet packet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
        target.send(packet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
    void waitForTargetReply(Packet packet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        target.waitForReply(packet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
         * If any object disposes have been batched up, send them now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
        processBatchedDisposes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
    Type findBootType(String signature) throws ClassNotLoadedException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
        List types = allClasses();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
        Iterator iter = types.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
            ReferenceType type = (ReferenceType)iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
            if ((type.classLoader() == null) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
                (type.signature().equals(signature))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
                return type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        JNITypeParser parser = new JNITypeParser(signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        throw new ClassNotLoadedException(parser.typeName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                                         "Type " + parser.typeName() + " not loaded");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
    BooleanType theBooleanType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
        if (theBooleanType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
                if (theBooleanType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                    theBooleanType = new BooleanTypeImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
        return theBooleanType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
    ByteType theByteType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
        if (theByteType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                if (theByteType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                    theByteType = new ByteTypeImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
        return theByteType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
    CharType theCharType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
        if (theCharType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                if (theCharType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
                    theCharType = new CharTypeImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
        return theCharType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
    ShortType theShortType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
        if (theShortType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                if (theShortType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
                    theShortType = new ShortTypeImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
        return theShortType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
    IntegerType theIntegerType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
        if (theIntegerType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
                if (theIntegerType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
                    theIntegerType = new IntegerTypeImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        return theIntegerType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
    LongType theLongType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
        if (theLongType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
                if (theLongType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
                    theLongType = new LongTypeImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
        return theLongType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
    FloatType theFloatType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
        if (theFloatType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
                if (theFloatType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
                    theFloatType = new FloatTypeImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
        return theFloatType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
    DoubleType theDoubleType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
        if (theDoubleType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
                if (theDoubleType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
                    theDoubleType = new DoubleTypeImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
        return theDoubleType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
    VoidType theVoidType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        if (theVoidType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
                if (theVoidType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
                    theVoidType = new VoidTypeImpl(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
        return theVoidType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
    PrimitiveType primitiveTypeMirror(byte tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
        switch (tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
            case JDWP.Tag.BOOLEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
                return theBooleanType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
            case JDWP.Tag.BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
                return theByteType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
            case JDWP.Tag.CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
                return theCharType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
            case JDWP.Tag.SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
                return theShortType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
            case JDWP.Tag.INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
                return theIntegerType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
            case JDWP.Tag.LONG:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
                return theLongType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
            case JDWP.Tag.FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
                return theFloatType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
            case JDWP.Tag.DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
                return theDoubleType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
                throw new IllegalArgumentException("Unrecognized primitive tag " + tag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
    private void processBatchedDisposes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
        if (shutdown) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
        JDWP.VirtualMachine.DisposeObjects.Request[] requests = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        synchronized(batchedDisposeRequests) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
            int size = batchedDisposeRequests.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
            if (size >= DISPOSE_THRESHOLD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
                if ((traceFlags & TRACE_OBJREFS) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
                    printTrace("Dispose threashold reached. Will dispose "
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
                               + size + " object references...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
                requests = new JDWP.VirtualMachine.DisposeObjects.Request[size];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
                for (int i = 0; i < requests.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
                    SoftObjectReference ref =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
                        (SoftObjectReference)batchedDisposeRequests.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
                    if ((traceFlags & TRACE_OBJREFS) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
                        printTrace("Disposing object " + ref.key().longValue() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
                                   " (ref count = " + ref.count() + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
                    // This is kludgy. We temporarily re-create an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
                    // reference so that we can correctly pass its id to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
                    // JDWP command.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
                    requests[i] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
                        new JDWP.VirtualMachine.DisposeObjects.Request(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
                            new ObjectReferenceImpl(this, ref.key().longValue()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
                            ref.count());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
                batchedDisposeRequests.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
        if (requests != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
                JDWP.VirtualMachine.DisposeObjects.process(vm, requests);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
            } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
                throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
    private void batchForDispose(SoftObjectReference ref) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
        if ((traceFlags & TRACE_OBJREFS) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
            printTrace("Batching object " + ref.key().longValue() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
                       " for dispose (ref count = " + ref.count() + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
        batchedDisposeRequests.add(ref);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
    private void processQueue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
        Reference ref;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
        //if ((traceFlags & TRACE_OBJREFS) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
        //    printTrace("Checking for softly reachable objects");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
        //}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
        while ((ref = referenceQueue.poll()) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
            SoftObjectReference softRef = (SoftObjectReference)ref;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
            removeObjectMirror(softRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
            batchForDispose(softRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
    synchronized ObjectReferenceImpl objectMirror(long id, int tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
        // Handle any queue elements that are not strongly reachable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
        processQueue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        if (id == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
        ObjectReferenceImpl object = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        Long key = new Long(id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
         * Attempt to retrieve an existing object object reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
        SoftObjectReference ref = objectsByID.get(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
        if (ref != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
            object = ref.object();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
         * If the object wasn't in the table, or it's soft reference was
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
         * cleared, create a new instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
        if (object == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
            switch (tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
                case JDWP.Tag.OBJECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
                    object = new ObjectReferenceImpl(vm, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
                case JDWP.Tag.STRING:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
                    object = new StringReferenceImpl(vm, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
                case JDWP.Tag.ARRAY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
                    object = new ArrayReferenceImpl(vm, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
                case JDWP.Tag.THREAD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
                    ThreadReferenceImpl thread =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
                        new ThreadReferenceImpl(vm, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
                    thread.addListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
                    object = thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
                case JDWP.Tag.THREAD_GROUP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
                    object = new ThreadGroupReferenceImpl(vm, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
                case JDWP.Tag.CLASS_LOADER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
                    object = new ClassLoaderReferenceImpl(vm, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
                case JDWP.Tag.CLASS_OBJECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
                    object = new ClassObjectReferenceImpl(vm, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
                    throw new IllegalArgumentException("Invalid object tag: " + tag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
            ref = new SoftObjectReference(key, object, referenceQueue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
             * If there was no previous entry in the table, we add one here
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
             * If the previous entry was cleared, we replace it here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
            objectsByID.put(key, ref);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
            if ((traceFlags & TRACE_OBJREFS) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
                printTrace("Creating new " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
                           object.getClass().getName() + " (id = " + id + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
            ref.incrementCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
        return object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
    synchronized void removeObjectMirror(ObjectReferenceImpl object) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
        // Handle any queue elements that are not strongly reachable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
        processQueue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
        SoftObjectReference ref = objectsByID.remove(new Long(object.ref()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
        if (ref != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
            batchForDispose(ref);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
             * If there's a live ObjectReference about, it better be part
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
             * of the cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
            throw new InternalException("ObjectReference " + object.ref() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
                                        " not found in object cache");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
    synchronized void removeObjectMirror(SoftObjectReference ref) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
         * This will remove the soft reference if it has not been
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
         * replaced in the cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
        objectsByID.remove(ref.key());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
    ObjectReferenceImpl objectMirror(long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
        return objectMirror(id, JDWP.Tag.OBJECT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
    StringReferenceImpl stringMirror(long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
        return (StringReferenceImpl)objectMirror(id, JDWP.Tag.STRING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
    ArrayReferenceImpl arrayMirror(long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
       return (ArrayReferenceImpl)objectMirror(id, JDWP.Tag.ARRAY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
    ThreadReferenceImpl threadMirror(long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
        return (ThreadReferenceImpl)objectMirror(id, JDWP.Tag.THREAD);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
    ThreadGroupReferenceImpl threadGroupMirror(long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
        return (ThreadGroupReferenceImpl)objectMirror(id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
                                                      JDWP.Tag.THREAD_GROUP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
    ClassLoaderReferenceImpl classLoaderMirror(long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
        return (ClassLoaderReferenceImpl)objectMirror(id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
                                                      JDWP.Tag.CLASS_LOADER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
    ClassObjectReferenceImpl classObjectMirror(long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
        return (ClassObjectReferenceImpl)objectMirror(id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
                                                      JDWP.Tag.CLASS_OBJECT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
     * Implementation of PathSearchingVirtualMachine
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
    private JDWP.VirtualMachine.ClassPaths getClasspath() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
        if (pathInfo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
                pathInfo = JDWP.VirtualMachine.ClassPaths.process(vm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
            } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
                throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
        return pathInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
   public List<String> classPath() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
       return Arrays.asList(getClasspath().classpaths);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
   public List<String> bootClassPath() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
       return Arrays.asList(getClasspath().bootclasspaths);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
   public String baseDirectory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
       return getClasspath().baseDir;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
    public void setDefaultStratum(String stratum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
        defaultStratum = stratum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
        if (stratum == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
            stratum = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
            JDWP.VirtualMachine.SetDefaultStratum.process(vm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
                                                          stratum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
        } catch (JDWPException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
            throw exc.toJDIException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
    public String getDefaultStratum() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
        return defaultStratum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
    ThreadGroup threadGroupForJDI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
        return threadGroupForJDI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
   static private class SoftObjectReference extends SoftReference<ObjectReferenceImpl> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
       int count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
       Long key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
       SoftObjectReference(Long key, ObjectReferenceImpl mirror,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
                           ReferenceQueue<ObjectReferenceImpl> queue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
           super(mirror, queue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
           this.count = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
           this.key = key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
       int count() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
           return count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
       void incrementCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
           count++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
       Long key() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
           return key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
       ObjectReferenceImpl object() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
           return (ObjectReferenceImpl)get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
}