hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/VirtualMachineImpl.java
author jiangli
Thu, 29 Mar 2012 22:18:56 -0400
changeset 12369 48fd3da4025c
parent 10547 ea4a2ec31ae2
child 13728 882756847a04
permissions -rw-r--r--
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass. Summary: Change implementor to embedded instanceKlass field. Reviewed-by: sspitsyn, minqi, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
12369
48fd3da4025c 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 10547
diff changeset
     2
 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
package sun.jvm.hotspot.jdi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import com.sun.jdi.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
import com.sun.jdi.event.EventQueue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
import com.sun.jdi.request.EventRequestManager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
import sun.jvm.hotspot.HotSpotAgent;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
import sun.jvm.hotspot.types.TypeDataBase;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
import sun.jvm.hotspot.oops.Klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
import sun.jvm.hotspot.oops.InstanceKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
import sun.jvm.hotspot.oops.ArrayKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
import sun.jvm.hotspot.oops.ObjArrayKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
import sun.jvm.hotspot.oops.TypeArrayKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
import sun.jvm.hotspot.oops.Oop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
import sun.jvm.hotspot.oops.Instance;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
import sun.jvm.hotspot.oops.Array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
import sun.jvm.hotspot.oops.ObjArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
import sun.jvm.hotspot.oops.TypeArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
import sun.jvm.hotspot.oops.Symbol;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
import sun.jvm.hotspot.oops.ObjectHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
import sun.jvm.hotspot.oops.JVMDIClassStatus;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
import sun.jvm.hotspot.runtime.VM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
import sun.jvm.hotspot.runtime.JavaThread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
import sun.jvm.hotspot.memory.SystemDictionary;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
import sun.jvm.hotspot.memory.SymbolTable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
import sun.jvm.hotspot.memory.Universe;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
import sun.jvm.hotspot.utilities.Assert;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
import java.util.List;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
import java.util.ArrayList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
import java.util.Map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
import java.util.Iterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
import java.util.Collections;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
import java.util.HashMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
import java.util.Observer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
import java.util.StringTokenizer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
import java.lang.ref.SoftReference;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
import java.lang.ref.ReferenceQueue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
import java.lang.ref.Reference;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
public class VirtualMachineImpl extends MirrorImpl implements PathSearchingVirtualMachine {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    private HotSpotAgent     saAgent = new HotSpotAgent();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    private VM               saVM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    private Universe         saUniverse;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    private SystemDictionary saSystemDictionary;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    private SymbolTable      saSymbolTable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    private ObjectHeap       saObjectHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    VM saVM() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
        return saVM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    SystemDictionary saSystemDictionary() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
        return saSystemDictionary;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    SymbolTable saSymbolTable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
        return saSymbolTable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    Universe saUniverse() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
        return saUniverse;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    ObjectHeap saObjectHeap() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
        return saObjectHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    com.sun.jdi.VirtualMachineManager vmmgr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    private final ThreadGroup             threadGroupForJDI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    // Per-vm singletons for primitive types and for void.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    // singleton-ness protected by "synchronized(this)".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    private BooleanType theBooleanType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    private ByteType    theByteType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    private CharType    theCharType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    private ShortType   theShortType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    private IntegerType theIntegerType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    private LongType    theLongType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    private FloatType   theFloatType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    private DoubleType  theDoubleType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    private VoidType    theVoidType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    private VoidValue voidVal;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    private Map       typesByID;             // Map<Klass, ReferenceTypeImpl>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    private List      typesBySignature;      // List<ReferenceTypeImpl> - used in signature search
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    private boolean   retrievedAllTypes = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    private List      bootstrapClasses;      // all bootstrap classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    private ArrayList allThreads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    private ArrayList topLevelGroups;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    final   int       sequenceNumber;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    // ObjectReference cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    // "objectsByID" protected by "synchronized(this)".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    private final Map            objectsByID = new HashMap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    private final ReferenceQueue referenceQueue = new ReferenceQueue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    // names of some well-known classes to jdi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    private Symbol javaLangString;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    private Symbol javaLangThread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    private Symbol javaLangThreadGroup;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    private Symbol javaLangClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    private Symbol javaLangClassLoader;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    // used in ReferenceTypeImpl.isThrowableBacktraceField
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    private Symbol javaLangThrowable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    // names of classes used in array assignment check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    // refer to ArrayTypeImpl.isAssignableTo
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    private Symbol javaLangObject;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    private Symbol javaLangCloneable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    private Symbol javaIoSerializable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    // symbol used in ClassTypeImpl.isEnum check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    private Symbol javaLangEnum;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    Symbol javaLangObject() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
        return javaLangObject;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    Symbol javaLangCloneable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
        return javaLangCloneable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    Symbol javaIoSerializable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
        return javaIoSerializable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    Symbol javaLangEnum() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
        return javaLangEnum;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    Symbol javaLangThrowable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
        return javaLangThrowable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    // name of the current default stratum
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    private String defaultStratum;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    // initialize known class name symbols
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    private void initClassNameSymbols() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
        SymbolTable st = saSymbolTable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
        javaLangString = st.probe("java/lang/String");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
        javaLangThread = st.probe("java/lang/Thread");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
        javaLangThreadGroup = st.probe("java/lang/ThreadGroup");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
        javaLangClass = st.probe("java/lang/Class");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
        javaLangClassLoader = st.probe("java/lang/ClassLoader");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
        javaLangThrowable = st.probe("java/lang/Throwable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
        javaLangObject = st.probe("java/lang/Object");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
        javaLangCloneable = st.probe("java/lang/Cloneable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
        javaIoSerializable = st.probe("java/io/Serializable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
        javaLangEnum = st.probe("java/lang/Enum");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    private void init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
        saVM = VM.getVM();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
        saUniverse = saVM.getUniverse();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
        saSystemDictionary = saVM.getSystemDictionary();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
        saSymbolTable = saVM.getSymbolTable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
        saObjectHeap = saVM.getObjectHeap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
        initClassNameSymbols();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    static public VirtualMachineImpl createVirtualMachineForCorefile(VirtualMachineManager mgr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
                                                                     String javaExecutableName,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
                                                                     String coreFileName,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
                                                                     int sequenceNumber)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
        throws Exception {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
            Assert.that(coreFileName != null, "SA VirtualMachineImpl: core filename = null is not yet implemented");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
            Assert.that(javaExecutableName != null, "SA VirtualMachineImpl: java executable = null is not yet implemented");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
        VirtualMachineImpl myvm = new VirtualMachineImpl(mgr, sequenceNumber);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
        try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
            myvm.saAgent.attach(javaExecutableName, coreFileName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
            myvm.init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
        } catch (Exception ee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
            myvm.saAgent.detach();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
            throw ee;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
        return myvm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    static public VirtualMachineImpl createVirtualMachineForPID(VirtualMachineManager mgr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
                                                                int pid,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
                                                                int sequenceNumber)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
        throws Exception {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
        VirtualMachineImpl myvm = new VirtualMachineImpl(mgr, sequenceNumber);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
        try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
            myvm.saAgent.attach(pid);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
            myvm.init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
        } catch (Exception ee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
            myvm.saAgent.detach();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
            throw ee;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
        return myvm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    static public VirtualMachineImpl createVirtualMachineForServer(VirtualMachineManager mgr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
                                                                String server,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
                                                                int sequenceNumber)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
        throws Exception {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
            Assert.that(server != null, "SA VirtualMachineImpl: DebugServer = null is not yet implemented");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
        VirtualMachineImpl myvm = new VirtualMachineImpl(mgr, sequenceNumber);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
        try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
            myvm.saAgent.attach(server);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
            myvm.init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
        } catch (Exception ee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
            myvm.saAgent.detach();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
            throw ee;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
        return myvm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    VirtualMachineImpl(VirtualMachineManager mgr, int sequenceNumber)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
        throws Exception {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
        super(null);  // Can't use super(this)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
        vm = this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
        this.sequenceNumber = sequenceNumber;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
        this.vmmgr = mgr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
        /* Create ThreadGroup to be used by all threads servicing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
         * this VM.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
         */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
        threadGroupForJDI = new ThreadGroup("JDI [" +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
                                            this.hashCode() + "]");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
        ((com.sun.tools.jdi.VirtualMachineManagerImpl)mgr).addVirtualMachine(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    // we reflectively use newly spec'ed class because our ALT_BOOTDIR
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    // is 1.4.2 and not 1.5.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    private static Class vmCannotBeModifiedExceptionClass = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    void throwNotReadOnlyException(String operation) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
        RuntimeException re = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
        if (vmCannotBeModifiedExceptionClass == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
            try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
                vmCannotBeModifiedExceptionClass = Class.forName("com.sun.jdi.VMCannotBeModifiedException");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
            } catch (ClassNotFoundException cnfe) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
                vmCannotBeModifiedExceptionClass = UnsupportedOperationException.class;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
        try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
            re = (RuntimeException) vmCannotBeModifiedExceptionClass.newInstance();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
        } catch (Exception exp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
            re = new RuntimeException(exp.getMessage());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
        throw re;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    public boolean equals(Object obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
        // Oh boy; big recursion troubles if we don't have this!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
        // See MirrorImpl.equals
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
        return this == obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
    public int hashCode() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
        // big recursion if we don't have this. See MirrorImpl.hashCode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
        return System.identityHashCode(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    public List classesByName(String className) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
        String signature = JNITypeParser.typeNameToSignature(className);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
        List list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
        if (!retrievedAllTypes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
            retrieveAllClasses();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
        list = findReferenceTypes(signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
        return Collections.unmodifiableList(list);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    public List allClasses() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
        if (!retrievedAllTypes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
            retrieveAllClasses();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
        ArrayList a;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
        synchronized (this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
            a = new ArrayList(typesBySignature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
        return Collections.unmodifiableList(a);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    // classes loaded by bootstrap loader
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    List bootstrapClasses() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
        if (bootstrapClasses == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
            bootstrapClasses = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
            List all = allClasses();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
            for (Iterator itr = all.iterator(); itr.hasNext();) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
               ReferenceType type = (ReferenceType) itr.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
               if (type.classLoader() == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
                   bootstrapClasses.add(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
               }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
        return bootstrapClasses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    private synchronized List findReferenceTypes(String signature) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
        if (typesByID == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
            return new ArrayList(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
        // we haven't sorted types by signatures. But we can take
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
        // advantage of comparing symbols instead of name. In the worst
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
        // case, we will be comparing N addresses rather than N strings
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
        // where N being total no. of classes in allClasses() list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
        // The signature could be Lx/y/z; or [....
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
        // If it is Lx/y/z; the internal type name is x/y/x
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
        // for array klasses internal type name is same as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
        // signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
        String typeName = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
        if (signature.charAt(0) == 'L') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
            typeName = signature.substring(1, signature.length() - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
            typeName = signature;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
        Symbol typeNameSym = saSymbolTable().probe(typeName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
        // if there is no symbol in VM, then we wouldn't have that type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
        if (typeNameSym == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
            return new ArrayList(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
        Iterator iter = typesBySignature.iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
        List list = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
        while (iter.hasNext()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
            // We have cached type name as symbol in reference type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
            ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
            if (typeNameSym.equals(type.typeNameAsSymbol())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
                list.add(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
        return list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    private void retrieveAllClasses() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
        final List saKlasses = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
        SystemDictionary.ClassVisitor visitor = new SystemDictionary.ClassVisitor() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
                public void visit(Klass k) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
                    for (Klass l = k; l != null; l = l.arrayKlassOrNull()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
                        // for non-array classes filter out un-prepared classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
                        // refer to 'allClasses' in share/back/VirtualMachineImpl.c
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
                        if (l instanceof ArrayKlass) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
                           saKlasses.add(l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
                        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
                           int status = l.getClassStatus();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
                           if ((status & JVMDIClassStatus.PREPARED) != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
                               saKlasses.add(l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
                           }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
                        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
        };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
        // refer to jvmtiGetLoadedClasses.cpp - getLoadedClasses in VM code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
        // classes from SystemDictionary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
        saSystemDictionary.classesDo(visitor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
        // From SystemDictionary we do not get primitive single
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
        // dimensional array classes. add primitive single dimensional array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
        // klasses from Universe.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
        saVM.getUniverse().basicTypeClassesDo(visitor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
        // Hold lock during processing to improve performance
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
        // and to have safe check/set of retrievedAllTypes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
        synchronized (this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
            if (!retrievedAllTypes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
                // Number of classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
                int count = saKlasses.size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
                for (int ii = 0; ii < count; ii++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
                    Klass kk = (Klass)saKlasses.get(ii);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
                    ReferenceTypeImpl type = referenceType(kk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
                retrievedAllTypes = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    ReferenceTypeImpl referenceType(Klass kk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
        ReferenceTypeImpl retType = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
        synchronized (this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
            if (typesByID != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
                retType = (ReferenceTypeImpl)typesByID.get(kk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
            if (retType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
                retType = addReferenceType(kk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
        return retType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    private void initReferenceTypes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
        typesByID = new HashMap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
        typesBySignature = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
    private synchronized ReferenceTypeImpl addReferenceType(Klass kk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
        if (typesByID == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
            initReferenceTypes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
        ReferenceTypeImpl newRefType = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
        if (kk instanceof ObjArrayKlass || kk instanceof TypeArrayKlass) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
            newRefType = new ArrayTypeImpl(this, (ArrayKlass)kk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
        } else if (kk instanceof InstanceKlass) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
            if (kk.isInterface()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
                newRefType = new InterfaceTypeImpl(this, (InstanceKlass)kk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
                newRefType = new ClassTypeImpl(this, (InstanceKlass)kk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
            throw new RuntimeException("should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
        typesByID.put(kk, newRefType);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
        typesBySignature.add(newRefType);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
        return newRefType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
    ThreadGroup threadGroupForJDI() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
        return threadGroupForJDI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    public void redefineClasses(Map classToBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
        throwNotReadOnlyException("VirtualMachineImpl.redefineClasses()");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    private List getAllThreads() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
        if (allThreads == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
            allThreads = new ArrayList(10);  // Might be enough, might not be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
            for (sun.jvm.hotspot.runtime.JavaThread thread =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
                     saVM.getThreads().first(); thread != null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
                     thread = thread.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
                // refer to JvmtiEnv::GetAllThreads in jvmtiEnv.cpp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
                // filter out the hidden-from-external-view threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
                if (thread.isHiddenFromExternalView() == false) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
                    ThreadReferenceImpl myThread = threadMirror(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
                    allThreads.add(myThread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
        return allThreads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
    public List allThreads() { //fixme jjh
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
        return Collections.unmodifiableList(getAllThreads());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
    public void suspend() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
        throwNotReadOnlyException("VirtualMachineImpl.suspend()");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
    public void resume() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
        throwNotReadOnlyException("VirtualMachineImpl.resume()");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
    public List topLevelThreadGroups() { //fixme jjh
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
        // The doc for ThreadGroup says that The top-level thread group
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
        // is the only thread group whose parent is null.  This means there is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
        // only one top level thread group.  There will be a thread in this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
        // group so we will just find a thread whose threadgroup has no parent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
        // and that will be it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
        if (topLevelGroups == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
            topLevelGroups = new ArrayList(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
            Iterator myIt = getAllThreads().iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
            while (myIt.hasNext()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
                ThreadReferenceImpl myThread = (ThreadReferenceImpl)myIt.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
                ThreadGroupReference myGroup = myThread.threadGroup();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
                ThreadGroupReference myParent = myGroup.parent();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
                if (myGroup.parent() == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
                    topLevelGroups.add(myGroup);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
                    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
        return  Collections.unmodifiableList(topLevelGroups);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    public EventQueue eventQueue() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
        throwNotReadOnlyException("VirtualMachine.eventQueue()");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
        return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    public EventRequestManager eventRequestManager() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
        throwNotReadOnlyException("VirtualMachineImpl.eventRequestManager()");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
        return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
    public BooleanValue mirrorOf(boolean value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
        return new BooleanValueImpl(this,value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
    public ByteValue mirrorOf(byte value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
        return new ByteValueImpl(this,value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
    public CharValue mirrorOf(char value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
        return new CharValueImpl(this,value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
    public ShortValue mirrorOf(short value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
        return new ShortValueImpl(this,value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
    public IntegerValue mirrorOf(int value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
        return new IntegerValueImpl(this,value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
    public LongValue mirrorOf(long value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
        return new LongValueImpl(this,value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
    public FloatValue mirrorOf(float value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
        return new FloatValueImpl(this,value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
    public DoubleValue mirrorOf(double value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
        return new DoubleValueImpl(this,value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
    public StringReference mirrorOf(String value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
        throwNotReadOnlyException("VirtualMachinestop.mirrorOf(String)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
        return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
    public VoidValue mirrorOfVoid() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
        if (voidVal == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
            voidVal = new VoidValueImpl(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
        return voidVal;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
    public Process process() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
        throwNotReadOnlyException("VirtualMachine.process");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
        return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    // dispose observer for Class re-use. refer to ConnectorImpl.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    private Observer disposeObserver;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
    // ConnectorImpl loaded by a different class loader can not access it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
    // i.e., runtime package of <ConnectorImpl, L1> is not the same that of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
    // <VirtualMachineImpl, L2> when L1 != L2. So, package private method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    // can be called reflectively after using setAccessible(true).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
    void setDisposeObserver(Observer observer) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
       disposeObserver = observer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
    private void notifyDispose() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
            Assert.that(disposeObserver != null, "null VM.dispose observer");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
        disposeObserver.update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
    public void dispose() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
        saAgent.detach();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
        notifyDispose();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
    public void exit(int exitCode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
        throwNotReadOnlyException("VirtualMachine.exit(int)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
    public boolean canBeModified() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    public boolean canWatchFieldModification() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    public boolean canWatchFieldAccess() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
    public boolean canGetBytecodes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
    public boolean canGetSyntheticAttribute() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
    // FIXME: For now, all monitor capabilities are disabled
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
    public boolean canGetOwnedMonitorInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    public boolean canGetCurrentContendedMonitor() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
    public boolean canGetMonitorInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
    // because this SA works only with 1.5 and update releases
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
    // this should always succeed unlike JVMDI/JDI.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
    public boolean canGet1_5LanguageFeatures() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
    public boolean canUseInstanceFilters() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
    public boolean canRedefineClasses() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
    public boolean canAddMethod() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
    public boolean canUnrestrictedlyRedefineClasses() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    public boolean canPopFrames() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
    public boolean canGetSourceDebugExtension() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
        // We can use InstanceKlass.getSourceDebugExtension only if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
        // ClassFileParser parsed the info. But, ClassFileParser parses
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
        // SourceDebugExtension attribute only if corresponding JVMDI/TI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
        // capability is set to true. Currently, vmStructs does not expose
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
        // JVMDI/TI capabilities and hence we conservatively assume false.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
    public boolean canRequestVMDeathEvent() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
    // new method since 1.6
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
    public boolean canForceEarlyReturn() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
    // new method since 1.6
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
    public boolean canGetConstantPool() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
    // new method since 1.6
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
    public boolean canGetClassFileVersion() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
    // new method since 1.6.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
    public boolean canGetMethodReturnValues() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
    // new method since 1.6
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
    // Real body will be supplied later.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
    public boolean canGetInstanceInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
    // new method since 1.6
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
    public boolean canUseSourceNameFilters() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
    // new method since 1.6.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
    public boolean canRequestMonitorEvents() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
    // new method since 1.6.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
    public boolean canGetMonitorFrameInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
    // new method since 1.6
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
    // Real body will be supplied later.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
    public long[] instanceCounts(List classes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
        if (!canGetInstanceInfo()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
            throw new UnsupportedOperationException(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
                      "target does not support getting instances");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
        final long[] retValue = new long[classes.size()] ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
        final Klass [] klassArray = new Klass[classes.size()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
        boolean allAbstractClasses = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
        for (int i=0; i < classes.size(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
            ReferenceTypeImpl rti = (ReferenceTypeImpl)classes.get(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
            klassArray[i] = rti.ref();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
            retValue[i]=0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
            if (!(rti.isAbstract() || ((ReferenceType)rti instanceof InterfaceType))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
                allAbstractClasses = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
        if (allAbstractClasses) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
            return retValue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
        final int size = classes.size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
        saObjectHeap.iterate(new DefaultHeapVisitor() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
                public boolean doObj(Oop oop) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
                    for (int i=0; i < size; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
                        if (klassArray[i].equals(oop.getKlass())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
                            retValue[i]++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
                            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
                        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
                                        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
            });
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
        return retValue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
    private List getPath (String pathName) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
        String cp = saVM.getSystemProperty(pathName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
        String pathSep = saVM.getSystemProperty("path.separator");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
        ArrayList al = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
        StringTokenizer st = new StringTokenizer(cp, pathSep);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
        while (st.hasMoreTokens()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
            al.add(st.nextToken());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
        al.trimToSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
        return al;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
    public List classPath() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
        return getPath("java.class.path");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
    public List bootClassPath() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
        return getPath("sun.boot.class.path");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
    public String baseDirectory() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
        return saVM.getSystemProperty("user.dir");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
    public void setDefaultStratum(String stratum) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
        defaultStratum = stratum;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
    public String getDefaultStratum() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
        return defaultStratum;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
    public String description() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
        return java.text.MessageFormat.format(java.util.ResourceBundle.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
                                              getBundle("com.sun.tools.jdi.resources.jdi").getString("version_format"),
9127
c3fc6f9ed68d 7010849: 5/5 Extraneous javac source/target options when building sa-jdi
andrew
parents: 5547
diff changeset
   795
                                              "" + vmmgr.majorInterfaceVersion(),
c3fc6f9ed68d 7010849: 5/5 Extraneous javac source/target options when building sa-jdi
andrew
parents: 5547
diff changeset
   796
                                              "" + vmmgr.minorInterfaceVersion(),
c3fc6f9ed68d 7010849: 5/5 Extraneous javac source/target options when building sa-jdi
andrew
parents: 5547
diff changeset
   797
                                              name());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
    public String version() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
        return saVM.getSystemProperty("java.version");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
    public String name() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
        StringBuffer sb = new StringBuffer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
        sb.append("JVM version ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
        sb.append(version());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
        sb.append(" (");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
        sb.append(saVM.getSystemProperty("java.vm.name"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
        sb.append(", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
        sb.append(saVM.getSystemProperty("java.vm.info"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
        sb.append(")");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
        return sb.toString();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
    // from interface Mirror
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
    public VirtualMachine virtualMachine() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
        return this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
    public String toString() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
        return name();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
    public void setDebugTraceMode(int traceFlags) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
        // spec. says output is implementation dependent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
        // and trace mode may be ignored. we ignore it :-)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
    // heap walking API
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
    // capability check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
    public boolean canWalkHeap() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
    // return a list of all objects in heap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
    public List/*<ObjectReference>*/ allObjects() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
        final List objects = new ArrayList(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
        saObjectHeap.iterate(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
            new DefaultHeapVisitor() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
                public boolean doObj(Oop oop) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
                    objects.add(objectMirror(oop));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
                                        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
            });
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
        return objects;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
    // equivalent to objectsByType(type, true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
    public List/*<ObjectReference>*/ objectsByType(ReferenceType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
        return objectsByType(type, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
    // returns objects of type exactly equal to given type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
    private List/*<ObjectReference>*/ objectsByExactType(ReferenceType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
        final List objects = new ArrayList(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
        final Klass givenKls = ((ReferenceTypeImpl)type).ref();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
        saObjectHeap.iterate(new DefaultHeapVisitor() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
                public boolean doObj(Oop oop) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
                    if (givenKls.equals(oop.getKlass())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
                        objects.add(objectMirror(oop));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
                        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
            });
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
        return objects;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
    // returns objects of given type as well as it's subtypes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
    private List/*<ObjectReference>*/ objectsBySubType(ReferenceType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
        final List objects = new ArrayList(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
        final ReferenceType givenType = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
        saObjectHeap.iterate(new DefaultHeapVisitor() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
                public boolean doObj(Oop oop) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
                    ReferenceTypeImpl curType = (ReferenceTypeImpl) referenceType(oop.getKlass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
                    if (curType.isAssignableTo(givenType)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
                        objects.add(objectMirror(oop));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
                        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
            });
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
        return objects;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
    // includeSubtypes - do you want to include subclass/subtype instances of given
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
    // ReferenceType or do we want objects of exact type only?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
    public List/*<ObjectReference>*/ objectsByType(ReferenceType type, boolean includeSubtypes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
        Klass kls = ((ReferenceTypeImpl)type).ref();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
        if (kls instanceof InstanceKlass) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
            InstanceKlass ik = (InstanceKlass) kls;
12369
48fd3da4025c 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 10547
diff changeset
   892
            // if the Klass is final or if there are no subklasses loaded yet
48fd3da4025c 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 10547
diff changeset
   893
            if (ik.getAccessFlagsObj().isFinal() || ik.getSubklassKlass() == null) {
48fd3da4025c 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 10547
diff changeset
   894
                includeSubtypes = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
            // no subtypes for primitive array types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
            ArrayTypeImpl arrayType = (ArrayTypeImpl) type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
            try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
                Type componentType = arrayType.componentType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
                if (componentType instanceof PrimitiveType) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
                    includeSubtypes = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
            } catch (ClassNotLoadedException cnle) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
                // ignore. component type not yet loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
        if (includeSubtypes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
            return objectsBySubType(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
            return objectsByExactType(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
    Type findBootType(String signature) throws ClassNotLoadedException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
        List types = allClasses();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
        Iterator iter = types.iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
        while (iter.hasNext()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
            ReferenceType type = (ReferenceType)iter.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
            if ((type.classLoader() == null) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
                (type.signature().equals(signature))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
                return type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
        JNITypeParser parser = new JNITypeParser(signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
        throw new ClassNotLoadedException(parser.typeName(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
                                         "Type " + parser.typeName() + " not loaded");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
    BooleanType theBooleanType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
        if (theBooleanType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
            synchronized(this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
                if (theBooleanType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
                    theBooleanType = new BooleanTypeImpl(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
        return theBooleanType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
    ByteType theByteType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
        if (theByteType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
            synchronized(this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
                if (theByteType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
                    theByteType = new ByteTypeImpl(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
        return theByteType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
    CharType theCharType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
        if (theCharType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
            synchronized(this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
                if (theCharType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
                    theCharType = new CharTypeImpl(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
        return theCharType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
    ShortType theShortType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
        if (theShortType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
            synchronized(this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
                if (theShortType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
                    theShortType = new ShortTypeImpl(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
        return theShortType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
    IntegerType theIntegerType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
        if (theIntegerType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
            synchronized(this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
                if (theIntegerType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
                    theIntegerType = new IntegerTypeImpl(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
        return theIntegerType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
    LongType theLongType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
        if (theLongType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
            synchronized(this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
                if (theLongType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
                    theLongType = new LongTypeImpl(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
        return theLongType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
    FloatType theFloatType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
        if (theFloatType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
            synchronized(this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
                if (theFloatType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
                    theFloatType = new FloatTypeImpl(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
        return theFloatType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
    DoubleType theDoubleType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
        if (theDoubleType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
            synchronized(this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
                if (theDoubleType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
                    theDoubleType = new DoubleTypeImpl(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
        return theDoubleType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
    VoidType theVoidType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
        if (theVoidType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
            synchronized(this) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
                if (theVoidType == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
                    theVoidType = new VoidTypeImpl(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
        return theVoidType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
    PrimitiveType primitiveTypeMirror(char tag) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
        switch (tag) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
        case 'Z':
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
                return theBooleanType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
        case 'B':
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
                return theByteType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
        case 'C':
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
                return theCharType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
        case 'S':
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
                return theShortType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
        case 'I':
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
                return theIntegerType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
        case 'J':
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
                return theLongType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
        case 'F':
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
                return theFloatType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
        case 'D':
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
                return theDoubleType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
        default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
                throw new IllegalArgumentException("Unrecognized primitive tag " + tag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
    private void processQueue() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
        Reference ref;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
        while ((ref = referenceQueue.poll()) != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
            SoftObjectReference softRef = (SoftObjectReference)ref;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
            removeObjectMirror(softRef);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
    // Address value is used as uniqueID by ObjectReferenceImpl
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
    long getAddressValue(Oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
        return vm.saVM.getDebugger().getAddressValue(obj.getHandle());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
    synchronized ObjectReferenceImpl objectMirror(Oop key) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
        // Handle any queue elements that are not strongly reachable
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
        processQueue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
        if (key == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
            return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
        ObjectReferenceImpl object = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
        /*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
         * Attempt to retrieve an existing object object reference
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
         */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
        SoftObjectReference ref = (SoftObjectReference)objectsByID.get(key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
        if (ref != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
            object = ref.object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
        /*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
         * If the object wasn't in the table, or it's soft reference was
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
         * cleared, create a new instance.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
         */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
        if (object == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
            if (key instanceof Instance) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
                // look for well-known classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
                Symbol className = key.getKlass().getName();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
                if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
                    Assert.that(className != null, "Null class name");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
                Instance inst = (Instance) key;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
                if (className.equals(javaLangString)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
                    object = new StringReferenceImpl(this, inst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
                } else if (className.equals(javaLangThread)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
                    object = new ThreadReferenceImpl(this, inst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
                } else if (className.equals(javaLangThreadGroup)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
                    object = new ThreadGroupReferenceImpl(this, inst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
                } else if (className.equals(javaLangClass)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
                    object = new ClassObjectReferenceImpl(this, inst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
                } else if (className.equals(javaLangClassLoader)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
                    object = new ClassLoaderReferenceImpl(this, inst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
                } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
                    // not a well-known class. But the base class may be
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
                    // one of the known classes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
                    Klass kls = key.getKlass().getSuper();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
                    while (kls != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
                       className = kls.getName();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
                       // java.lang.Class and java.lang.String are final classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
                       if (className.equals(javaLangThread)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
                          object = new ThreadReferenceImpl(this, inst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
                          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
                       } else if(className.equals(javaLangThreadGroup)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
                          object = new ThreadGroupReferenceImpl(this, inst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
                          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
                       } else if (className.equals(javaLangClassLoader)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
                          object = new ClassLoaderReferenceImpl(this, inst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
                          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
                       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
                       kls = kls.getSuper();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
                    if (object == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
                       // create generic object reference
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
                       object = new ObjectReferenceImpl(this, inst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
            } else if (key instanceof TypeArray) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
                object = new ArrayReferenceImpl(this, (Array) key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
            } else if (key instanceof ObjArray) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
                object = new ArrayReferenceImpl(this, (Array) key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
                throw new RuntimeException("unexpected object type " + key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
            ref = new SoftObjectReference(key, object, referenceQueue);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
            /*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
             * If there was no previous entry in the table, we add one here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
             * If the previous entry was cleared, we replace it here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
             */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
            objectsByID.put(key, ref);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
            ref.incrementCount();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
        return object;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
    synchronized void removeObjectMirror(SoftObjectReference ref) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
        /*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
         * This will remove the soft reference if it has not been
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
         * replaced in the cache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
         */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
        objectsByID.remove(ref.key());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
    StringReferenceImpl stringMirror(Instance id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
        return (StringReferenceImpl) objectMirror(id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
    ArrayReferenceImpl arrayMirror(Array id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
       return (ArrayReferenceImpl) objectMirror(id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
    ThreadReferenceImpl threadMirror(Instance id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
        return (ThreadReferenceImpl) objectMirror(id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
    ThreadReferenceImpl threadMirror(JavaThread jt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
        return (ThreadReferenceImpl) objectMirror(jt.getThreadObj());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
    ThreadGroupReferenceImpl threadGroupMirror(Instance id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
        return (ThreadGroupReferenceImpl) objectMirror(id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
    ClassLoaderReferenceImpl classLoaderMirror(Instance id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
        return (ClassLoaderReferenceImpl) objectMirror(id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
    ClassObjectReferenceImpl classObjectMirror(Instance id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
        return (ClassObjectReferenceImpl) objectMirror(id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
    // Use of soft refs and caching stuff here has to be re-examined.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
    //  It might not make sense for JDI - SA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
    static private class SoftObjectReference extends SoftReference {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
       int count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
       Object key;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
       SoftObjectReference(Object key, ObjectReferenceImpl mirror,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
                           ReferenceQueue queue) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
           super(mirror, queue);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
           this.count = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
           this.key = key;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
       int count() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
           return count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
       void incrementCount() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
           count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
       Object key() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
           return key;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
       ObjectReferenceImpl object() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
           return (ObjectReferenceImpl)get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
}