Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @ 3962:cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
Reviewed-by: kvn
author | never |
---|---|
date | Thu, 29 Sep 2011 09:53:56 -0700 |
parents | 35c656d0b685 |
children | 75c0a73eee98 |
comparison
equal
deleted
inserted
replaced
3961:a92cdbac8b9e | 3962:cb315dc80374 |
---|---|
42 } | 42 } |
43 }); | 43 }); |
44 } | 44 } |
45 | 45 |
46 // field offset constants | 46 // field offset constants |
47 public static int ACCESS_FLAGS_OFFSET; | 47 private static int ACCESS_FLAGS_OFFSET; |
48 public static int NAME_INDEX_OFFSET; | 48 private static int NAME_INDEX_OFFSET; |
49 public static int SIGNATURE_INDEX_OFFSET; | 49 private static int SIGNATURE_INDEX_OFFSET; |
50 public static int INITVAL_INDEX_OFFSET; | 50 private static int INITVAL_INDEX_OFFSET; |
51 public static int LOW_OFFSET; | 51 private static int LOW_OFFSET; |
52 public static int HIGH_OFFSET; | 52 private static int HIGH_OFFSET; |
53 public static int GENERIC_SIGNATURE_INDEX_OFFSET; | 53 private static int GENERIC_SIGNATURE_INDEX_OFFSET; |
54 public static int FIELD_SLOTS; | 54 private static int FIELD_SLOTS; |
55 public static int IMPLEMENTORS_LIMIT; | 55 public static int IMPLEMENTORS_LIMIT; |
56 | 56 |
57 // ClassState constants | 57 // ClassState constants |
58 private static int CLASS_STATE_UNPARSABLE_BY_GC; | 58 private static int CLASS_STATE_UNPARSABLE_BY_GC; |
59 private static int CLASS_STATE_ALLOCATED; | 59 private static int CLASS_STATE_ALLOCATED; |
120 | 120 |
121 } | 121 } |
122 | 122 |
123 InstanceKlass(OopHandle handle, ObjectHeap heap) { | 123 InstanceKlass(OopHandle handle, ObjectHeap heap) { |
124 super(handle, heap); | 124 super(handle, heap); |
125 if (getJavaFieldsCount() != getAllFieldsCount()) { | |
126 // Exercise the injected field logic | |
127 for (int i = getJavaFieldsCount(); i < getAllFieldsCount(); i++) { | |
128 getFieldName(i); | |
129 getFieldSignature(i); | |
130 } | |
131 } | |
125 } | 132 } |
126 | 133 |
127 private static OopField arrayKlasses; | 134 private static OopField arrayKlasses; |
128 private static OopField methods; | 135 private static OopField methods; |
129 private static OopField methodOrdering; | 136 private static OopField methodOrdering; |
251 | 258 |
252 public short getFieldAccessFlags(int index) { | 259 public short getFieldAccessFlags(int index) { |
253 return getFields().getShortAt(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET); | 260 return getFields().getShortAt(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET); |
254 } | 261 } |
255 | 262 |
263 public short getFieldNameIndex(int index) { | |
264 if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;"); | |
265 return getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET); | |
266 } | |
267 | |
256 public Symbol getFieldName(int index) { | 268 public Symbol getFieldName(int index) { |
257 int nameIndex = getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET); | 269 int nameIndex = getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET); |
258 return getConstants().getSymbolAt(nameIndex); | 270 if (index < getJavaFieldsCount()) { |
271 return getConstants().getSymbolAt(nameIndex); | |
272 } else { | |
273 return vmSymbols.symbolAt(nameIndex); | |
274 } | |
275 } | |
276 | |
277 public short getFieldSignatureIndex(int index) { | |
278 if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;"); | |
279 return getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET); | |
259 } | 280 } |
260 | 281 |
261 public Symbol getFieldSignature(int index) { | 282 public Symbol getFieldSignature(int index) { |
262 int signatureIndex = getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET); | 283 int signatureIndex = getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET); |
263 return getConstants().getSymbolAt(signatureIndex); | 284 if (index < getJavaFieldsCount()) { |
285 return getConstants().getSymbolAt(signatureIndex); | |
286 } else { | |
287 return vmSymbols.symbolAt(signatureIndex); | |
288 } | |
289 } | |
290 | |
291 public short getFieldGenericSignatureIndex(int index) { | |
292 return getFields().getShortAt(index * FIELD_SLOTS + GENERIC_SIGNATURE_INDEX_OFFSET); | |
264 } | 293 } |
265 | 294 |
266 public Symbol getFieldGenericSignature(int index) { | 295 public Symbol getFieldGenericSignature(int index) { |
267 short genericSignatureIndex = getFields().getShortAt(index * FIELD_SLOTS + GENERIC_SIGNATURE_INDEX_OFFSET); | 296 short genericSignatureIndex = getFieldGenericSignatureIndex(index); |
268 if (genericSignatureIndex != 0) { | 297 if (genericSignatureIndex != 0) { |
269 return getConstants().getSymbolAt(genericSignatureIndex); | 298 return getConstants().getSymbolAt(genericSignatureIndex); |
270 } | 299 } |
271 return null; | 300 return null; |
301 } | |
302 | |
303 public short getFieldInitialValueIndex(int index) { | |
304 if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;"); | |
305 return getFields().getShortAt(index * FIELD_SLOTS + INITVAL_INDEX_OFFSET); | |
272 } | 306 } |
273 | 307 |
274 public int getFieldOffset(int index) { | 308 public int getFieldOffset(int index) { |
275 TypeArray fields = getFields(); | 309 TypeArray fields = getFields(); |
276 return VM.getVM().buildIntFromShorts(fields.getShortAt(index * FIELD_SLOTS + LOW_OFFSET), | 310 return VM.getVM().buildIntFromShorts(fields.getShortAt(index * FIELD_SLOTS + LOW_OFFSET), |
286 public long nofImplementors() { return nofImplementors.getValue(this); } | 320 public long nofImplementors() { return nofImplementors.getValue(this); } |
287 public Klass getImplementor() { return (Klass) implementors[0].getValue(this); } | 321 public Klass getImplementor() { return (Klass) implementors[0].getValue(this); } |
288 public Klass getImplementor(int i) { return (Klass) implementors[i].getValue(this); } | 322 public Klass getImplementor(int i) { return (Klass) implementors[i].getValue(this); } |
289 public TypeArray getFields() { return (TypeArray) fields.getValue(this); } | 323 public TypeArray getFields() { return (TypeArray) fields.getValue(this); } |
290 public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); } | 324 public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); } |
291 public int getAllFieldsCount() { return (int)getFields().getLength(); } | 325 public int getAllFieldsCount() { return (int)getFields().getLength() / FIELD_SLOTS; } |
292 public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } | 326 public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } |
293 public Oop getClassLoader() { return classLoader.getValue(this); } | 327 public Oop getClassLoader() { return classLoader.getValue(this); } |
294 public Oop getProtectionDomain() { return protectionDomain.getValue(this); } | 328 public Oop getProtectionDomain() { return protectionDomain.getValue(this); } |
295 public ObjArray getSigners() { return (ObjArray) signers.getValue(this); } | 329 public ObjArray getSigners() { return (ObjArray) signers.getValue(this); } |
296 public Symbol getSourceFileName() { return getSymbol(sourceFileName); } | 330 public Symbol getSourceFileName() { return getSymbol(sourceFileName); } |
509 visitor.epilogue(); | 543 visitor.epilogue(); |
510 | 544 |
511 } | 545 } |
512 | 546 |
513 void iterateStaticFieldsInternal(OopVisitor visitor) { | 547 void iterateStaticFieldsInternal(OopVisitor visitor) { |
514 TypeArray fields = getFields(); | |
515 int length = getJavaFieldsCount(); | 548 int length = getJavaFieldsCount(); |
516 for (int index = 0; index < length; index++) { | 549 for (int index = 0; index < length; index++) { |
517 short accessFlags = getFieldAccessFlags(index); | 550 short accessFlags = getFieldAccessFlags(index); |
518 FieldType type = new FieldType(getFieldSignature(index)); | 551 FieldType type = new FieldType(getFieldSignature(index)); |
519 AccessFlags access = new AccessFlags(accessFlags); | 552 AccessFlags access = new AccessFlags(accessFlags); |
539 | 572 |
540 public void iterateNonStaticFields(OopVisitor visitor, Oop obj) { | 573 public void iterateNonStaticFields(OopVisitor visitor, Oop obj) { |
541 if (getSuper() != null) { | 574 if (getSuper() != null) { |
542 ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj); | 575 ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj); |
543 } | 576 } |
544 TypeArray fields = getFields(); | |
545 | |
546 int length = getJavaFieldsCount(); | 577 int length = getJavaFieldsCount(); |
547 for (int index = 0; index < length; index++) { | 578 for (int index = 0; index < length; index++) { |
548 short accessFlags = getFieldAccessFlags(index); | 579 short accessFlags = getFieldAccessFlags(index); |
549 FieldType type = new FieldType(getFieldSignature(index)); | 580 FieldType type = new FieldType(getFieldSignature(index)); |
550 AccessFlags access = new AccessFlags(accessFlags); | 581 AccessFlags access = new AccessFlags(accessFlags); |
554 } | 585 } |
555 } | 586 } |
556 | 587 |
557 /** Field access by name. */ | 588 /** Field access by name. */ |
558 public Field findLocalField(Symbol name, Symbol sig) { | 589 public Field findLocalField(Symbol name, Symbol sig) { |
559 TypeArray fields = getFields(); | 590 int length = getJavaFieldsCount(); |
560 int length = (int) fields.getLength(); | |
561 ConstantPool cp = getConstants(); | |
562 for (int i = 0; i < length; i++) { | 591 for (int i = 0; i < length; i++) { |
563 Symbol f_name = getFieldName(i); | 592 Symbol f_name = getFieldName(i); |
564 Symbol f_sig = getFieldSignature(i); | 593 Symbol f_sig = getFieldSignature(i); |
565 if (name.equals(f_name) && sig.equals(f_sig)) { | 594 if (name.equals(f_name) && sig.equals(f_sig)) { |
566 return newField(i); | 595 return newField(i); |
646 Return an empty list if there are no fields declared in this class. | 675 Return an empty list if there are no fields declared in this class. |
647 Only designed for use in a debugging system. */ | 676 Only designed for use in a debugging system. */ |
648 public List getImmediateFields() { | 677 public List getImmediateFields() { |
649 // A list of Fields for each field declared in this class/interface, | 678 // A list of Fields for each field declared in this class/interface, |
650 // not including inherited fields. | 679 // not including inherited fields. |
651 TypeArray fields = getFields(); | |
652 | |
653 int length = getJavaFieldsCount(); | 680 int length = getJavaFieldsCount(); |
654 List immediateFields = new ArrayList(length); | 681 List immediateFields = new ArrayList(length); |
655 for (int index = 0; index < length; index++) { | 682 for (int index = 0; index < length; index++) { |
656 immediateFields.add(getFieldByIndex(index)); | 683 immediateFields.add(getFieldByIndex(index)); |
657 } | 684 } |
837 } | 864 } |
838 } | 865 } |
839 | 866 |
840 // Creates new field from index in fields TypeArray | 867 // Creates new field from index in fields TypeArray |
841 private Field newField(int index) { | 868 private Field newField(int index) { |
842 TypeArray fields = getFields(); | |
843 FieldType type = new FieldType(getFieldSignature(index)); | 869 FieldType type = new FieldType(getFieldSignature(index)); |
844 if (type.isOop()) { | 870 if (type.isOop()) { |
845 if (VM.getVM().isCompressedOopsEnabled()) { | 871 if (VM.getVM().isCompressedOopsEnabled()) { |
846 return new NarrowOopField(this, index); | 872 return new NarrowOopField(this, index); |
847 } else { | 873 } else { |