Class SignatureInterner

java.lang.Object
sootup.core.signatures.SignatureInterner

public final class SignatureInterner extends Object
Hash-conses (interns) the identifier objects of sootup.core.signatures: for a given value there is at most one live instance, so equal signatures are the same object and may be compared with ==.

Interning happens on the constructed object itself, so identity follows each type's own equals/hashCode - there is no separate cache key that could drift out of sync with them. The interners hold their entries weakly, so a signature that nothing references any more is collected as usual.

This class exists in sootup.core because the constructors it calls are package-private: it is the only way to create these types, which is what makes the interning invariant hold. Most callers should not use it directly but go through an IdentifierFactory, which is the language-aware entry point. sootup.core itself has no IdentifierFactory implementation available (that lives in the language modules, which depend on this one), so code inside this module - its tests in particular - uses these methods instead.

  • Method Details

    • getPackageName

      public static @NonNull PackageName getPackageName(@NonNull String packageName)
      Returns the unique PackageName for the given package name.
    • internPackageName

      public static <T extends PackageName> @NonNull T internPackageName(@NonNull T packageName)
      Interns an already constructed PackageName. Subclasses of PackageName live in the language modules and construct themselves; they pass the result through here so that they share the interning invariant.
    • getMethodSubSignature

      public static @NonNull MethodSubSignature getMethodSubSignature(@NonNull String name, @NonNull Type returnType, @NonNull Iterable<? extends Type> parameterTypes)
      Returns the unique MethodSubSignature for the given name, return type and parameters.
    • getFieldSubSignature

      public static @NonNull FieldSubSignature getFieldSubSignature(@NonNull String name, @NonNull Type type)
      Returns the unique FieldSubSignature for the given name and type.
    • getMethodSignature

      public static @NonNull MethodSignature getMethodSignature(@NonNull ClassType declaringClass, @NonNull MethodSubSignature subSignature)
      Returns the unique MethodSignature for the given declaring class and sub-signature.
    • getMethodSignature

      public static @NonNull MethodSignature getMethodSignature(@NonNull ClassType declaringClass, @NonNull String methodName, @NonNull Iterable<Type> parameters, @NonNull Type returnType)
      Returns the unique MethodSignature for the given declaring class, name, parameters and return type.
    • getFieldSignature

      public static @NonNull FieldSignature getFieldSignature(@NonNull ClassType declaringClass, @NonNull FieldSubSignature subSignature)
      Returns the unique FieldSignature for the given declaring class and sub-signature.
    • getFieldSignature

      public static @NonNull FieldSignature getFieldSignature(@NonNull ClassType declaringClass, @NonNull String name, @NonNull Type type)
      Returns the unique FieldSignature for the given declaring class, name and type.