agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7092278 Sdiff agent/src/share/classes/sun/jvm/hotspot/oops

agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java

Print this page




  27 import java.io.*;
  28 import java.util.*;
  29 import sun.jvm.hotspot.debugger.*;
  30 import sun.jvm.hotspot.memory.*;
  31 import sun.jvm.hotspot.runtime.*;
  32 import sun.jvm.hotspot.types.*;
  33 import sun.jvm.hotspot.utilities.*;
  34 
  35 // An InstanceKlass is the VM level representation of a Java class.
  36 
  37 public class InstanceKlass extends Klass {
  38   static {
  39     VM.registerVMInitializedObserver(new Observer() {
  40         public void update(Observable o, Object data) {
  41           initialize(VM.getVM().getTypeDataBase());
  42         }
  43       });
  44   }
  45 
  46   // field offset constants
  47   public static int ACCESS_FLAGS_OFFSET;
  48   public static int NAME_INDEX_OFFSET;
  49   public static int SIGNATURE_INDEX_OFFSET;
  50   public static int INITVAL_INDEX_OFFSET;
  51   public static int LOW_OFFSET;
  52   public static int HIGH_OFFSET;
  53   public static int GENERIC_SIGNATURE_INDEX_OFFSET;
  54   public static int FIELD_SLOTS;
  55   public static int IMPLEMENTORS_LIMIT;
  56 
  57   // ClassState constants
  58   private static int CLASS_STATE_UNPARSABLE_BY_GC;
  59   private static int CLASS_STATE_ALLOCATED;
  60   private static int CLASS_STATE_LOADED;
  61   private static int CLASS_STATE_LINKED;
  62   private static int CLASS_STATE_BEING_INITIALIZED;
  63   private static int CLASS_STATE_FULLY_INITIALIZED;
  64   private static int CLASS_STATE_INITIALIZATION_ERROR;
  65 
  66   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
  67     Type type            = db.lookupType("instanceKlass");
  68     arrayKlasses         = new OopField(type.getOopField("_array_klasses"), Oop.getHeaderSize());
  69     methods              = new OopField(type.getOopField("_methods"), Oop.getHeaderSize());
  70     methodOrdering       = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize());
  71     localInterfaces      = new OopField(type.getOopField("_local_interfaces"), Oop.getHeaderSize());
  72     transitiveInterfaces = new OopField(type.getOopField("_transitive_interfaces"), Oop.getHeaderSize());
  73     nofImplementors      = new CIntField(type.getCIntegerField("_nof_implementors"), Oop.getHeaderSize());
  74     IMPLEMENTORS_LIMIT   = db.lookupIntConstant("instanceKlass::implementors_limit").intValue();


 105     NAME_INDEX_OFFSET              = db.lookupIntConstant("FieldInfo::name_index_offset").intValue();
 106     SIGNATURE_INDEX_OFFSET         = db.lookupIntConstant("FieldInfo::signature_index_offset").intValue();
 107     INITVAL_INDEX_OFFSET           = db.lookupIntConstant("FieldInfo::initval_index_offset").intValue();
 108     LOW_OFFSET                     = db.lookupIntConstant("FieldInfo::low_offset").intValue();
 109     HIGH_OFFSET                    = db.lookupIntConstant("FieldInfo::high_offset").intValue();
 110     GENERIC_SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::generic_signature_offset").intValue();
 111     FIELD_SLOTS                    = db.lookupIntConstant("FieldInfo::field_slots").intValue();
 112     // read ClassState constants
 113     CLASS_STATE_UNPARSABLE_BY_GC = db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue();
 114     CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue();
 115     CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue();
 116     CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue();
 117     CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("instanceKlass::being_initialized").intValue();
 118     CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue();
 119     CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("instanceKlass::initialization_error").intValue();
 120 
 121   }
 122 
 123   InstanceKlass(OopHandle handle, ObjectHeap heap) {
 124     super(handle, heap);





 125   }


 126 
 127   private static OopField  arrayKlasses;
 128   private static OopField  methods;
 129   private static OopField  methodOrdering;
 130   private static OopField  localInterfaces;
 131   private static OopField  transitiveInterfaces;
 132   private static CIntField nofImplementors;
 133   private static OopField[] implementors;
 134   private static OopField  fields;
 135   private static CIntField javaFieldsCount;
 136   private static OopField  constants;
 137   private static OopField  classLoader;
 138   private static OopField  protectionDomain;
 139   private static OopField  signers;
 140   private static AddressField  sourceFileName;
 141   private static AddressField  sourceDebugExtension;
 142   private static OopField  innerClasses;
 143   private static CIntField nonstaticFieldSize;
 144   private static CIntField staticFieldSize;
 145   private static CIntField staticOopFieldCount;


 236 
 237      if (isInErrorState()) {
 238         result |= JVMDIClassStatus.ERROR;
 239      }
 240      return result;
 241   }
 242 
 243   // Byteside of the header
 244   private static long headerSize;
 245 
 246   public long getObjectSize(Oop object) {
 247     return getSizeHelper() * VM.getVM().getAddressSize();
 248   }
 249 
 250   public static long getHeaderSize() { return headerSize; }
 251 
 252   public short getFieldAccessFlags(int index) {
 253     return getFields().getShortAt(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET);
 254   }
 255 





 256   public Symbol getFieldName(int index) {
 257     int nameIndex = getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET);

 258     return getConstants().getSymbolAt(nameIndex);


 259   }

 260 





 261   public Symbol getFieldSignature(int index) {
 262     int signatureIndex = getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET);

 263     return getConstants().getSymbolAt(signatureIndex);


 264   }

 265 




 266   public Symbol getFieldGenericSignature(int index) {
 267     short genericSignatureIndex = getFields().getShortAt(index * FIELD_SLOTS + GENERIC_SIGNATURE_INDEX_OFFSET);
 268     if (genericSignatureIndex != 0)  {
 269       return getConstants().getSymbolAt(genericSignatureIndex);
 270     }
 271     return null;
 272   }
 273 





 274   public int getFieldOffset(int index) {
 275     TypeArray fields = getFields();
 276     return VM.getVM().buildIntFromShorts(fields.getShortAt(index * FIELD_SLOTS + LOW_OFFSET),
 277                                          fields.getShortAt(index * FIELD_SLOTS + HIGH_OFFSET));
 278   }
 279 
 280   // Accessors for declared fields
 281   public Klass     getArrayKlasses()        { return (Klass)        arrayKlasses.getValue(this); }
 282   public ObjArray  getMethods()             { return (ObjArray)     methods.getValue(this); }
 283   public TypeArray getMethodOrdering()      { return (TypeArray)    methodOrdering.getValue(this); }
 284   public ObjArray  getLocalInterfaces()     { return (ObjArray)     localInterfaces.getValue(this); }
 285   public ObjArray  getTransitiveInterfaces() { return (ObjArray)     transitiveInterfaces.getValue(this); }
 286   public long      nofImplementors()        { return                nofImplementors.getValue(this); }
 287   public Klass     getImplementor()         { return (Klass)        implementors[0].getValue(this); }
 288   public Klass     getImplementor(int i)    { return (Klass)        implementors[i].getValue(this); }
 289   public TypeArray getFields()              { return (TypeArray)    fields.getValue(this); }
 290   public int       getJavaFieldsCount()     { return                (int) javaFieldsCount.getValue(this); }
 291   public int       getAllFieldsCount()      { return                (int)getFields().getLength(); }
 292   public ConstantPool getConstants()        { return (ConstantPool) constants.getValue(this); }
 293   public Oop       getClassLoader()         { return                classLoader.getValue(this); }
 294   public Oop       getProtectionDomain()    { return                protectionDomain.getValue(this); }
 295   public ObjArray  getSigners()             { return (ObjArray)     signers.getValue(this); }
 296   public Symbol    getSourceFileName()      { return getSymbol(sourceFileName); }
 297   public Symbol    getSourceDebugExtension(){ return getSymbol(sourceDebugExtension); }
 298   public TypeArray getInnerClasses()        { return (TypeArray)    innerClasses.getValue(this); }
 299   public long      getNonstaticFieldSize()  { return                nonstaticFieldSize.getValue(this); }
 300   public long      getStaticOopFieldCount() { return                staticOopFieldCount.getValue(this); }
 301   public long      getNonstaticOopMapSize() { return                nonstaticOopMapSize.getValue(this); }
 302   public boolean   getIsMarkedDependent()   { return                isMarkedDependent.getValue(this) != 0; }
 303   public long      getVtableLen()           { return                vtableLen.getValue(this); }
 304   public long      getItableLen()           { return                itableLen.getValue(this); }
 305   public Symbol    getGenericSignature()    { return getSymbol(genericSignature); }
 306   public long      majorVersion()           { return                majorVersion.getValue(this); }
 307   public long      minorVersion()           { return                minorVersion.getValue(this); }
 308 
 309   // "size helper" == instance size in words
 310   public long getSizeHelper() {
 311     int lh = getLayoutHelper();


 494       visitor.doCInt(initState, true);
 495       visitor.doCInt(vtableLen, true);
 496       visitor.doCInt(itableLen, true);
 497     }
 498   }
 499 
 500   /*
 501    *  Visit the static fields of this InstanceKlass with the obj of
 502    *  the visitor set to the oop holding the fields, which is
 503    *  currently the java mirror.
 504    */
 505   public void iterateStaticFields(OopVisitor visitor) {
 506     visitor.setObj(getJavaMirror());
 507     visitor.prologue();
 508     iterateStaticFieldsInternal(visitor);
 509     visitor.epilogue();
 510 
 511   }
 512 
 513   void iterateStaticFieldsInternal(OopVisitor visitor) {
 514     TypeArray fields = getFields();
 515     int length = getJavaFieldsCount();
 516     for (int index = 0; index < length; index++) {
 517       short accessFlags    = getFieldAccessFlags(index);
 518       FieldType   type   = new FieldType(getFieldSignature(index));
 519       AccessFlags access = new AccessFlags(accessFlags);
 520       if (access.isStatic()) {
 521         visitField(visitor, type, index);
 522       }
 523     }
 524   }
 525 
 526   public Klass getJavaSuper() {
 527     return getSuper();
 528   }
 529 
 530   public static class StaticField {
 531     public AccessFlags flags;
 532     public Field field;
 533 
 534     StaticField(Field field, AccessFlags flags) {
 535       this.field = field;
 536       this.flags = flags;
 537     }
 538   }
 539 
 540   public void iterateNonStaticFields(OopVisitor visitor, Oop obj) {
 541     if (getSuper() != null) {
 542       ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj);
 543     }
 544     TypeArray fields = getFields();
 545 
 546     int length = getJavaFieldsCount();
 547     for (int index = 0; index < length; index++) {
 548       short accessFlags    = getFieldAccessFlags(index);
 549       FieldType   type   = new FieldType(getFieldSignature(index));
 550       AccessFlags access = new AccessFlags(accessFlags);
 551       if (!access.isStatic()) {
 552         visitField(visitor, type, index);
 553       }
 554     }
 555   }
 556 
 557   /** Field access by name. */
 558   public Field findLocalField(Symbol name, Symbol sig) {
 559     TypeArray fields = getFields();
 560     int length = (int) fields.getLength();
 561     ConstantPool cp = getConstants();
 562     for (int i = 0; i < length; i++) {
 563       Symbol f_name = getFieldName(i);
 564       Symbol f_sig  = getFieldSignature(i);
 565       if (name.equals(f_name) && sig.equals(f_sig)) {
 566         return newField(i);
 567       }
 568     }
 569 
 570     return null;
 571   }
 572 
 573   /** Find field in direct superinterfaces. */
 574   public Field findInterfaceField(Symbol name, Symbol sig) {
 575     ObjArray interfaces = getLocalInterfaces();
 576     int n = (int) interfaces.getLength();
 577     for (int i = 0; i < n; i++) {
 578       InstanceKlass intf1 = (InstanceKlass) interfaces.getObjAt(i);
 579       if (Assert.ASSERTS_ENABLED) {
 580         Assert.that(intf1.isInterface(), "just checking type");
 581       }


 631       which the field is defined (retained only for backward
 632       compatibility with jdbx) */
 633   public Field findFieldDbg(String name, String sig) {
 634     return findField(name, sig);
 635   }
 636 
 637   /** Get field by its index in the fields array. Only designed for
 638       use in a debugging system. */
 639   public Field getFieldByIndex(int fieldIndex) {
 640     return newField(fieldIndex);
 641   }
 642 
 643 
 644     /** Return a List of SA Fields for the fields declared in this class.
 645         Inherited fields are not included.
 646         Return an empty list if there are no fields declared in this class.
 647         Only designed for use in a debugging system. */
 648     public List getImmediateFields() {
 649         // A list of Fields for each field declared in this class/interface,
 650         // not including inherited fields.
 651         TypeArray fields = getFields();
 652 
 653         int length = getJavaFieldsCount();
 654         List immediateFields = new ArrayList(length);
 655         for (int index = 0; index < length; index++) {
 656             immediateFields.add(getFieldByIndex(index));
 657         }
 658 
 659         return immediateFields;
 660     }
 661 
 662     /** Return a List of SA Fields for all the java fields in this class,
 663         including all inherited fields.  This includes hidden
 664         fields.  Thus the returned list can contain fields with
 665         the same name.
 666         Return an empty list if there are no fields.
 667         Only designed for use in a debugging system. */
 668     public List getAllFields() {
 669         // Contains a Field for each field in this class, including immediate
 670         // fields and inherited fields.
 671         List  allFields = getImmediateFields();
 672 




  27 import java.io.*;
  28 import java.util.*;
  29 import sun.jvm.hotspot.debugger.*;
  30 import sun.jvm.hotspot.memory.*;
  31 import sun.jvm.hotspot.runtime.*;
  32 import sun.jvm.hotspot.types.*;
  33 import sun.jvm.hotspot.utilities.*;
  34 
  35 // An InstanceKlass is the VM level representation of a Java class.
  36 
  37 public class InstanceKlass extends Klass {
  38   static {
  39     VM.registerVMInitializedObserver(new Observer() {
  40         public void update(Observable o, Object data) {
  41           initialize(VM.getVM().getTypeDataBase());
  42         }
  43       });
  44   }
  45 
  46   // field offset constants
  47   private static int ACCESS_FLAGS_OFFSET;
  48   private static int NAME_INDEX_OFFSET;
  49   private static int SIGNATURE_INDEX_OFFSET;
  50   private static int INITVAL_INDEX_OFFSET;
  51   private static int LOW_OFFSET;
  52   private static int HIGH_OFFSET;
  53   private static int GENERIC_SIGNATURE_INDEX_OFFSET;
  54   private static int FIELD_SLOTS;
  55   public static int IMPLEMENTORS_LIMIT;
  56 
  57   // ClassState constants
  58   private static int CLASS_STATE_UNPARSABLE_BY_GC;
  59   private static int CLASS_STATE_ALLOCATED;
  60   private static int CLASS_STATE_LOADED;
  61   private static int CLASS_STATE_LINKED;
  62   private static int CLASS_STATE_BEING_INITIALIZED;
  63   private static int CLASS_STATE_FULLY_INITIALIZED;
  64   private static int CLASS_STATE_INITIALIZATION_ERROR;
  65 
  66   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
  67     Type type            = db.lookupType("instanceKlass");
  68     arrayKlasses         = new OopField(type.getOopField("_array_klasses"), Oop.getHeaderSize());
  69     methods              = new OopField(type.getOopField("_methods"), Oop.getHeaderSize());
  70     methodOrdering       = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize());
  71     localInterfaces      = new OopField(type.getOopField("_local_interfaces"), Oop.getHeaderSize());
  72     transitiveInterfaces = new OopField(type.getOopField("_transitive_interfaces"), Oop.getHeaderSize());
  73     nofImplementors      = new CIntField(type.getCIntegerField("_nof_implementors"), Oop.getHeaderSize());
  74     IMPLEMENTORS_LIMIT   = db.lookupIntConstant("instanceKlass::implementors_limit").intValue();


 105     NAME_INDEX_OFFSET              = db.lookupIntConstant("FieldInfo::name_index_offset").intValue();
 106     SIGNATURE_INDEX_OFFSET         = db.lookupIntConstant("FieldInfo::signature_index_offset").intValue();
 107     INITVAL_INDEX_OFFSET           = db.lookupIntConstant("FieldInfo::initval_index_offset").intValue();
 108     LOW_OFFSET                     = db.lookupIntConstant("FieldInfo::low_offset").intValue();
 109     HIGH_OFFSET                    = db.lookupIntConstant("FieldInfo::high_offset").intValue();
 110     GENERIC_SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::generic_signature_offset").intValue();
 111     FIELD_SLOTS                    = db.lookupIntConstant("FieldInfo::field_slots").intValue();
 112     // read ClassState constants
 113     CLASS_STATE_UNPARSABLE_BY_GC = db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue();
 114     CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue();
 115     CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue();
 116     CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue();
 117     CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("instanceKlass::being_initialized").intValue();
 118     CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue();
 119     CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("instanceKlass::initialization_error").intValue();
 120 
 121   }
 122 
 123   InstanceKlass(OopHandle handle, ObjectHeap 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     }
 132   }
 133 
 134   private static OopField  arrayKlasses;
 135   private static OopField  methods;
 136   private static OopField  methodOrdering;
 137   private static OopField  localInterfaces;
 138   private static OopField  transitiveInterfaces;
 139   private static CIntField nofImplementors;
 140   private static OopField[] implementors;
 141   private static OopField  fields;
 142   private static CIntField javaFieldsCount;
 143   private static OopField  constants;
 144   private static OopField  classLoader;
 145   private static OopField  protectionDomain;
 146   private static OopField  signers;
 147   private static AddressField  sourceFileName;
 148   private static AddressField  sourceDebugExtension;
 149   private static OopField  innerClasses;
 150   private static CIntField nonstaticFieldSize;
 151   private static CIntField staticFieldSize;
 152   private static CIntField staticOopFieldCount;


 243 
 244      if (isInErrorState()) {
 245         result |= JVMDIClassStatus.ERROR;
 246      }
 247      return result;
 248   }
 249 
 250   // Byteside of the header
 251   private static long headerSize;
 252 
 253   public long getObjectSize(Oop object) {
 254     return getSizeHelper() * VM.getVM().getAddressSize();
 255   }
 256 
 257   public static long getHeaderSize() { return headerSize; }
 258 
 259   public short getFieldAccessFlags(int index) {
 260     return getFields().getShortAt(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET);
 261   }
 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 
 268   public Symbol getFieldName(int index) {
 269     int nameIndex = getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET);
 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);
 280   }
 281 
 282   public Symbol getFieldSignature(int index) {
 283     int signatureIndex = getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET);
 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);
 293   }
 294 
 295   public Symbol getFieldGenericSignature(int index) {
 296     short genericSignatureIndex = getFieldGenericSignatureIndex(index);
 297     if (genericSignatureIndex != 0)  {
 298       return getConstants().getSymbolAt(genericSignatureIndex);
 299     }
 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);
 306   }
 307 
 308   public int getFieldOffset(int index) {
 309     TypeArray fields = getFields();
 310     return VM.getVM().buildIntFromShorts(fields.getShortAt(index * FIELD_SLOTS + LOW_OFFSET),
 311                                          fields.getShortAt(index * FIELD_SLOTS + HIGH_OFFSET));
 312   }
 313 
 314   // Accessors for declared fields
 315   public Klass     getArrayKlasses()        { return (Klass)        arrayKlasses.getValue(this); }
 316   public ObjArray  getMethods()             { return (ObjArray)     methods.getValue(this); }
 317   public TypeArray getMethodOrdering()      { return (TypeArray)    methodOrdering.getValue(this); }
 318   public ObjArray  getLocalInterfaces()     { return (ObjArray)     localInterfaces.getValue(this); }
 319   public ObjArray  getTransitiveInterfaces() { return (ObjArray)     transitiveInterfaces.getValue(this); }
 320   public long      nofImplementors()        { return                nofImplementors.getValue(this); }
 321   public Klass     getImplementor()         { return (Klass)        implementors[0].getValue(this); }
 322   public Klass     getImplementor(int i)    { return (Klass)        implementors[i].getValue(this); }
 323   public TypeArray getFields()              { return (TypeArray)    fields.getValue(this); }
 324   public int       getJavaFieldsCount()     { return                (int) javaFieldsCount.getValue(this); }
 325   public int       getAllFieldsCount()      { return                (int)getFields().getLength() / FIELD_SLOTS; }
 326   public ConstantPool getConstants()        { return (ConstantPool) constants.getValue(this); }
 327   public Oop       getClassLoader()         { return                classLoader.getValue(this); }
 328   public Oop       getProtectionDomain()    { return                protectionDomain.getValue(this); }
 329   public ObjArray  getSigners()             { return (ObjArray)     signers.getValue(this); }
 330   public Symbol    getSourceFileName()      { return getSymbol(sourceFileName); }
 331   public Symbol    getSourceDebugExtension(){ return getSymbol(sourceDebugExtension); }
 332   public TypeArray getInnerClasses()        { return (TypeArray)    innerClasses.getValue(this); }
 333   public long      getNonstaticFieldSize()  { return                nonstaticFieldSize.getValue(this); }
 334   public long      getStaticOopFieldCount() { return                staticOopFieldCount.getValue(this); }
 335   public long      getNonstaticOopMapSize() { return                nonstaticOopMapSize.getValue(this); }
 336   public boolean   getIsMarkedDependent()   { return                isMarkedDependent.getValue(this) != 0; }
 337   public long      getVtableLen()           { return                vtableLen.getValue(this); }
 338   public long      getItableLen()           { return                itableLen.getValue(this); }
 339   public Symbol    getGenericSignature()    { return getSymbol(genericSignature); }
 340   public long      majorVersion()           { return                majorVersion.getValue(this); }
 341   public long      minorVersion()           { return                minorVersion.getValue(this); }
 342 
 343   // "size helper" == instance size in words
 344   public long getSizeHelper() {
 345     int lh = getLayoutHelper();


 528       visitor.doCInt(initState, true);
 529       visitor.doCInt(vtableLen, true);
 530       visitor.doCInt(itableLen, true);
 531     }
 532   }
 533 
 534   /*
 535    *  Visit the static fields of this InstanceKlass with the obj of
 536    *  the visitor set to the oop holding the fields, which is
 537    *  currently the java mirror.
 538    */
 539   public void iterateStaticFields(OopVisitor visitor) {
 540     visitor.setObj(getJavaMirror());
 541     visitor.prologue();
 542     iterateStaticFieldsInternal(visitor);
 543     visitor.epilogue();
 544 
 545   }
 546 
 547   void iterateStaticFieldsInternal(OopVisitor visitor) {

 548     int length = getJavaFieldsCount();
 549     for (int index = 0; index < length; index++) {
 550       short accessFlags    = getFieldAccessFlags(index);
 551       FieldType   type   = new FieldType(getFieldSignature(index));
 552       AccessFlags access = new AccessFlags(accessFlags);
 553       if (access.isStatic()) {
 554         visitField(visitor, type, index);
 555       }
 556     }
 557   }
 558 
 559   public Klass getJavaSuper() {
 560     return getSuper();
 561   }
 562 
 563   public static class StaticField {
 564     public AccessFlags flags;
 565     public Field field;
 566 
 567     StaticField(Field field, AccessFlags flags) {
 568       this.field = field;
 569       this.flags = flags;
 570     }
 571   }
 572 
 573   public void iterateNonStaticFields(OopVisitor visitor, Oop obj) {
 574     if (getSuper() != null) {
 575       ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj);
 576     }


 577     int length = getJavaFieldsCount();
 578     for (int index = 0; index < length; index++) {
 579       short accessFlags    = getFieldAccessFlags(index);
 580       FieldType   type   = new FieldType(getFieldSignature(index));
 581       AccessFlags access = new AccessFlags(accessFlags);
 582       if (!access.isStatic()) {
 583         visitField(visitor, type, index);
 584       }
 585     }
 586   }
 587 
 588   /** Field access by name. */
 589   public Field findLocalField(Symbol name, Symbol sig) {
 590     int length = getJavaFieldsCount();


 591     for (int i = 0; i < length; i++) {
 592       Symbol f_name = getFieldName(i);
 593       Symbol f_sig  = getFieldSignature(i);
 594       if (name.equals(f_name) && sig.equals(f_sig)) {
 595         return newField(i);
 596       }
 597     }
 598 
 599     return null;
 600   }
 601 
 602   /** Find field in direct superinterfaces. */
 603   public Field findInterfaceField(Symbol name, Symbol sig) {
 604     ObjArray interfaces = getLocalInterfaces();
 605     int n = (int) interfaces.getLength();
 606     for (int i = 0; i < n; i++) {
 607       InstanceKlass intf1 = (InstanceKlass) interfaces.getObjAt(i);
 608       if (Assert.ASSERTS_ENABLED) {
 609         Assert.that(intf1.isInterface(), "just checking type");
 610       }


 660       which the field is defined (retained only for backward
 661       compatibility with jdbx) */
 662   public Field findFieldDbg(String name, String sig) {
 663     return findField(name, sig);
 664   }
 665 
 666   /** Get field by its index in the fields array. Only designed for
 667       use in a debugging system. */
 668   public Field getFieldByIndex(int fieldIndex) {
 669     return newField(fieldIndex);
 670   }
 671 
 672 
 673     /** Return a List of SA Fields for the fields declared in this class.
 674         Inherited fields are not included.
 675         Return an empty list if there are no fields declared in this class.
 676         Only designed for use in a debugging system. */
 677     public List getImmediateFields() {
 678         // A list of Fields for each field declared in this class/interface,
 679         // not including inherited fields.


 680         int length = getJavaFieldsCount();
 681         List immediateFields = new ArrayList(length);
 682         for (int index = 0; index < length; index++) {
 683             immediateFields.add(getFieldByIndex(index));
 684         }
 685 
 686         return immediateFields;
 687     }
 688 
 689     /** Return a List of SA Fields for all the java fields in this class,
 690         including all inherited fields.  This includes hidden
 691         fields.  Thus the returned list can contain fields with
 692         the same name.
 693         Return an empty list if there are no fields.
 694         Only designed for use in a debugging system. */
 695     public List getAllFields() {
 696         // Contains a Field for each field in this class, including immediate
 697         // fields and inherited fields.
 698         List  allFields = getImmediateFields();
 699 


agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File