jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaClass.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 468 642c8c0be52e
child 5506 202f599c92aa
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 468
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * The Original Code is HAT. The Initial Developer of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * Original Code is Bill Foote, with contributions from others
468
642c8c0be52e 6695553: Cleanup GPLv2+SPL legal notices in hat sources
ohair
parents: 2
diff changeset
    30
 * at JavaSoft/Sun.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
package com.sun.tools.hat.internal.model;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.tools.hat.internal.util.CompositeEnumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import com.sun.tools.hat.internal.parser.ReadBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @author      Bill Foote
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
public class JavaClass extends JavaHeapObject {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    // my id
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private long id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    // my name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    // These are JavaObjectRef before resolve
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private JavaThing superclass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private JavaThing loader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private JavaThing signers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private JavaThing protectionDomain;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    // non-static fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private JavaField[] fields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    // static fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private JavaStatic[] statics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private static final JavaClass[] EMPTY_CLASS_ARRAY = new JavaClass[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    // my subclasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private JavaClass[] subclasses = EMPTY_CLASS_ARRAY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    // my instances
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private Vector<JavaHeapObject> instances = new Vector<JavaHeapObject>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    // Who I belong to.  Set on resolve.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private Snapshot mySnapshot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    // Size of an instance, including VM overhead
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private int instanceSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    // Total number of fields including inherited ones
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private int totalNumFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public JavaClass(long id, String name, long superclassId, long loaderId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                     long signersId, long protDomainId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                     JavaField[] fields, JavaStatic[] statics,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                     int instanceSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        this.id = id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        this.superclass = new JavaObjectRef(superclassId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        this.loader = new JavaObjectRef(loaderId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        this.signers = new JavaObjectRef(signersId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        this.protectionDomain = new JavaObjectRef(protDomainId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        this.fields = fields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        this.statics = statics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        this.instanceSize = instanceSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public JavaClass(String name, long superclassId, long loaderId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                     long signersId, long protDomainId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                     JavaField[] fields, JavaStatic[] statics,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                     int instanceSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        this(-1L, name, superclassId, loaderId, signersId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
             protDomainId, fields, statics, instanceSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public final JavaClass getClazz() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        return mySnapshot.getJavaLangClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public final int getIdentifierSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        return mySnapshot.getIdentifierSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public final int getMinimumObjectSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return mySnapshot.getMinimumObjectSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public void resolve(Snapshot snapshot) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        if (mySnapshot != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        mySnapshot = snapshot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        resolveSuperclass(snapshot);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        if (superclass != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            ((JavaClass) superclass).addSubclass(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        loader  = loader.dereference(snapshot, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        signers  = signers.dereference(snapshot, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        protectionDomain  = protectionDomain.dereference(snapshot, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        for (int i = 0; i < statics.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            statics[i].resolve(this, snapshot);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        snapshot.getJavaLangClass().addInstance(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        super.resolve(snapshot);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Resolve our superclass.  This might be called well before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * all instances are available (like when reading deferred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * instances in a 1.2 dump file :-)  Calling this is sufficient
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * to be able to explore this class' fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public void resolveSuperclass(Snapshot snapshot) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        if (superclass == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            // We must be java.lang.Object, so we have no superclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            totalNumFields = fields.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            superclass = superclass.dereference(snapshot, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            if (superclass == snapshot.getNullThing()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                superclass = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                    JavaClass sc = (JavaClass) superclass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                    sc.resolveSuperclass(snapshot);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                    totalNumFields += sc.totalNumFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                } catch (ClassCastException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                    System.out.println("Warning!  Superclass of " + name + " is " + superclass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                    superclass = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public boolean isString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        return mySnapshot.getJavaLangString() == this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public boolean isClassLoader() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        return mySnapshot.getJavaLangClassLoader().isAssignableFrom(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * Get a numbered field from this class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    public JavaField getField(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        if (i < 0 || i >= fields.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            throw new Error("No field " + i + " for " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        return fields[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * Get the total number of fields that are part of an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * this class.  That is, include superclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public int getNumFieldsForInstance() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        return totalNumFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * Get a numbered field from all the fields that are part of instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * of this class.  That is, include superclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public JavaField getFieldForInstance(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (superclass != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            JavaClass sc = (JavaClass) superclass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            if (i < sc.totalNumFields) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                return sc.getFieldForInstance(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            i -= sc.totalNumFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        return getField(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Get the class responsible for field i, where i is a field number that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * could be passed into getFieldForInstance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @see JavaClass.getFieldForInstance()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    public JavaClass getClassForField(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        if (superclass != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            JavaClass sc = (JavaClass) superclass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            if (i < sc.totalNumFields) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                return sc.getClassForField(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public long getId() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        return id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    public boolean isArray() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        return name.indexOf('[') != -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public Enumeration getInstances(boolean includeSubclasses) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        if (includeSubclasses) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            Enumeration res = instances.elements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            for (int i = 0; i < subclasses.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                res = new CompositeEnumeration(res,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                              subclasses[i].getInstances(true));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            return instances.elements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @return a count of the instances of this class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    public int getInstancesCount(boolean includeSubclasses) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        int result = instances.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        if (includeSubclasses) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            for (int i = 0; i < subclasses.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                result += subclasses[i].getInstancesCount(includeSubclasses);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    public JavaClass[] getSubclasses() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        return subclasses;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * This can only safely be called after resolve()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    public JavaClass getSuperclass() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        return (JavaClass) superclass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * This can only safely be called after resolve()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public JavaThing getLoader() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        return loader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * This can only safely be called after resolve()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    public boolean isBootstrap() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        return loader == mySnapshot.getNullThing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * This can only safely be called after resolve()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    public JavaThing getSigners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        return signers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * This can only safely be called after resolve()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public JavaThing getProtectionDomain() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        return protectionDomain;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    public JavaField[] getFields() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        return fields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Includes superclass fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    public JavaField[] getFieldsForInstance() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        Vector<JavaField> v = new Vector<JavaField>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        addFields(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        JavaField[] result = new JavaField[v.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        for (int i = 0; i < v.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            result[i] =  v.elementAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    public JavaStatic[] getStatics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        return statics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    // returns value of static field of given name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    public JavaThing getStaticField(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        for (int i = 0; i < statics.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            JavaStatic s = statics[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            if (s.getField().getName().equals(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                return s.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        return "class " + name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    public int compareTo(JavaThing other) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        if (other instanceof JavaClass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            return name.compareTo(((JavaClass) other).name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        return super.compareTo(other);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @return true iff a variable of type this is assignable from an instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *          of other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    public boolean isAssignableFrom(JavaClass other) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        if (this == other) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        } else if (other == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            return isAssignableFrom((JavaClass) other.superclass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            // Trivial tail recursion:  I have faith in javac.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * Describe the reference that this thing has to target.  This will only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * be called if target is in the array returned by getChildrenForRootset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     public String describeReferenceTo(JavaThing target, Snapshot ss) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        for (int i = 0; i < statics.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            JavaField f = statics[i].getField();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            if (f.hasId()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                JavaThing other = statics[i].getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                if (other == target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                    return "static field " + f.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        return super.describeReferenceTo(target, ss);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @return the size of an instance of this class.  Gives 0 for an array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     *          type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    public int getInstanceSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        return instanceSize + mySnapshot.getMinimumObjectSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @return The size of all instances of this class.  Correctly handles
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     *          arrays.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    public long getTotalInstanceSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        int count = instances.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        if (count == 0 || !isArray()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            return count * instanceSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        // array class and non-zero count, we have to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        // get the size of each instance and sum it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        long result = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        for (int i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            JavaThing t = (JavaThing) instances.elementAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            result += t.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * @return the size of this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    public int getSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        JavaClass cl = mySnapshot.getJavaLangClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        if (cl == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            return cl.getInstanceSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    public void visitReferencedObjects(JavaHeapObjectVisitor v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        super.visitReferencedObjects(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        JavaHeapObject sc = getSuperclass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        if (sc != null) v.visit(getSuperclass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        JavaThing other;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        other = getLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        if (other instanceof JavaHeapObject) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            v.visit((JavaHeapObject)other);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        other = getSigners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        if (other instanceof JavaHeapObject) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            v.visit((JavaHeapObject)other);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        other = getProtectionDomain();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        if (other instanceof JavaHeapObject) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            v.visit((JavaHeapObject)other);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        for (int i = 0; i < statics.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            JavaField f = statics[i].getField();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            if (!v.exclude(this, f) && f.hasId()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                other = statics[i].getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                if (other instanceof JavaHeapObject) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                    v.visit((JavaHeapObject) other);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    // package-privates below this point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    final ReadBuffer getReadBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        return mySnapshot.getReadBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    final void setNew(JavaHeapObject obj, boolean flag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        mySnapshot.setNew(obj, flag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    final boolean isNew(JavaHeapObject obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        return mySnapshot.isNew(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    final StackTrace getSiteTrace(JavaHeapObject obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        return mySnapshot.getSiteTrace(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    final void addReferenceFromRoot(Root root, JavaHeapObject obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        mySnapshot.addReferenceFromRoot(root, obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    final Root getRoot(JavaHeapObject obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        return mySnapshot.getRoot(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    final Snapshot getSnapshot() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        return mySnapshot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    void addInstance(JavaHeapObject inst) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        instances.addElement(inst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    // Internals only below this point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    private void addFields(Vector<JavaField> v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        if (superclass != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            ((JavaClass) superclass).addFields(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        for (int i = 0; i < fields.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            v.addElement(fields[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    private void addSubclassInstances(Vector<JavaHeapObject> v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        for (int i = 0; i < subclasses.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            subclasses[i].addSubclassInstances(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        for (int i = 0; i < instances.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            v.addElement(instances.elementAt(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    private void addSubclass(JavaClass sub) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        JavaClass newValue[] = new JavaClass[subclasses.length + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        System.arraycopy(subclasses, 0, newValue, 0, subclasses.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        newValue[subclasses.length] = sub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        subclasses = newValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
}