Example #1
0
  /**
   * Returns a string representation of this object.
   *
   * @return String representation.
   */
  @Override
  public String toString() {

    StringBuilder s = new StringBuilder(137);

    try {

      s.append('\n').append(className).append(":\n\nConstants:\n");
      for (int i = 1; i < constantPool.length; i++) {
        Constant entry = getConstantPoolEntry(i);
        s.append("    ").append(i).append(". ").append(entry.toString()).append('\n');
        if (entry.getTag() == CONSTANT_DOUBLE || entry.getTag() == CONSTANT_LONG) {
          i++;
        }
      }

      s.append("\nClass Name: ")
          .append(className)
          .append("\nSuper Name: ")
          .append(superClassName)
          .append("\n\n")
          .append(interfaceNames.length)
          .append(" interfaces\n");

      for (String interfaceName : interfaceNames) {
        s.append("    ").append(interfaceName).append('\n');
      }

      s.append('\n').append(fields.length).append(" fields\n");
      for (FieldOrMethodInfo field : fields) {
        s.append(field.toString()).append('\n');
      }

      s.append('\n').append(methods.length).append(" methods\n");
      for (FieldOrMethodInfo method : methods) {
        s.append(method.toString()).append('\n');
      }

      s.append("\nDependencies:\n");
      for (JavaPackage jPackage : jClass.getImportedPackages()) {
        s.append("    ").append(jPackage.getName()).append('\n');
      }

    } catch (Exception e) {
      e.printStackTrace();
    }

    return s.toString();
  }
Example #2
0
  private FieldOrMethodInfo parseFieldOrMethodInfo() throws IOException {

    FieldOrMethodInfo result =
        new FieldOrMethodInfo(
            in.readUnsignedShort(), in.readUnsignedShort(), in.readUnsignedShort());

    int attributesCount = in.readUnsignedShort();
    for (int a = 0; a < attributesCount; a++) {
      AttributeInfo attribute = parseAttribute();
      if ("RuntimeVisibleAnnotations".equals(attribute.name)) {
        result.runtimeVisibleAnnotations = attribute;
      }
    }

    return result;
  }