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

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

Print this page




 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 += FIELD_SLOTS) {
 517       short accessFlags    = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
 518       short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
 519       FieldType   type   = new FieldType(getConstants().getSymbolAt(signatureIndex));
 520       AccessFlags access = new AccessFlags(accessFlags);
 521       if (access.isStatic()) {
 522         visitField(visitor, type, index);
 523       }
 524     }
 525   }
 526 
 527   public Klass getJavaSuper() {
 528     return getSuper();
 529   }
 530 
 531   public static class StaticField {
 532     public AccessFlags flags;
 533     public Field field;
 534 
 535     StaticField(Field field, AccessFlags flags) {
 536       this.field = field;
 537       this.flags = flags;
 538     }
 539   }
 540 
 541   public void iterateNonStaticFields(OopVisitor visitor, Oop obj) {
 542     if (getSuper() != null) {
 543       ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj);
 544     }
 545     TypeArray fields = getFields();
 546 
 547     int length = getJavaFieldsCount();
 548     for (int index = 0; index < length; index += FIELD_SLOTS) {
 549       short accessFlags    = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
 550       short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
 551 
 552       FieldType   type   = new FieldType(getConstants().getSymbolAt(signatureIndex));
 553       AccessFlags access = new AccessFlags(accessFlags);
 554       if (!access.isStatic()) {
 555         visitField(visitor, type, index);
 556       }
 557     }
 558   }
 559 
 560   /** Field access by name. */
 561   public Field findLocalField(Symbol name, Symbol sig) {
 562     TypeArray fields = getFields();
 563     int length = (int) fields.getLength();
 564     ConstantPool cp = getConstants();
 565     for (int i = 0; i < length; i += FIELD_SLOTS) {
 566       int nameIndex = fields.getShortAt(i + NAME_INDEX_OFFSET);
 567       int sigIndex  = fields.getShortAt(i + SIGNATURE_INDEX_OFFSET);
 568       Symbol f_name = cp.getSymbolAt(nameIndex);
 569       Symbol f_sig  = cp.getSymbolAt(sigIndex);
 570       if (name.equals(f_name) && sig.equals(f_sig)) {
 571         return newField(i);
 572       }
 573     }
 574 
 575     return null;
 576   }
 577 
 578   /** Find field in direct superinterfaces. */
 579   public Field findInterfaceField(Symbol name, Symbol sig) {
 580     ObjArray interfaces = getLocalInterfaces();
 581     int n = (int) interfaces.getLength();
 582     for (int i = 0; i < n; i++) {
 583       InstanceKlass intf1 = (InstanceKlass) interfaces.getObjAt(i);
 584       if (Assert.ASSERTS_ENABLED) {
 585         Assert.that(intf1.isInterface(), "just checking type");
 586       }
 587       // search for field in current interface
 588       Field f = intf1.findLocalField(name, sig);
 589       if (f != null) {


 624       which the field is defined (convenience routine) */
 625   public Field findField(String name, String sig) {
 626     SymbolTable symbols = VM.getVM().getSymbolTable();
 627     Symbol nameSym = symbols.probe(name);
 628     Symbol sigSym  = symbols.probe(sig);
 629     if (nameSym == null || sigSym == null) {
 630       return null;
 631     }
 632     return findField(nameSym, sigSym);
 633   }
 634 
 635   /** Find field according to JVM spec 5.4.3.2, returns the klass in
 636       which the field is defined (retained only for backward
 637       compatibility with jdbx) */
 638   public Field findFieldDbg(String name, String sig) {
 639     return findField(name, sig);
 640   }
 641 
 642   /** Get field by its index in the fields array. Only designed for
 643       use in a debugging system. */
 644   public Field getFieldByIndex(int fieldArrayIndex) {
 645     return newField(fieldArrayIndex);
 646   }
 647 
 648 
 649     /** Return a List of SA Fields for the fields declared in this class.
 650         Inherited fields are not included.
 651         Return an empty list if there are no fields declared in this class.
 652         Only designed for use in a debugging system. */
 653     public List getImmediateFields() {
 654         // A list of Fields for each field declared in this class/interface,
 655         // not including inherited fields.
 656         TypeArray fields = getFields();
 657 
 658         int length = getJavaFieldsCount();
 659         List immediateFields = new ArrayList(length);
 660         for (int index = 0; index < length; index += FIELD_SLOTS) {
 661             immediateFields.add(getFieldByIndex(index));
 662         }
 663 
 664         return immediateFields;
 665     }
 666 
 667     /** Return a List of SA Fields for all the java fields in this class,
 668         including all inherited fields.  This includes hidden
 669         fields.  Thus the returned list can contain fields with
 670         the same name.
 671         Return an empty list if there are no fields.
 672         Only designed for use in a debugging system. */
 673     public List getAllFields() {
 674         // Contains a Field for each field in this class, including immediate
 675         // fields and inherited fields.
 676         List  allFields = getImmediateFields();
 677 
 678         // transitiveInterfaces contains all interfaces implemented
 679         // by this class and its superclass chain with no duplicates.
 680 


 828       visitor.doInt((IntField) f, false);
 829       return;
 830     }
 831     if (type.isLong()) {
 832       visitor.doLong((LongField) f, false);
 833       return;
 834     }
 835     if (type.isShort()) {
 836       visitor.doShort((ShortField) f, false);
 837       return;
 838     }
 839     if (type.isBoolean()) {
 840       visitor.doBoolean((BooleanField) f, false);
 841       return;
 842     }
 843   }
 844 
 845   // Creates new field from index in fields TypeArray
 846   private Field newField(int index) {
 847     TypeArray fields = getFields();
 848     short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
 849     FieldType type = new FieldType(getConstants().getSymbolAt(signatureIndex));
 850     if (type.isOop()) {
 851      if (VM.getVM().isCompressedOopsEnabled()) {
 852         return new NarrowOopField(this, index);
 853      } else {
 854         return new OopField(this, index);
 855      }
 856     }
 857     if (type.isByte()) {
 858       return new ByteField(this, index);
 859     }
 860     if (type.isChar()) {
 861       return new CharField(this, index);
 862     }
 863     if (type.isDouble()) {
 864       return new DoubleField(this, index);
 865     }
 866     if (type.isFloat()) {
 867       return new FloatField(this, index);
 868     }
 869     if (type.isInt()) {




 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       }
 582       // search for field in current interface
 583       Field f = intf1.findLocalField(name, sig);
 584       if (f != null) {


 619       which the field is defined (convenience routine) */
 620   public Field findField(String name, String sig) {
 621     SymbolTable symbols = VM.getVM().getSymbolTable();
 622     Symbol nameSym = symbols.probe(name);
 623     Symbol sigSym  = symbols.probe(sig);
 624     if (nameSym == null || sigSym == null) {
 625       return null;
 626     }
 627     return findField(nameSym, sigSym);
 628   }
 629 
 630   /** Find field according to JVM spec 5.4.3.2, returns the klass in
 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 
 673         // transitiveInterfaces contains all interfaces implemented
 674         // by this class and its superclass chain with no duplicates.
 675 


 823       visitor.doInt((IntField) f, false);
 824       return;
 825     }
 826     if (type.isLong()) {
 827       visitor.doLong((LongField) f, false);
 828       return;
 829     }
 830     if (type.isShort()) {
 831       visitor.doShort((ShortField) f, false);
 832       return;
 833     }
 834     if (type.isBoolean()) {
 835       visitor.doBoolean((BooleanField) f, false);
 836       return;
 837     }
 838   }
 839 
 840   // Creates new field from index in fields TypeArray
 841   private Field newField(int index) {
 842     TypeArray fields = getFields();
 843     FieldType type = new FieldType(getFieldSignature(index));

 844     if (type.isOop()) {
 845      if (VM.getVM().isCompressedOopsEnabled()) {
 846         return new NarrowOopField(this, index);
 847      } else {
 848         return new OopField(this, index);
 849      }
 850     }
 851     if (type.isByte()) {
 852       return new ByteField(this, index);
 853     }
 854     if (type.isChar()) {
 855       return new CharField(this, index);
 856     }
 857     if (type.isDouble()) {
 858       return new DoubleField(this, index);
 859     }
 860     if (type.isFloat()) {
 861       return new FloatField(this, index);
 862     }
 863     if (type.isInt()) {


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