Package sootup.java.core
Class JavaIdentifierFactory
java.lang.Object
sootup.java.core.JavaIdentifierFactory
- All Implemented Interfaces:
IdentifierFactory
- Direct Known Subclasses:
JavaModuleIdentifierFactory
The Java-specific implementation of
IdentifierFactory
. Should not be used for other
languages.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NonNull com.google.common.cache.Cache<String,
JavaClassType> Caches class typesprotected final @NonNull com.google.common.cache.Cache<String,
PackageName> Caches the created PackageNames for packages.protected final @NonNull Map<String,
PrimitiveType> static final @NonNull MethodSubSignature
-
Method Summary
Modifier and TypeMethodDescription@NonNull Collection<PrimitiveType>
getArrayType
(Type baseType, int dim) Gets the array type.@NonNull JavaClassType
getBoxedType
(@NonNull PrimitiveType primitiveType) getClassType
(String fullyQualifiedClassName) Always creates a new ClassSignature.getClassType
(String className, String packageName) Always creates a new ClassSignature.@NonNull FieldSignature
getFieldSignature
(@NonNull ClassType declaringClassSignature, @NonNull FieldSubSignature subSignature) Gets the field signature.getFieldSignature
(String fieldName, ClassType declaringClassSignature, String fieldType) Gets the field signature.getFieldSignature
(String fieldName, ClassType declaringClassSignature, Type fieldType) Gets the field signature.@NonNull FieldSubSignature
getFieldSubSignature
(@NonNull String name, @NonNull Type type) Gets the field sub signature.static JavaIdentifierFactory
@NonNull MethodSignature
getMethodSignature
(@NonNull ClassType declaringClassSignature, @NonNull MethodSubSignature subSignature) Gets the method signature.getMethodSignature
(String fullyQualifiedNameDeclClass, String methodName, String fqReturnType, List<String> parameters) Always creates a new MethodSignature AND a new ClassSignature.getMethodSignature
(ClassType declaringClassSignature, String methodName, String fqReturnType, List<String> parameters) Always creates a new MethodSignature reusing the given ClassSignature.getMethodSignature
(ClassType declaringClassSignature, String methodName, Type fqReturnType, List<Type> parameters) Gets the method signature.@NonNull MethodSubSignature
getMethodSubSignature
(@NonNull String name, @NonNull Type returnType, @NonNull Iterable<? extends Type> parameterSignatures) Gets the method sub signature.getPackageName
(@NonNull String packageName) Returns a unique PackageName.@NonNull Optional<PrimitiveType>
getPrimitiveType
(@NonNull String typeName) Gets the primitive type.getStaticInitializerSignature
(ClassType declaringClassSignature) Gets the static initializer method signature.boolean
isConstructorSignature
(@NonNull MethodSignature methodSignature) boolean
isConstructorSubSignature
(@NonNull MethodSubSignature methodSubSignature) boolean
isMainSubSignature
(@NonNull MethodSubSignature methodSubSignature) boolean
isStaticInitializerSubSignature
(@NonNull MethodSubSignature methodSubSignature) @NonNull FieldSignature
parseFieldSignature
(@NonNull String fieldSignature) Parses aMethodSignature
either from a Soot or from a JavaDoc-like signature specification.@NonNull FieldSubSignature
parseFieldSubSignature
(@NonNull String subSignature) Parses aFieldSubSignature
either from a Soot or from a JavaDoc-like signature specification.@NonNull MethodSignature
parseMethodSignature
(@NonNull String methodSignature) Parses aMethodSignature
either from a Soot or from a JavaDoc-like signature specification.@NonNull MethodSubSignature
parseMethodSubSignature
(@NonNull String subSignature) Parses aMethodSubSignature
either from a Soot or from a JavaDoc-like signature specification.
-
Field Details
-
STATIC_INITIALIZER
-
packageCache
Caches the created PackageNames for packages. -
classTypeCache
Caches class types -
primitiveTypeMap
-
-
Method Details
-
getInstance
-
getClassType
Always creates a new ClassSignature. In opposite to PackageSignatures, ClassSignatures are not cached because the are unique per class, and thus reusing them does not make sense.- Specified by:
getClassType
in interfaceIdentifierFactory
- Parameters:
className
- the simple class namepackageName
- the Java package name; must not be null use empty string for the default packagePackageName.DEFAULT_PACKAGE
the Java package name- Returns:
- a ClassSignature for a Java class
- Throws:
NullPointerException
- if the given package name is null. Use the empty string to denote the default package.
-
getClassType
Always creates a new ClassSignature.- Specified by:
getClassType
in interfaceIdentifierFactory
- Parameters:
fullyQualifiedClassName
- the fully-qualified name of the class- Returns:
- a ClassSignature for a Java Class
-
getType
- Specified by:
getType
in interfaceIdentifierFactory
- Parameters:
typeDesc
- the fully-qualified name of the class or for primitives its simple name, e.g., int, null, void, ...- Returns:
- the type signature
-
getPrimitiveType
Description copied from interface:IdentifierFactory
Gets the primitive type.- Specified by:
getPrimitiveType
in interfaceIdentifierFactory
- Parameters:
typeName
- the type name- Returns:
- the primitive type
-
getAllPrimitiveTypes
-
getBoxedType
- Specified by:
getBoxedType
in interfaceIdentifierFactory
-
getArrayType
Description copied from interface:IdentifierFactory
Gets the array type.- Specified by:
getArrayType
in interfaceIdentifierFactory
- Parameters:
baseType
- the base typedim
- the dim- Returns:
- the array type
-
getPackageName
Returns a unique PackageName. The method looks up a cache if it already contains a signature with the given package name. If the cache lookup fails a new signature is created.- Specified by:
getPackageName
in interfaceIdentifierFactory
- Parameters:
packageName
- the Java package name; must not be null use empty string for the default packagePackageName.DEFAULT_PACKAGE
- Returns:
- a PackageName
- Throws:
NullPointerException
- if the given package name is null. Use the empty string to denote the default package.
-
getMethodSignature
public MethodSignature getMethodSignature(String fullyQualifiedNameDeclClass, String methodName, String fqReturnType, List<String> parameters) Always creates a new MethodSignature AND a new ClassSignature.- Specified by:
getMethodSignature
in interfaceIdentifierFactory
- Parameters:
fullyQualifiedNameDeclClass
- the fully-qualified name of the declaring classmethodName
- the method's namefqReturnType
- the fully-qualified name of the return type or a primitive's nameparameters
- the methods parameters fully-qualified name or a primitive's name- Returns:
- a MethodSignature
-
getMethodSignature
public MethodSignature getMethodSignature(ClassType declaringClassSignature, String methodName, String fqReturnType, List<String> parameters) Always creates a new MethodSignature reusing the given ClassSignature.- Specified by:
getMethodSignature
in interfaceIdentifierFactory
- Parameters:
declaringClassSignature
- the ClassSignature of the declaring classmethodName
- the method's namefqReturnType
- the fully-qualified name of the return type or a primitive's nameparameters
- the methods parameters fully-qualified name or a primitive's name- Returns:
- a MethodSignature
-
getMethodSignature
public MethodSignature getMethodSignature(ClassType declaringClassSignature, String methodName, Type fqReturnType, List<Type> parameters) Description copied from interface:IdentifierFactory
Gets the method signature.- Specified by:
getMethodSignature
in interfaceIdentifierFactory
- Parameters:
declaringClassSignature
- the declaring class signaturemethodName
- the method namefqReturnType
- the fq return typeparameters
- the parameters- Returns:
- the method signature
-
getMethodSignature
public @NonNull MethodSignature getMethodSignature(@NonNull ClassType declaringClassSignature, @NonNull MethodSubSignature subSignature) Description copied from interface:IdentifierFactory
Gets the method signature.- Specified by:
getMethodSignature
in interfaceIdentifierFactory
- Parameters:
declaringClassSignature
- the declaring class signaturesubSignature
- the sub signature- Returns:
- the method signature
-
parseMethodSignature
Parses aMethodSignature
either from a Soot or from a JavaDoc-like signature specification.Soot syntax:
<CLASS: RETURNTYPE METHOD(PARAM1, PARAM2, PARAM3)>
JavaDoc-like syntax:
CLASS#METHOD(PARAM1, PARAM2, PARAM3): RETURNTYPE
Soot syntax examples:
<de.upb.sootup.signatures.Remove: de.upb.sootup.signatures.MethodSignature parseMethodSignature(java.lang.String)> <de.upb.sootup.signatures.Remove: de.upb.sootup.signatures.MethodSignature getMethodSignature(java.lang.String, de.upb.sootup.types.JavaClassType)>
JavaDoc-like syntax examples:
de.upb.sootup.signatures.Remove#parseMethodSignature(java.lang.String): de.upb.sootup.signatures.MethodSignature de.upb.sootup.signatures.Remove#getMethodSignature(java.lang.String, de.upb.sootup.types.JavaClassType): de.upb.sootup.signatures.MethodSignature
- Specified by:
parseMethodSignature
in interfaceIdentifierFactory
- Parameters:
methodSignature
- A Soot- or JavaDoc-like method signature.- Returns:
- The parsed
MethodSignature
.
-
getMethodSubSignature
public @NonNull MethodSubSignature getMethodSubSignature(@NonNull String name, @NonNull Type returnType, @NonNull Iterable<? extends Type> parameterSignatures) Description copied from interface:IdentifierFactory
Gets the method sub signature.- Specified by:
getMethodSubSignature
in interfaceIdentifierFactory
- Parameters:
name
- the namereturnType
- the return typeparameterSignatures
- the parameter signatures- Returns:
- the method sub signature
-
parseMethodSubSignature
Parses aMethodSubSignature
either from a Soot or from a JavaDoc-like signature specification.Soot syntax:
<RETURNTYPE METHOD(PARAM1, PARAM2, PARAM3)>
JavaDoc-like syntax:
#METHOD(PARAM1, PARAM2, PARAM3): RETURNTYPE
Soot syntax examples:
>de.upb.sootup.signatures.MethodSignature parseMethodSignature(java.lang.String)> >de.upb.sootup.signatures.MethodSignature getMethodSignature(java.lang.String, de.upb.sootup.types.JavaClassType)>
JavaDoc-like syntax examples:
#parseMethodSignature(java.lang.String): de.upb.sootup.signatures.MethodSignature #getMethodSignature(java.lang.String, de.upb.sootup.types.JavaClassType): de.upb.sootup.signatures.MethodSignature
- Specified by:
parseMethodSubSignature
in interfaceIdentifierFactory
- Parameters:
subSignature
- A Soot- or Kotlin-like method sub-signature.- Returns:
- The parsed
MethodSubSignature
.
-
parseFieldSignature
Parses aMethodSignature
either from a Soot or from a JavaDoc-like signature specification.Soot syntax:
<CLASS: TYPE FIELD>
JavaDoc-like syntax:
CLASS#FIELD: TYPE
Soot syntax examples:
<de.upb.sootup.signatures.Remove: de.upb.sootup.signatures.Remove INSTANCE>
JavaDoc-like syntax examples:
de.upb.sootup.signatures.Remove#INSTANCE: de.upb.sootup.signatures.Remove
- Specified by:
parseFieldSignature
in interfaceIdentifierFactory
- Parameters:
fieldSignature
- A Soot- or JavaDoc-like field signature.- Returns:
- The parsed
MethodSignature
.
-
getFieldSignature
public FieldSignature getFieldSignature(String fieldName, ClassType declaringClassSignature, String fieldType) Description copied from interface:IdentifierFactory
Gets the field signature.- Specified by:
getFieldSignature
in interfaceIdentifierFactory
- Parameters:
fieldName
- the field namedeclaringClassSignature
- the declaring class signaturefieldType
- the field type- Returns:
- the field signature
-
getFieldSignature
public FieldSignature getFieldSignature(String fieldName, ClassType declaringClassSignature, Type fieldType) Description copied from interface:IdentifierFactory
Gets the field signature.- Specified by:
getFieldSignature
in interfaceIdentifierFactory
- Parameters:
fieldName
- the field namedeclaringClassSignature
- the declaring class signaturefieldType
- the field type- Returns:
- the field signature
-
getFieldSignature
public @NonNull FieldSignature getFieldSignature(@NonNull ClassType declaringClassSignature, @NonNull FieldSubSignature subSignature) Description copied from interface:IdentifierFactory
Gets the field signature.- Specified by:
getFieldSignature
in interfaceIdentifierFactory
- Parameters:
declaringClassSignature
- the declaring class signaturesubSignature
- the sub signature- Returns:
- the field signature
-
getFieldSubSignature
Description copied from interface:IdentifierFactory
Gets the field sub signature.- Specified by:
getFieldSubSignature
in interfaceIdentifierFactory
- Parameters:
name
- the nametype
- the type- Returns:
- the field sub signature
-
parseFieldSubSignature
Parses aFieldSubSignature
either from a Soot or from a JavaDoc-like signature specification.Soot syntax:
<TYPE FIELD>
JavaDoc-like syntax:
#FIELD: TYPE
Soot syntax example:
<de.upb.sootup.signatures.Remove INSTANCE>
JavaDoc-like syntax example:
#INSTANCE: de.upb.sootup.signatures.Remove
- Specified by:
parseFieldSubSignature
in interfaceIdentifierFactory
- Parameters:
subSignature
- A Soot- or Kotlin-like method sub-signature.- Returns:
- The parsed
FieldSubSignature
.
-
getStaticInitializerSignature
Description copied from interface:IdentifierFactory
Gets the static initializer method signature.- Specified by:
getStaticInitializerSignature
in interfaceIdentifierFactory
- Parameters:
declaringClassSignature
- the declaring class signature- Returns:
- the static initializer method signature
-
isStaticInitializerSubSignature
- Specified by:
isStaticInitializerSubSignature
in interfaceIdentifierFactory
-
isConstructorSignature
- Specified by:
isConstructorSignature
in interfaceIdentifierFactory
-
isConstructorSubSignature
- Specified by:
isConstructorSubSignature
in interfaceIdentifierFactory
-
isMainSubSignature
- Specified by:
isMainSubSignature
in interfaceIdentifierFactory
-