コード例 #1
0
 /**
  * Reads a <code>MethodInfo</code> from an input stream.
  *
  * @param cf The class file defining the method.
  * @param in The input stream to read from.
  * @return The method information read.
  * @throws IOException If an IO error occurs.
  */
 public static MethodInfo read(ClassFile cf, DataInputStream in) throws IOException {
   int accessFlags = in.readUnsignedShort();
   int nameIndex = in.readUnsignedShort();
   int descriptorIndex = in.readUnsignedShort();
   MethodInfo mi = new MethodInfo(cf, accessFlags, nameIndex, descriptorIndex);
   int attrCount = in.readUnsignedShort();
   for (int j = 0; j < attrCount; j++) {
     AttributeInfo ai = mi.readAttribute(in);
     if (ai instanceof Signature) {
       mi.signatureAttr = (Signature) ai;
     } else if (ai instanceof Code) {
       mi.codeAttr = (Code) ai;
     } else if (ai != null) {
       mi.addAttribute(ai);
     }
   }
   return mi;
 }
コード例 #2
0
  /**
   * Finds the original method name(s), appending the first one to the out line, and any additional
   * alternatives to the extra lines.
   */
  private void originalMethodName(
      String className,
      String obfuscatedMethodName,
      int lineNumber,
      String type,
      String arguments,
      StringBuffer outLine,
      List extraOutLines) {
    int extraIndent = -1;

    // Class name -> obfuscated method names.
    Map methodMap = (Map) classMethodMap.get(className);
    if (methodMap != null) {
      // Obfuscated method names -> methods.
      Set methodSet = (Set) methodMap.get(obfuscatedMethodName);
      if (methodSet != null) {
        // Find all matching methods.
        Iterator methodInfoIterator = methodSet.iterator();
        while (methodInfoIterator.hasNext()) {
          MethodInfo methodInfo = (MethodInfo) methodInfoIterator.next();
          if (methodInfo.matches(lineNumber, type, arguments)) {
            // Is this the first matching method?
            if (extraIndent < 0) {
              extraIndent = outLine.length();

              // Append the first original name.
              if (verbose) {
                outLine.append(methodInfo.type).append(' ');
              }
              outLine.append(methodInfo.originalName);
              if (verbose) {
                outLine.append('(').append(methodInfo.arguments).append(')');
              }
            } else {
              // Create an additional line with the proper
              // indentation.
              StringBuffer extraBuffer = new StringBuffer();
              for (int counter = 0; counter < extraIndent; counter++) {
                extraBuffer.append(' ');
              }

              // Append the alternative name.
              if (verbose) {
                extraBuffer.append(methodInfo.type).append(' ');
              }
              extraBuffer.append(methodInfo.originalName);
              if (verbose) {
                extraBuffer.append('(').append(methodInfo.arguments).append(')');
              }

              // Store the additional line.
              extraOutLines.add(extraBuffer);
            }
          }
        }
      }
    }

    // Just append the obfuscated name if we haven't found any matching
    // methods.
    if (extraIndent < 0) {
      outLine.append(obfuscatedMethodName);
    }
  }