30 import sun.jvm.hotspot.utilities.*;
31
32 // Super class for all fields in an object
33 public class Field {
34
35 Field(FieldIdentifier id, long offset, boolean isVMField) {
36 this.offset = offset;
37 this.id = id;
38 this.isVMField = isVMField;
39 }
40
41 /** Constructor for fields that are named in an InstanceKlass's
42 fields array (i.e., named, non-VM fields) */
43 Field(InstanceKlass holder, int fieldIndex) {
44 this.holder = holder;
45 this.fieldIndex = fieldIndex;
46
47 offset = holder.getFieldOffset(fieldIndex);
48 genericSignature = holder.getFieldGenericSignature(fieldIndex);
49
50 Symbol name = holder.getFieldName(fieldIndex);
51 id = new NamedFieldIdentifier(name.asString());
52
53 signature = holder.getFieldSignature(fieldIndex);
54 fieldType = new FieldType(signature);
55
56 short access = holder.getFieldAccessFlags(fieldIndex);
57 accessFlags = new AccessFlags(access);
58 }
59
60 private long offset;
61 private FieldIdentifier id;
62 private boolean isVMField;
63 // Java fields only
64 private InstanceKlass holder;
65 private FieldType fieldType;
66 private Symbol signature;
67 private Symbol genericSignature;
68 private AccessFlags accessFlags;
69 private int fieldIndex;
70
71 /** Returns the byte offset of the field within the object or klass */
72 public long getOffset() { return offset; }
73
74 /** Returns the identifier of the field */
75 public FieldIdentifier getID() { return id; }
76
77 /** Indicates whether this is a VM field */
78 public boolean isVMField() { return isVMField; }
79
80 /** Indicates whether this is a named field */
81 public boolean isNamedField() { return (id instanceof NamedFieldIdentifier); }
82
83 public void printOn(PrintStream tty) {
84 getID().printOn(tty);
85 tty.print(" {" + getOffset() + "} :");
86 }
87
88 /** (Named, non-VM fields only) Returns the InstanceKlass containing
89 this (static or non-static) field. */
90 public InstanceKlass getFieldHolder() {
91 return holder;
92 }
93
94 /** (Named, non-VM fields only) Returns the index in the fields
95 TypeArray for this field. Equivalent to the "index" in the VM's
|
30 import sun.jvm.hotspot.utilities.*;
31
32 // Super class for all fields in an object
33 public class Field {
34
35 Field(FieldIdentifier id, long offset, boolean isVMField) {
36 this.offset = offset;
37 this.id = id;
38 this.isVMField = isVMField;
39 }
40
41 /** Constructor for fields that are named in an InstanceKlass's
42 fields array (i.e., named, non-VM fields) */
43 Field(InstanceKlass holder, int fieldIndex) {
44 this.holder = holder;
45 this.fieldIndex = fieldIndex;
46
47 offset = holder.getFieldOffset(fieldIndex);
48 genericSignature = holder.getFieldGenericSignature(fieldIndex);
49
50 name = holder.getFieldName(fieldIndex);
51 id = new NamedFieldIdentifier(name.asString());
52
53 signature = holder.getFieldSignature(fieldIndex);
54 fieldType = new FieldType(signature);
55
56 short access = holder.getFieldAccessFlags(fieldIndex);
57 accessFlags = new AccessFlags(access);
58 }
59
60 private Symbol name;
61 private long offset;
62 private FieldIdentifier id;
63 private boolean isVMField;
64 // Java fields only
65 private InstanceKlass holder;
66 private FieldType fieldType;
67 private Symbol signature;
68 private Symbol genericSignature;
69 private AccessFlags accessFlags;
70 private int fieldIndex;
71
72 /** Returns the byte offset of the field within the object or klass */
73 public long getOffset() { return offset; }
74
75 /** Returns the identifier of the field */
76 public FieldIdentifier getID() { return id; }
77
78 public Symbol getName() { return name; }
79
80 /** Indicates whether this is a VM field */
81 public boolean isVMField() { return isVMField; }
82
83 /** Indicates whether this is a named field */
84 public boolean isNamedField() { return (id instanceof NamedFieldIdentifier); }
85
86 public void printOn(PrintStream tty) {
87 getID().printOn(tty);
88 tty.print(" {" + getOffset() + "} :");
89 }
90
91 /** (Named, non-VM fields only) Returns the InstanceKlass containing
92 this (static or non-static) field. */
93 public InstanceKlass getFieldHolder() {
94 return holder;
95 }
96
97 /** (Named, non-VM fields only) Returns the index in the fields
98 TypeArray for this field. Equivalent to the "index" in the VM's
|