Class SignatureInterner
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 Summary
Modifier and TypeMethodDescriptionstatic @NonNull FieldSignaturegetFieldSignature(@NonNull ClassType declaringClass, @NonNull String name, @NonNull Type type) Returns the uniqueFieldSignaturefor the given declaring class, name and type.static @NonNull FieldSignaturegetFieldSignature(@NonNull ClassType declaringClass, @NonNull FieldSubSignature subSignature) Returns the uniqueFieldSignaturefor the given declaring class and sub-signature.static @NonNull FieldSubSignaturegetFieldSubSignature(@NonNull String name, @NonNull Type type) Returns the uniqueFieldSubSignaturefor the given name and type.static @NonNull MethodSignaturegetMethodSignature(@NonNull ClassType declaringClass, @NonNull String methodName, @NonNull Iterable<Type> parameters, @NonNull Type returnType) Returns the uniqueMethodSignaturefor the given declaring class, name, parameters and return type.static @NonNull MethodSignaturegetMethodSignature(@NonNull ClassType declaringClass, @NonNull MethodSubSignature subSignature) Returns the uniqueMethodSignaturefor the given declaring class and sub-signature.static @NonNull MethodSubSignaturegetMethodSubSignature(@NonNull String name, @NonNull Type returnType, @NonNull Iterable<? extends Type> parameterTypes) Returns the uniqueMethodSubSignaturefor the given name, return type and parameters.static @NonNull PackageNamegetPackageName(@NonNull String packageName) Returns the uniquePackageNamefor the given package name.static <T extends PackageName>
@NonNull TinternPackageName(@NonNull T packageName) Interns an already constructedPackageName.
-
Method Details
-
getPackageName
Returns the uniquePackageNamefor the given package name. -
internPackageName
Interns an already constructedPackageName. Subclasses ofPackageNamelive 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 uniqueMethodSubSignaturefor the given name, return type and parameters. -
getFieldSubSignature
public static @NonNull FieldSubSignature getFieldSubSignature(@NonNull String name, @NonNull Type type) Returns the uniqueFieldSubSignaturefor the given name and type. -
getMethodSignature
public static @NonNull MethodSignature getMethodSignature(@NonNull ClassType declaringClass, @NonNull MethodSubSignature subSignature) Returns the uniqueMethodSignaturefor 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 uniqueMethodSignaturefor the given declaring class, name, parameters and return type. -
getFieldSignature
public static @NonNull FieldSignature getFieldSignature(@NonNull ClassType declaringClass, @NonNull FieldSubSignature subSignature) Returns the uniqueFieldSignaturefor the given declaring class and sub-signature. -
getFieldSignature
public static @NonNull FieldSignature getFieldSignature(@NonNull ClassType declaringClass, @NonNull String name, @NonNull Type type) Returns the uniqueFieldSignaturefor the given declaring class, name and type.
-