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

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

Print this page
rev 7840 : 8071999: SA's buildreplayjars fail with exception
Summary: support default methods when dumping classes in SA
Reviewed-by:


 406             }
 407         }
 408     }
 409 
 410     protected boolean isSynthetic(short accessFlags) {
 411         return (accessFlags & (short) JVM_ACC_SYNTHETIC) != 0;
 412     }
 413 
 414     protected boolean hasSyntheticAttribute(short accessFlags) {
 415         // Check if flags have the attribute and if the constant pool contains an entry for it.
 416         return isSynthetic(accessFlags) && _syntheticIndex != 0;
 417     }
 418 
 419     protected void writeSynthetic() throws IOException {
 420         writeIndex(_syntheticIndex);
 421         dos.writeInt(0);
 422     }
 423 
 424     protected void writeMethods() throws IOException {
 425         MethodArray methods = klass.getMethods();
 426         final int len = methods.length();



















 427         // write number of methods
 428         dos.writeShort((short) len);
 429         if (DEBUG) debugMessage("number of methods = " + len);
 430         for (int m = 0; m < len; m++) {
 431             writeMethod(methods.at(m));
 432         }
 433     }
 434 
 435     protected void writeMethod(Method m) throws IOException {
 436         long accessFlags = m.getAccessFlags();
 437         dos.writeShort((short) (accessFlags & JVM_RECOGNIZED_METHOD_MODIFIERS));
 438         dos.writeShort((short) m.getNameIndex());
 439         dos.writeShort((short) m.getSignatureIndex());
 440         if (DEBUG) debugMessage("\tmethod name = " + m.getNameIndex() + ", signature = "
 441                         + m.getSignatureIndex());
 442 
 443         final boolean isNative = ((accessFlags & JVM_ACC_NATIVE) != 0);
 444         final boolean isAbstract = ((accessFlags & JVM_ACC_ABSTRACT) != 0);
 445 
 446         short methodAttributeCount = 0;
 447 
 448         final boolean hasSyn = hasSyntheticAttribute((short)accessFlags);
 449         if (hasSyn)
 450             methodAttributeCount++;
 451 




 406             }
 407         }
 408     }
 409 
 410     protected boolean isSynthetic(short accessFlags) {
 411         return (accessFlags & (short) JVM_ACC_SYNTHETIC) != 0;
 412     }
 413 
 414     protected boolean hasSyntheticAttribute(short accessFlags) {
 415         // Check if flags have the attribute and if the constant pool contains an entry for it.
 416         return isSynthetic(accessFlags) && _syntheticIndex != 0;
 417     }
 418 
 419     protected void writeSynthetic() throws IOException {
 420         writeIndex(_syntheticIndex);
 421         dos.writeInt(0);
 422     }
 423 
 424     protected void writeMethods() throws IOException {
 425         MethodArray methods = klass.getMethods();
 426         ArrayList<Method> valid_methods = new ArrayList<Method>();
 427         for (int i = 0; i < methods.length(); i++) {
 428             Method m = methods.at(i);
 429             long accessFlags = m.getAccessFlags();
 430             // overpass method
 431             if (accessFlags == (JVM_ACC_PUBLIC | JVM_ACC_SYNTHETIC | JVM_ACC_BRIDGE)) {
 432                 continue;
 433             }
 434             final boolean isNative = ((accessFlags & JVM_ACC_NATIVE) != 0);
 435             final boolean isAbstract = ((accessFlags & JVM_ACC_ABSTRACT) != 0);
 436             final boolean isCodeAvailable = (!isNative) && (!isAbstract);
 437             // If _codeIndex == 0 but code exists we're in an
 438             // interface and we're dealing with a default method. Skip
 439             // it.
 440             if (isCodeAvailable && _codeIndex == 0) {
 441                 continue;
 442             }
 443             valid_methods.add(m);
 444         }
 445         final int len = valid_methods.size();
 446         // write number of methods
 447         dos.writeShort((short) len);
 448         if (DEBUG) debugMessage("number of methods = " + len);
 449         for (int m = 0; m < len; m++) {
 450             writeMethod(valid_methods.get(m));
 451         }
 452     }
 453 
 454     protected void writeMethod(Method m) throws IOException {
 455         long accessFlags = m.getAccessFlags();
 456         dos.writeShort((short) (accessFlags & JVM_RECOGNIZED_METHOD_MODIFIERS));
 457         dos.writeShort((short) m.getNameIndex());
 458         dos.writeShort((short) m.getSignatureIndex());
 459         if (DEBUG) debugMessage("\tmethod name = " + m.getNameIndex() + ", signature = "
 460                         + m.getSignatureIndex());
 461 
 462         final boolean isNative = ((accessFlags & JVM_ACC_NATIVE) != 0);
 463         final boolean isAbstract = ((accessFlags & JVM_ACC_ABSTRACT) != 0);
 464 
 465         short methodAttributeCount = 0;
 466 
 467         final boolean hasSyn = hasSyntheticAttribute((short)accessFlags);
 468         if (hasSyn)
 469             methodAttributeCount++;
 470 


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