예제 #1
0
  private void writeMethodSpecification(List memberSpecifications) {
    if (memberSpecifications != null) {
      for (int index = 0; index < memberSpecifications.size(); index++) {
        MemberSpecification memberSpecification =
            (MemberSpecification) memberSpecifications.get(index);

        writer.print("    ");

        // Write out the required annotation, if any.
        if (memberSpecification.annotationType != null) {
          writer.print(ConfigurationConstants.ANNOTATION_KEYWORD);
          writer.println(ClassUtil.externalType(memberSpecification.annotationType));
          writer.print("    ");
        }

        // Write out the method access flags.
        writer.print(
            ClassUtil.externalMethodAccessFlags(
                memberSpecification.requiredUnsetAccessFlags,
                ConfigurationConstants.NEGATOR_KEYWORD));

        writer.print(
            ClassUtil.externalMethodAccessFlags(memberSpecification.requiredSetAccessFlags));

        // Write out the method name and descriptor.
        String name = memberSpecification.name;
        String descriptor = memberSpecification.descriptor;

        writer.print(
            descriptor == null
                ? name == null
                    ? ConfigurationConstants.ANY_METHOD_KEYWORD
                    : ConfigurationConstants.ANY_TYPE_KEYWORD
                        + ' '
                        + name
                        + ConfigurationConstants.OPEN_ARGUMENTS_KEYWORD
                        + ConfigurationConstants.ANY_ARGUMENTS_KEYWORD
                        + ConfigurationConstants.CLOSE_ARGUMENTS_KEYWORD
                : ClassUtil.externalFullMethodDescription(
                    ClassConstants.METHOD_NAME_INIT,
                    0,
                    name == null ? ConfigurationConstants.ANY_CLASS_MEMBER_KEYWORD : name,
                    descriptor));

        writer.println(ConfigurationConstants.SEPARATOR_KEYWORD);
      }
    }
  }
  public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod) {
    // Special cases: <clinit> and <init> are always kept unchanged.
    // We can ignore them here.
    String name = programMethod.getName(programClass);
    if (name.equals(ClassConstants.INTERNAL_METHOD_NAME_CLINIT)
        || name.equals(ClassConstants.INTERNAL_METHOD_NAME_INIT)) {
      return;
    }

    String newName = MemberObfuscator.newMemberName(programMethod);
    if (newName != null) {
      ps.println(
          "    "
              + lineNumberRange(programClass, programMethod)
              + ClassUtil.externalFullMethodDescription(
                  programClass.getName(),
                  0,
                  programMethod.getName(programClass),
                  programMethod.getDescriptor(programClass))
              + " -> "
              + newName);
    }
  }