hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
author coleenp
Sun, 13 Apr 2008 17:43:42 -0400
changeset 360 21d113ecbf6a
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
permissions -rw-r--r--
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
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.oops;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import java.io.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
import java.util.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
import sun.jvm.hotspot.debugger.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
import sun.jvm.hotspot.memory.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
import sun.jvm.hotspot.runtime.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
import sun.jvm.hotspot.types.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
import sun.jvm.hotspot.utilities.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// An InstanceKlass is the VM level representation of a Java class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
public class InstanceKlass extends Klass {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  static {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    VM.registerVMInitializedObserver(new Observer() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
        public void update(Observable o, Object data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
          initialize(VM.getVM().getTypeDataBase());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
      });
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // field offset constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  public static int ACCESS_FLAGS_OFFSET;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  public static int NAME_INDEX_OFFSET;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  public static int SIGNATURE_INDEX_OFFSET;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  public static int INITVAL_INDEX_OFFSET;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  public static int LOW_OFFSET;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  public static int HIGH_OFFSET;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  public static int GENERIC_SIGNATURE_INDEX_OFFSET;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  public static int NEXT_OFFSET;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  public static int IMPLEMENTORS_LIMIT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // ClassState constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  private static int CLASS_STATE_UNPARSABLE_BY_GC;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  private static int CLASS_STATE_ALLOCATED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  private static int CLASS_STATE_LOADED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  private static int CLASS_STATE_LINKED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  private static int CLASS_STATE_BEING_INITIALIZED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  private static int CLASS_STATE_FULLY_INITIALIZED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  private static int CLASS_STATE_INITIALIZATION_ERROR;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    Type type            = db.lookupType("instanceKlass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    arrayKlasses         = new OopField(type.getOopField("_array_klasses"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    methods              = new OopField(type.getOopField("_methods"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    methodOrdering       = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    localInterfaces      = new OopField(type.getOopField("_local_interfaces"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    transitiveInterfaces = new OopField(type.getOopField("_transitive_interfaces"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    nofImplementors      = new CIntField(type.getCIntegerField("_nof_implementors"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    IMPLEMENTORS_LIMIT   = db.lookupIntConstant("instanceKlass::implementors_limit").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    implementors         = new OopField[IMPLEMENTORS_LIMIT];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    for (int i = 0; i < IMPLEMENTORS_LIMIT; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      long arrayOffset = Oop.getHeaderSize() + (i * db.getAddressSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
      implementors[i]    = new OopField(type.getOopField("_implementors[0]"), arrayOffset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    fields               = new OopField(type.getOopField("_fields"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    constants            = new OopField(type.getOopField("_constants"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    classLoader          = new OopField(type.getOopField("_class_loader"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    protectionDomain     = new OopField(type.getOopField("_protection_domain"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    signers              = new OopField(type.getOopField("_signers"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    sourceFileName       = new OopField(type.getOopField("_source_file_name"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    sourceDebugExtension = new OopField(type.getOopField("_source_debug_extension"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    innerClasses         = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    nonstaticFieldSize   = new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    staticFieldSize      = new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    staticOopFieldSize   = new CIntField(type.getCIntegerField("_static_oop_field_size"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    nonstaticOopMapSize  = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    isMarkedDependent    = new CIntField(type.getCIntegerField("_is_marked_dependent"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    initState            = new CIntField(type.getCIntegerField("_init_state"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    vtableLen            = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    itableLen            = new CIntField(type.getCIntegerField("_itable_len"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    breakpoints          = type.getAddressField("_breakpoints");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    genericSignature     = new OopField(type.getOopField("_generic_signature"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    majorVersion         = new CIntField(type.getCIntegerField("_major_version"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    minorVersion         = new CIntField(type.getCIntegerField("_minor_version"), Oop.getHeaderSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    headerSize           = alignObjectOffset(Oop.getHeaderSize() + type.getSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    // read field offset constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    ACCESS_FLAGS_OFFSET = db.lookupIntConstant("instanceKlass::access_flags_offset").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    NAME_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::name_index_offset").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::signature_index_offset").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    INITVAL_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::initval_index_offset").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    LOW_OFFSET = db.lookupIntConstant("instanceKlass::low_offset").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    HIGH_OFFSET = db.lookupIntConstant("instanceKlass::high_offset").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    GENERIC_SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::generic_signature_offset").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    NEXT_OFFSET = db.lookupIntConstant("instanceKlass::next_offset").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    // read ClassState constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    CLASS_STATE_UNPARSABLE_BY_GC = db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("instanceKlass::being_initialized").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("instanceKlass::initialization_error").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  InstanceKlass(OopHandle handle, ObjectHeap heap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    super(handle, heap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  private static OopField  arrayKlasses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  private static OopField  methods;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  private static OopField  methodOrdering;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  private static OopField  localInterfaces;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  private static OopField  transitiveInterfaces;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  private static CIntField nofImplementors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  private static OopField[] implementors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  private static OopField  fields;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  private static OopField  constants;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  private static OopField  classLoader;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  private static OopField  protectionDomain;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  private static OopField  signers;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  private static OopField  sourceFileName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  private static OopField  sourceDebugExtension;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  private static OopField  innerClasses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  private static CIntField nonstaticFieldSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  private static CIntField staticFieldSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  private static CIntField staticOopFieldSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  private static CIntField nonstaticOopMapSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  private static CIntField isMarkedDependent;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  private static CIntField initState;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  private static CIntField vtableLen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  private static CIntField itableLen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  private static AddressField breakpoints;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  private static OopField  genericSignature;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  private static CIntField majorVersion;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  private static CIntField minorVersion;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // type safe enum for ClassState from instanceKlass.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  public static class ClassState {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
     public static final ClassState UNPARSABLE_BY_GC = new ClassState("unparsable_by_gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
     public static final ClassState ALLOCATED    = new ClassState("allocated");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
     public static final ClassState LOADED       = new ClassState("loaded");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
     public static final ClassState LINKED       = new ClassState("linked");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
     public static final ClassState BEING_INITIALIZED      = new ClassState("beingInitialized");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
     public static final ClassState FULLY_INITIALIZED    = new ClassState("fullyInitialized");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
     public static final ClassState INITIALIZATION_ERROR = new ClassState("initializationError");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
     private ClassState(String value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
        this.value = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
     public String toString() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
        return value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
     private String value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  private int  getInitStateAsInt() { return (int) initState.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  public ClassState getInitState() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
     int state = getInitStateAsInt();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
     if (state == CLASS_STATE_UNPARSABLE_BY_GC) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
        return ClassState.UNPARSABLE_BY_GC;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
     } else if (state == CLASS_STATE_ALLOCATED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
        return ClassState.ALLOCATED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
     } else if (state == CLASS_STATE_LOADED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
        return ClassState.LOADED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
     } else if (state == CLASS_STATE_LINKED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
        return ClassState.LINKED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
     } else if (state == CLASS_STATE_BEING_INITIALIZED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
        return ClassState.BEING_INITIALIZED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
     } else if (state == CLASS_STATE_FULLY_INITIALIZED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
        return ClassState.FULLY_INITIALIZED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
     } else if (state == CLASS_STATE_INITIALIZATION_ERROR) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
        return ClassState.INITIALIZATION_ERROR;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
     } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
        throw new RuntimeException("should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  // initialization state quaries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  public boolean isLoaded() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
     return getInitStateAsInt() >= CLASS_STATE_LOADED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  public boolean isLinked() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
     return getInitStateAsInt() >= CLASS_STATE_LINKED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  public boolean isInitialized() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
     return getInitStateAsInt() == CLASS_STATE_FULLY_INITIALIZED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  public boolean isNotInitialized() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
     return getInitStateAsInt() < CLASS_STATE_BEING_INITIALIZED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  public boolean isBeingInitialized() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
     return getInitStateAsInt() == CLASS_STATE_BEING_INITIALIZED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  public boolean isInErrorState() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
     return getInitStateAsInt() == CLASS_STATE_INITIALIZATION_ERROR;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  public int getClassStatus() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
     int result = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
     if (isLinked()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
        result |= JVMDIClassStatus.VERIFIED | JVMDIClassStatus.PREPARED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
     if (isInitialized()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
           Assert.that(isLinked(), "Class status is not consistent");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
        result |= JVMDIClassStatus.INITIALIZED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
     if (isInErrorState()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
        result |= JVMDIClassStatus.ERROR;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
     return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // Byteside of the header
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  private static long headerSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  public static long getHeaderSize() { return headerSize; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  // Accessors for declared fields
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  public Klass     getArrayKlasses()        { return (Klass)        arrayKlasses.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  public ObjArray  getMethods()             { return (ObjArray)     methods.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  public TypeArray getMethodOrdering()      { return (TypeArray)    methodOrdering.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  public ObjArray  getLocalInterfaces()     { return (ObjArray)     localInterfaces.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  public ObjArray  getTransitiveInterfaces() { return (ObjArray)     transitiveInterfaces.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  public long      nofImplementors()        { return                nofImplementors.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  public Klass     getImplementor()         { return (Klass)        implementors[0].getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  public Klass     getImplementor(int i)    { return (Klass)        implementors[i].getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  public TypeArray getFields()              { return (TypeArray)    fields.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  public ConstantPool getConstants()        { return (ConstantPool) constants.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  public Oop       getClassLoader()         { return                classLoader.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  public Oop       getProtectionDomain()    { return                protectionDomain.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  public ObjArray  getSigners()             { return (ObjArray)     signers.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  public Symbol    getSourceFileName()      { return (Symbol)       sourceFileName.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  public Symbol    getSourceDebugExtension(){ return (Symbol)       sourceDebugExtension.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  public TypeArray getInnerClasses()        { return (TypeArray)    innerClasses.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  public long      getNonstaticFieldSize()  { return                nonstaticFieldSize.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  public long      getStaticFieldSize()     { return                staticFieldSize.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  public long      getStaticOopFieldSize()  { return                staticOopFieldSize.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  public long      getNonstaticOopMapSize() { return                nonstaticOopMapSize.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  public boolean   getIsMarkedDependent()   { return                isMarkedDependent.getValue(this) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  public long      getVtableLen()           { return                vtableLen.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  public long      getItableLen()           { return                itableLen.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  public Symbol    getGenericSignature()    { return (Symbol)       genericSignature.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  public long      majorVersion()           { return                majorVersion.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  public long      minorVersion()           { return                minorVersion.getValue(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  // "size helper" == instance size in words
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  public long getSizeHelper() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    int lh = getLayoutHelper();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
      Assert.that(lh > 0, "layout helper initialized for instance class");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    return lh / VM.getVM().getAddressSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  // same as enum InnerClassAttributeOffset in VM code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  public static interface InnerClassAttributeOffset {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    // from JVM spec. "InnerClasses" attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    public static final int innerClassInnerClassInfoOffset = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    public static final int innerClassOuterClassInfoOffset = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    public static final int innerClassInnerNameOffset = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    public static final int innerClassAccessFlagsOffset = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    public static final int innerClassNextOffset = 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  // refer to compute_modifier_flags in VM code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  public long computeModifierFlags() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
    long access = getAccessFlags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    // But check if it happens to be member class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    TypeArray innerClassList = getInnerClasses();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    int length = ( innerClassList == null)? 0 : (int) innerClassList.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    if (length > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
       if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
          Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
       for (int i = 0; i < length; i += InnerClassAttributeOffset.innerClassNextOffset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
          int ioff = innerClassList.getShortAt(i +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
                         InnerClassAttributeOffset.innerClassInnerClassInfoOffset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
          // 'ioff' can be zero.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
          // refer to JVM spec. section 4.7.5.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
          if (ioff != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
             // only look at classes that are already loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
             // since we are looking for the flags for our self.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
             Oop classInfo = getConstants().getObjAt(ioff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
             Symbol name = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
             if (classInfo instanceof Klass) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
                name = ((Klass) classInfo).getName();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
             } else if (classInfo instanceof Symbol) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
                name = (Symbol) classInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
             } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
                throw new RuntimeException("should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
             }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
             if (name.equals(getName())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
                // This is really a member class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
                access = innerClassList.getShortAt(i +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
                        InnerClassAttributeOffset.innerClassAccessFlagsOffset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
                break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
             }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
       } // for inner classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    // Remember to strip ACC_SUPER bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    return (access & (~JVM_ACC_SUPER)) & JVM_ACC_WRITTEN_FLAGS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // whether given Symbol is name of an inner/nested Klass of this Klass?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  // anonymous and local classes are excluded.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  public boolean isInnerClassName(Symbol sym) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
    return isInInnerClasses(sym, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  // whether given Symbol is name of an inner/nested Klass of this Klass?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  // anonymous classes excluded, but local classes are included.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  public boolean isInnerOrLocalClassName(Symbol sym) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    return isInInnerClasses(sym, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  private boolean isInInnerClasses(Symbol sym, boolean includeLocals) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    TypeArray innerClassList = getInnerClasses();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    int length = ( innerClassList == null)? 0 : (int) innerClassList.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    if (length > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
       if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
         Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
       for (int i = 0; i < length; i += InnerClassAttributeOffset.innerClassNextOffset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
         int ioff = innerClassList.getShortAt(i +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
                        InnerClassAttributeOffset.innerClassInnerClassInfoOffset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
         // 'ioff' can be zero.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
         // refer to JVM spec. section 4.7.5.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
         if (ioff != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
            Oop iclassInfo = getConstants().getObjAt(ioff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
            Symbol innerName = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
            if (iclassInfo instanceof Klass) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
               innerName = ((Klass) iclassInfo).getName();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
            } else if (iclassInfo instanceof Symbol) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
               innerName = (Symbol) iclassInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
               throw new RuntimeException("should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
            Symbol myname = getName();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
            int ooff = innerClassList.getShortAt(i +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
                        InnerClassAttributeOffset.innerClassOuterClassInfoOffset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
            // for anonymous classes inner_name_index of InnerClasses
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
            // attribute is zero.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
            int innerNameIndex = innerClassList.getShortAt(i +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
                        InnerClassAttributeOffset.innerClassInnerNameOffset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
            // if this is not a member (anonymous, local etc.), 'ooff' will be zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
            // refer to JVM spec. section 4.7.5.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
            if (ooff == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
               if (includeLocals) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
                  // does it looks like my local class?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
                  if (innerName.equals(sym) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
                     innerName.asString().startsWith(myname.asString())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
                     // exclude anonymous classes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
                     return (innerNameIndex != 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
                  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
               }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
               Oop oclassInfo = getConstants().getObjAt(ooff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
               Symbol outerName = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
               if (oclassInfo instanceof Klass) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
                  outerName = ((Klass) oclassInfo).getName();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
               } else if (oclassInfo instanceof Symbol) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
                  outerName = (Symbol) oclassInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
               } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
                  throw new RuntimeException("should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
               }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
               // include only if current class is outer class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
               if (outerName.equals(myname) && innerName.equals(sym)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
                  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
               }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
           }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
       } // for inner classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
       return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
       return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  public boolean implementsInterface(Klass k) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
      Assert.that(k.isInterface(), "should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    ObjArray interfaces =  getTransitiveInterfaces();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    final int len = (int) interfaces.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
    for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
      if (interfaces.getObjAt(i).equals(k)) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  boolean computeSubtypeOf(Klass k) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
    if (k.isInterface()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
      return implementsInterface(k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
      return super.computeSubtypeOf(k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  public void printValueOn(PrintStream tty) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    tty.print("InstanceKlass for " + getName().asString());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  public void iterateFields(OopVisitor visitor, boolean doVMFields) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    super.iterateFields(visitor, doVMFields);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    if (doVMFields) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
      visitor.doOop(arrayKlasses, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
      visitor.doOop(methods, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
      visitor.doOop(methodOrdering, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
      visitor.doOop(localInterfaces, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
      visitor.doOop(transitiveInterfaces, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
      visitor.doCInt(nofImplementors, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
      for (int i = 0; i < IMPLEMENTORS_LIMIT; i++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
        visitor.doOop(implementors[i], true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
      visitor.doOop(fields, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      visitor.doOop(constants, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
      visitor.doOop(classLoader, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
      visitor.doOop(protectionDomain, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
      visitor.doOop(signers, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
      visitor.doOop(sourceFileName, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
      visitor.doOop(innerClasses, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
      visitor.doCInt(nonstaticFieldSize, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
      visitor.doCInt(staticFieldSize, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
      visitor.doCInt(staticOopFieldSize, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
      visitor.doCInt(nonstaticOopMapSize, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
      visitor.doCInt(isMarkedDependent, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
      visitor.doCInt(initState, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
      visitor.doCInt(vtableLen, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
      visitor.doCInt(itableLen, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
    TypeArray fields = getFields();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    int length = (int) fields.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    for (int index = 0; index < length; index += NEXT_OFFSET) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
      short accessFlags    = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
      short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
      FieldType   type   = new FieldType((Symbol) getConstants().getObjAt(signatureIndex));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
      AccessFlags access = new AccessFlags(accessFlags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
      if (access.isStatic()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
        visitField(visitor, type, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  public Klass getJavaSuper() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
    return getSuper();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  public void iterateNonStaticFields(OopVisitor visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
    if (getSuper() != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
      ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    TypeArray fields = getFields();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
    int length = (int) fields.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
    for (int index = 0; index < length; index += NEXT_OFFSET) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
      short accessFlags    = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
      short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
      FieldType   type   = new FieldType((Symbol) getConstants().getObjAt(signatureIndex));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
      AccessFlags access = new AccessFlags(accessFlags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
      if (!access.isStatic()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
        visitField(visitor, type, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  /** Field access by name. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  public Field findLocalField(Symbol name, Symbol sig) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
    TypeArray fields = getFields();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
    int n = (int) fields.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
    ConstantPool cp = getConstants();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
    for (int i = 0; i < n; i += NEXT_OFFSET) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
      int nameIndex = fields.getShortAt(i + NAME_INDEX_OFFSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
      int sigIndex  = fields.getShortAt(i + SIGNATURE_INDEX_OFFSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
      Symbol f_name = cp.getSymbolAt(nameIndex);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
      Symbol f_sig  = cp.getSymbolAt(sigIndex);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
      if (name.equals(f_name) && sig.equals(f_sig)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
        return newField(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  /** Find field in direct superinterfaces. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  public Field findInterfaceField(Symbol name, Symbol sig) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
    ObjArray interfaces = getLocalInterfaces();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
    int n = (int) interfaces.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    for (int i = 0; i < n; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
      InstanceKlass intf1 = (InstanceKlass) interfaces.getObjAt(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
      if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
        Assert.that(intf1.isInterface(), "just checking type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
      // search for field in current interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
      Field f = intf1.findLocalField(name, sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
      if (f != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
          Assert.that(f.getAccessFlagsObj().isStatic(), "interface field must be static");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
        return f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
      // search for field in direct superinterfaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
      f = intf1.findInterfaceField(name, sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
      if (f != null) return f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
    // otherwise field lookup fails
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  /** Find field according to JVM spec 5.4.3.2, returns the klass in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
      which the field is defined. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
  public Field findField(Symbol name, Symbol sig) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    // search order according to newest JVM spec (5.4.3.2, p.167).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
    // 1) search for field in current klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
    Field f = findLocalField(name, sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
    if (f != null) return f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
    // 2) search for field recursively in direct superinterfaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
    f = findInterfaceField(name, sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    if (f != null) return f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
    // 3) apply field lookup recursively if superclass exists
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
    InstanceKlass supr = (InstanceKlass) getSuper();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
    if (supr != null) return supr.findField(name, sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
    // 4) otherwise field lookup fails
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
    return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  /** Find field according to JVM spec 5.4.3.2, returns the klass in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
      which the field is defined (convenience routine) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  public Field findField(String name, String sig) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
    SymbolTable symbols = VM.getVM().getSymbolTable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
    Symbol nameSym = symbols.probe(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
    Symbol sigSym  = symbols.probe(sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    if (nameSym == null || sigSym == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
      return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
    return findField(nameSym, sigSym);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  /** Find field according to JVM spec 5.4.3.2, returns the klass in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
      which the field is defined (retained only for backward
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
      compatibility with jdbx) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  public Field findFieldDbg(String name, String sig) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    return findField(name, sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  /** Get field by its index in the fields array. Only designed for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
      use in a debugging system. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  public Field getFieldByIndex(int fieldArrayIndex) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
    return newField(fieldArrayIndex);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
    /** Return a List of SA Fields for the fields declared in this class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
        Inherited fields are not included.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
        Return an empty list if there are no fields declared in this class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
        Only designed for use in a debugging system. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
    public List getImmediateFields() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
        // A list of Fields for each field declared in this class/interface,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
        // not including inherited fields.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
        TypeArray fields = getFields();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
        int length = (int) fields.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
        List immediateFields = new ArrayList(length / NEXT_OFFSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
        for (int index = 0; index < length; index += NEXT_OFFSET) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
            immediateFields.add(getFieldByIndex(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
        return immediateFields;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
    /** Return a List of SA Fields for all the java fields in this class,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
        including all inherited fields.  This includes hidden
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
        fields.  Thus the returned list can contain fields with
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
        the same name.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
        Return an empty list if there are no fields.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
        Only designed for use in a debugging system. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    public List getAllFields() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
        // Contains a Field for each field in this class, including immediate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
        // fields and inherited fields.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
        List  allFields = getImmediateFields();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
        // transitiveInterfaces contains all interfaces implemented
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
        // by this class and its superclass chain with no duplicates.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
        ObjArray interfaces = getTransitiveInterfaces();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
        int n = (int) interfaces.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
        for (int i = 0; i < n; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
            InstanceKlass intf1 = (InstanceKlass) interfaces.getObjAt(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
            if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
                Assert.that(intf1.isInterface(), "just checking type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
            allFields.addAll(intf1.getImmediateFields());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
        // Get all fields in the superclass, recursively.  But, don't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
        // include fields in interfaces implemented by superclasses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
        // we already have all those.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
        if (!isInterface()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
            InstanceKlass supr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
            if  ( (supr = (InstanceKlass) getSuper()) != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
                allFields.addAll(supr.getImmediateFields());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
        return allFields;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
    /** Return a List of SA Methods declared directly in this class/interface.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
        Return an empty list if there are none, or if this isn't a class/
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
        interface.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
    */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
    public List getImmediateMethods() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
      // Contains a Method for each method declared in this class/interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
      // not including inherited methods.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
      ObjArray methods = getMethods();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
      int length = (int)methods.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
      Object[] tmp = new Object[length];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
      TypeArray methodOrdering = getMethodOrdering();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
      if (methodOrdering.getLength() != length) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
         // no ordering info present
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
         for (int index = 0; index < length; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
            tmp[index] = methods.getObjAt(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
         for (int index = 0; index < length; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
            int originalIndex = getMethodOrdering().getIntAt(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
            tmp[originalIndex] = methods.getObjAt(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
      return Arrays.asList(tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
    /** Return a List containing an SA InstanceKlass for each
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
        interface named in this class's 'implements' clause.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
    */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
    public List getDirectImplementedInterfaces() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
        // Contains an InstanceKlass for each interface in this classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
        // 'implements' clause.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
        ObjArray interfaces = getLocalInterfaces();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
        int length = (int) interfaces.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
        List directImplementedInterfaces = new ArrayList(length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
        for (int index = 0; index < length; index ++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
            directImplementedInterfaces.add(interfaces.getObjAt(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
        return directImplementedInterfaces;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
  public long getObjectSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
    long bodySize =    alignObjectOffset(getVtableLen() * getHeap().getOopSize())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
                     + alignObjectOffset(getItableLen() * getHeap().getOopSize())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
                     + (getStaticFieldSize() + getNonstaticOopMapSize()) * getHeap().getOopSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
    return alignObjectSize(headerSize + bodySize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
  public Klass arrayKlassImpl(boolean orNull, int n) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
    // FIXME: in reflective system this would need to change to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
    // actually allocate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
    if (getArrayKlasses() == null) { return null; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
    ObjArrayKlass oak = (ObjArrayKlass) getArrayKlasses();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
    if (orNull) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
      return oak.arrayKlassOrNull(n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
    return oak.arrayKlass(n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
  public Klass arrayKlassImpl(boolean orNull) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
    return arrayKlassImpl(orNull, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  public String signature() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
     return "L" + super.signature() + ";";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  /** Convenience routine taking Strings; lookup is done in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
      SymbolTable. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
  public Method findMethod(String name, String sig) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
    SymbolTable syms = VM.getVM().getSymbolTable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
    Symbol nameSym = syms.probe(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
    Symbol sigSym  = syms.probe(sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
    if (nameSym == null || sigSym == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
      return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
    return findMethod(nameSym, sigSym);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  /** Find method in vtable. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
  public Method findMethod(Symbol name, Symbol sig) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
    return findMethod(getMethods(), name, sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
  /** Breakpoint support (see methods on methodOop for details) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  public BreakpointInfo getBreakpoints() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
    Address addr = getHandle().getAddressAt(Oop.getHeaderSize() + breakpoints.getOffset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
    return (BreakpointInfo) VMObjectFactory.newObject(BreakpointInfo.class, addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
  //----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
  // Internals only below this point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
  private void visitField(OopVisitor visitor, FieldType type, int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
    Field f = newField(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
    if (type.isOop()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
      visitor.doOop((OopField) f, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
    if (type.isByte()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
      visitor.doByte((ByteField) f, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
    if (type.isChar()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
      visitor.doChar((CharField) f, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
    if (type.isDouble()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
      visitor.doDouble((DoubleField) f, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
    if (type.isFloat()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
      visitor.doFloat((FloatField) f, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
    if (type.isInt()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
      visitor.doInt((IntField) f, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
    if (type.isLong()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
      visitor.doLong((LongField) f, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
    if (type.isShort()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
      visitor.doShort((ShortField) f, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
    if (type.isBoolean()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
      visitor.doBoolean((BooleanField) f, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
  // Creates new field from index in fields TypeArray
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
  private Field newField(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
    TypeArray fields = getFields();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
    short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
    FieldType type = new FieldType((Symbol) getConstants().getObjAt(signatureIndex));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
    if (type.isOop()) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   792
     if (VM.getVM().isCompressedOopsEnabled()) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   793
        return new NarrowOopField(this, index);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   794
     } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   795
        return new OopField(this, index);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   796
     }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    if (type.isByte()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
      return new ByteField(this, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
    if (type.isChar()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
      return new CharField(this, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
    if (type.isDouble()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
      return new DoubleField(this, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
    if (type.isFloat()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
      return new FloatField(this, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
    if (type.isInt()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
      return new IntField(this, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
    if (type.isLong()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
      return new LongField(this, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
    if (type.isShort()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
      return new ShortField(this, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
    if (type.isBoolean()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
      return new BooleanField(this, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
    throw new RuntimeException("Illegal field type at index " + index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
  private static Method findMethod(ObjArray methods, Symbol name, Symbol signature) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
    int len = (int) methods.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
    // methods are sorted, so do binary search
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
    int l = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
    int h = len - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
    while (l <= h) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
      int mid = (l + h) >> 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
      Method m = (Method) methods.getObjAt(mid);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
      int res = m.getName().fastCompare(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
      if (res == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
        // found matching name; do linear search to find matching signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
        // first, quick check for common case
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
        if (m.getSignature().equals(signature)) return m;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
        // search downwards through overloaded methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
        int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
        for (i = mid - 1; i >= l; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
          Method m1 = (Method) methods.getObjAt(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
          if (!m1.getName().equals(name)) break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
          if (m1.getSignature().equals(signature)) return m1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
        // search upwards
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
        for (i = mid + 1; i <= h; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
          Method m1 = (Method) methods.getObjAt(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
          if (!m1.getName().equals(name)) break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
          if (m1.getSignature().equals(signature)) return m1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
        // not found
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
          int index = linearSearch(methods, name, signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
          if (index != -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
            throw new DebuggerException("binary search bug: should have found entry " + index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
        return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
      } else if (res < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
        l = mid + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
        h = mid - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
      int index = linearSearch(methods, name, signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
      if (index != -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
        throw new DebuggerException("binary search bug: should have found entry " + index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
    return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  private static int linearSearch(ObjArray methods, Symbol name, Symbol signature) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
    int len = (int) methods.getLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
    for (int index = 0; index < len; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
      Method m = (Method) methods.getObjAt(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
      if (m.getSignature().equals(signature) && m.getName().equals(name)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
        return index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
    return -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
}