comparison agent/src/share/classes/sun/jvm/hotspot/oops/Field.java @ 3938:e6b1331a51d2

7086585: make Java field injection more flexible Reviewed-by: jrose, twisti, kvn, coleenp
author never
date Sat, 10 Sep 2011 17:29:02 -0700
parents c18cbe5936b8
children f6f3bb0ee072
comparison
equal deleted inserted replaced
3937:c565834fb592 3938:e6b1331a51d2
37 this.isVMField = isVMField; 37 this.isVMField = isVMField;
38 } 38 }
39 39
40 /** Constructor for fields that are named in an InstanceKlass's 40 /** Constructor for fields that are named in an InstanceKlass's
41 fields array (i.e., named, non-VM fields) */ 41 fields array (i.e., named, non-VM fields) */
42 Field(InstanceKlass holder, int fieldArrayIndex) { 42 Field(InstanceKlass holder, int fieldIndex) {
43 this.holder = holder; 43 this.holder = holder;
44 this.fieldArrayIndex = fieldArrayIndex; 44 this.fieldIndex = fieldIndex;
45 45
46 ConstantPool cp = holder.getConstants(); 46 offset = holder.getFieldOffset(fieldIndex);
47 TypeArray fields = holder.getFields(); 47 genericSignature = holder.getFieldGenericSignature(fieldIndex);
48 short access = fields.getShortAt(fieldArrayIndex + InstanceKlass.ACCESS_FLAGS_OFFSET); 48
49 short nameIndex = fields.getShortAt(fieldArrayIndex + InstanceKlass.NAME_INDEX_OFFSET); 49 Symbol name = holder.getFieldName(fieldIndex);
50 short signatureIndex = fields.getShortAt(fieldArrayIndex + InstanceKlass.SIGNATURE_INDEX_OFFSET);
51 offset = VM.getVM().buildIntFromShorts(fields.getShortAt(fieldArrayIndex + InstanceKlass.LOW_OFFSET),
52 fields.getShortAt(fieldArrayIndex + InstanceKlass.HIGH_OFFSET));
53 short genericSignatureIndex = fields.getShortAt(fieldArrayIndex + InstanceKlass.GENERIC_SIGNATURE_INDEX_OFFSET);
54 Symbol name = cp.getSymbolAt(nameIndex);
55 id = new NamedFieldIdentifier(name.asString()); 50 id = new NamedFieldIdentifier(name.asString());
56 signature = cp.getSymbolAt(signatureIndex);
57 if (genericSignatureIndex != 0) {
58 genericSignature = cp.getSymbolAt(genericSignatureIndex);
59 } else {
60 genericSignature = null;
61 }
62 51
52 signature = holder.getFieldSignature(fieldIndex);
63 fieldType = new FieldType(signature); 53 fieldType = new FieldType(signature);
54
55 short access = holder.getFieldAccessFlags(fieldIndex);
64 accessFlags = new AccessFlags(access); 56 accessFlags = new AccessFlags(access);
65 } 57 }
66 58
67 private long offset; 59 private long offset;
68 private FieldIdentifier id; 60 private FieldIdentifier id;
71 private InstanceKlass holder; 63 private InstanceKlass holder;
72 private FieldType fieldType; 64 private FieldType fieldType;
73 private Symbol signature; 65 private Symbol signature;
74 private Symbol genericSignature; 66 private Symbol genericSignature;
75 private AccessFlags accessFlags; 67 private AccessFlags accessFlags;
76 private int fieldArrayIndex; 68 private int fieldIndex;
77 69
78 /** Returns the byte offset of the field within the object or klass */ 70 /** Returns the byte offset of the field within the object or klass */
79 public long getOffset() { return offset; } 71 public long getOffset() { return offset; }
80 72
81 /** Returns the identifier of the field */ 73 /** Returns the identifier of the field */
99 } 91 }
100 92
101 /** (Named, non-VM fields only) Returns the index in the fields 93 /** (Named, non-VM fields only) Returns the index in the fields
102 TypeArray for this field. Equivalent to the "index" in the VM's 94 TypeArray for this field. Equivalent to the "index" in the VM's
103 fieldDescriptors. */ 95 fieldDescriptors. */
104 public int getFieldArrayIndex() { 96 public int getFieldIndex() {
105 return fieldArrayIndex; 97 return fieldIndex;
106 } 98 }
107 99
108 /** (Named, non-VM fields only) Retrieves the access flags. */ 100 /** (Named, non-VM fields only) Retrieves the access flags. */
109 public long getAccessFlags() { return accessFlags.getValue(); } 101 public long getAccessFlags() { return accessFlags.getValue(); }
110 public AccessFlags getAccessFlagsObj() { return accessFlags; } 102 public AccessFlags getAccessFlagsObj() { return accessFlags; }