Class Signature

java.lang.Object
proguard.classfile.Signature
All Implemented Interfaces:
Comparable<Signature>
Direct Known Subclasses:
ClassSignature, FieldSignature, MethodSignature

public abstract class Signature extends Object implements Comparable<Signature>
A signature currently can be a Method- or a FieldSignature. This class can be used to create the correct one from a ProguardCORE member object (which can also be a method or a field).
  • Field Details

    • fqn

      protected String fqn
    • prettyFqn

      protected String prettyFqn
    • className

      protected final String className
    • hashCode

      protected final int hashCode
    • referencedClass

      @Nullable protected @Nullable Clazz referencedClass
      The Clazz that the className references. May be null if there is no reference available (e.g. class is missing from the class pool).
  • Constructor Details

    • Signature

      protected Signature(String internalClassName, int hashCode)
  • Method Details

    • isIncomplete

      public abstract boolean isIncomplete()
      Check if this signature is missing information.
    • of

      public static Signature of(Clazz clazz, Member member)
      Convenience factory that takes any Member and generates the appropriate signature, i.e. MethodSignatures for Methods and FieldSignatures for Fields. If the member is null, a ClassSignature is generated.

      Note that if cacheEnabled is set to true, the generation process is delegated to computeIfAbsent(Clazz, Member) to make use of caching features.

      Parameters:
      clazz - The class containing the member
      member - The target member
      Returns:
      The corresponding Signature object
    • computeIfAbsent

      public static Signature computeIfAbsent(Clazz clazz, Member member)
      This factory uses the caching features provided by MethodSignature.computeIfAbsent(Clazz, Method), FieldSignature.computeIfAbsent(Clazz, Field) and ClassSignature.computeIfAbsent(Clazz). Only one signature is created for each distinct Method, Field or Clazz. If the same signature is requested several times, the previously created object will be returned.
      Parameters:
      clazz - The class containing the member
      member - The target member
      Returns:
      The corresponding Signature object
    • clearCache

      public static void clearCache()
      Clear the signature caches of all Signature subclasses.
    • setCacheEnabled

      public static void setCacheEnabled(boolean cacheEnabled)
      Enable or disable automatic caching in of(Clazz, Member). Existing caches are purged once caching has been disabled.
    • getFqn

      public String getFqn()
    • getPrettyFqn

      public String getPrettyFqn()
    • getPackageName

      @Deprecated public String getPackageName()
      Deprecated.
    • getExternalPackageName

      public String getExternalPackageName()
      Returns:
      the external package name (e.g., `java.lang` for `java.lang.Object`)
    • getClassName

      public String getClassName()
    • calculateFqn

      protected abstract String calculateFqn()
    • calculatePrettyFqn

      protected abstract String calculatePrettyFqn()
    • getReferencedClass

      @Nullable public @Nullable Clazz getReferencedClass()
      Returns the Clazz reference corresponding to the class returned by getClassName() or null if no reference is available (e.g. class is missing from the class pool).
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(Signature o)
      Specified by:
      compareTo in interface Comparable<Signature>
    • toString

      public String toString()
      Overrides:
      toString in class Object