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

agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java

Print this page




 362             dos.writeShort(0); // no super class
 363         }
 364     }
 365     protected void writeInterfaces() throws IOException {
 366         ObjArray interfaces = klass.getLocalInterfaces();
 367         final int len = (int) interfaces.getLength();
 368 
 369         if (DEBUG) debugMessage("number of interfaces = " + len);
 370 
 371         // write interfaces count
 372         dos.writeShort((short) len);
 373         for (int i = 0; i < len; i++) {
 374            Klass k = (Klass) interfaces.getObjAt(i);
 375            Short index = (Short) classToIndex.get(k.getName().asString());
 376            dos.writeShort(index.shortValue());
 377            if (DEBUG) debugMessage("\t" + index);
 378         }
 379     }
 380 
 381     protected void writeFields() throws IOException {
 382         TypeArray fields = klass.getFields();
 383         final int length = klass.getJavaFieldsCount();
 384 
 385         // write number of fields
 386         dos.writeShort((short) (length / InstanceKlass.FIELD_SLOTS) );
 387 
 388         if (DEBUG) debugMessage("number of fields = "
 389                                 + length/InstanceKlass.FIELD_SLOTS);
 390 
 391         for (int index = 0; index < length; index += InstanceKlass.FIELD_SLOTS) {
 392             short accessFlags    = fields.getShortAt(index + InstanceKlass.ACCESS_FLAGS_OFFSET);
 393             dos.writeShort(accessFlags & (short) JVM_RECOGNIZED_FIELD_MODIFIERS);
 394 
 395             short nameIndex    = fields.getShortAt(index + InstanceKlass.NAME_INDEX_OFFSET);
 396             dos.writeShort(nameIndex);
 397 
 398             short signatureIndex = fields.getShortAt(index + InstanceKlass.SIGNATURE_INDEX_OFFSET);
 399             dos.writeShort(signatureIndex);
 400             if (DEBUG) debugMessage("\tfield name = " + nameIndex + ", signature = " + signatureIndex);
 401 
 402             short fieldAttributeCount = 0;
 403             boolean hasSyn = hasSyntheticAttribute(accessFlags);
 404             if (hasSyn)
 405                 fieldAttributeCount++;
 406 
 407             short initvalIndex = fields.getShortAt(index + InstanceKlass.INITVAL_INDEX_OFFSET);
 408             if (initvalIndex != 0)
 409                 fieldAttributeCount++;
 410 
 411             short genSigIndex = fields.getShortAt(index + InstanceKlass.GENERIC_SIGNATURE_INDEX_OFFSET);
 412             if (genSigIndex != 0)
 413                 fieldAttributeCount++;
 414 
 415             dos.writeShort(fieldAttributeCount);
 416 
 417             // write synthetic, if applicable
 418             if (hasSyn)
 419                 writeSynthetic();
 420 
 421             if (initvalIndex != 0) {
 422                 writeIndex(_constantValueIndex);
 423                 dos.writeInt(2);
 424                 dos.writeShort(initvalIndex);
 425                 if (DEBUG) debugMessage("\tfield init value = " + initvalIndex);
 426             }
 427 
 428             if (genSigIndex != 0) {
 429                 writeIndex(_signatureIndex);
 430                 dos.writeInt(2);
 431                 dos.writeShort(genSigIndex);




 362             dos.writeShort(0); // no super class
 363         }
 364     }
 365     protected void writeInterfaces() throws IOException {
 366         ObjArray interfaces = klass.getLocalInterfaces();
 367         final int len = (int) interfaces.getLength();
 368 
 369         if (DEBUG) debugMessage("number of interfaces = " + len);
 370 
 371         // write interfaces count
 372         dos.writeShort((short) len);
 373         for (int i = 0; i < len; i++) {
 374            Klass k = (Klass) interfaces.getObjAt(i);
 375            Short index = (Short) classToIndex.get(k.getName().asString());
 376            dos.writeShort(index.shortValue());
 377            if (DEBUG) debugMessage("\t" + index);
 378         }
 379     }
 380 
 381     protected void writeFields() throws IOException {

 382         final int length = klass.getJavaFieldsCount();
 383 
 384         // write number of fields
 385         dos.writeShort((short) length);
 386 
 387         if (DEBUG) debugMessage("number of fields = " + length);

 388 
 389         for (int index = 0; index < length; index++) {
 390             short accessFlags    = klass.getFieldAccessFlags(index);
 391             dos.writeShort(accessFlags & (short) JVM_RECOGNIZED_FIELD_MODIFIERS);
 392 
 393             short nameIndex    = klass.getFieldNameIndex(index);
 394             dos.writeShort(nameIndex);
 395 
 396             short signatureIndex = klass.getFieldSignatureIndex(index);
 397             dos.writeShort(signatureIndex);
 398             if (DEBUG) debugMessage("\tfield name = " + nameIndex + ", signature = " + signatureIndex);
 399 
 400             short fieldAttributeCount = 0;
 401             boolean hasSyn = hasSyntheticAttribute(accessFlags);
 402             if (hasSyn)
 403                 fieldAttributeCount++;
 404 
 405             short initvalIndex = klass.getFieldInitialValueIndex(index);
 406             if (initvalIndex != 0)
 407                 fieldAttributeCount++;
 408 
 409             short genSigIndex = klass.getFieldGenericSignatureIndex(index);
 410             if (genSigIndex != 0)
 411                 fieldAttributeCount++;
 412 
 413             dos.writeShort(fieldAttributeCount);
 414 
 415             // write synthetic, if applicable
 416             if (hasSyn)
 417                 writeSynthetic();
 418 
 419             if (initvalIndex != 0) {
 420                 writeIndex(_constantValueIndex);
 421                 dos.writeInt(2);
 422                 dos.writeShort(initvalIndex);
 423                 if (DEBUG) debugMessage("\tfield init value = " + initvalIndex);
 424             }
 425 
 426             if (genSigIndex != 0) {
 427                 writeIndex(_signatureIndex);
 428                 dos.writeInt(2);
 429                 dos.writeShort(genSigIndex);


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