Class JavaIdentifierFactory

java.lang.Object
sootup.java.core.JavaIdentifierFactory
All Implemented Interfaces:
IdentifierFactory
Direct Known Subclasses:
JavaModuleIdentifierFactory

public class JavaIdentifierFactory extends Object implements IdentifierFactory
The Java-specific implementation of IdentifierFactory. Should not be used for other languages.
  • Field Details

  • Method Details

    • getInstance

      public static JavaIdentifierFactory getInstance()
    • getClassType

      public JavaClassType getClassType(String className, String packageName)
      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 interface IdentifierFactory
      Parameters:
      className - the simple class name
      packageName - the Java package name; must not be null use empty string for the default package PackageName.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

      public JavaClassType getClassType(String fullyQualifiedClassName)
      Always creates a new ClassSignature.
      Specified by:
      getClassType in interface IdentifierFactory
      Parameters:
      fullyQualifiedClassName - the fully-qualified name of the class
      Returns:
      a ClassSignature for a Java Class
    • getType

      public Type getType(String typeDesc)
      Returns a Type which can be a JavaClassType,PrimitiveType, VoidType, or NullType.
      Specified by:
      getType in interface IdentifierFactory
      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

      @Nonnull public Optional<PrimitiveType> getPrimitiveType(@Nonnull String typeName)
      Description copied from interface: IdentifierFactory
      Gets the primitive type.
      Specified by:
      getPrimitiveType in interface IdentifierFactory
      Parameters:
      typeName - the type name
      Returns:
      the primitive type
    • getAllPrimitiveTypes

      @Nonnull public Collection<PrimitiveType> getAllPrimitiveTypes()
    • getBoxedType

      @Nonnull public JavaClassType getBoxedType(@Nonnull PrimitiveType primitiveType)
      Specified by:
      getBoxedType in interface IdentifierFactory
    • getArrayType

      public ArrayType getArrayType(Type baseType, int dim)
      Description copied from interface: IdentifierFactory
      Gets the array type.
      Specified by:
      getArrayType in interface IdentifierFactory
      Parameters:
      baseType - the base type
      dim - the dim
      Returns:
      the array type
    • getPackageName

      public PackageName getPackageName(@Nonnull String packageName)
      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 interface IdentifierFactory
      Parameters:
      packageName - the Java package name; must not be null use empty string for the default package PackageName.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 interface IdentifierFactory
      Parameters:
      fullyQualifiedNameDeclClass - the fully-qualified name of the declaring class
      methodName - the method's name
      fqReturnType - the fully-qualified name of the return type or a primitive's name
      parameters - 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 interface IdentifierFactory
      Parameters:
      declaringClassSignature - the ClassSignature of the declaring class
      methodName - the method's name
      fqReturnType - the fully-qualified name of the return type or a primitive's name
      parameters - 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 interface IdentifierFactory
      Parameters:
      declaringClassSignature - the declaring class signature
      methodName - the method name
      fqReturnType - the fq return type
      parameters - the parameters
      Returns:
      the method signature
    • getMethodSignature

      @Nonnull public MethodSignature getMethodSignature(@Nonnull ClassType declaringClassSignature, @Nonnull MethodSubSignature subSignature)
      Description copied from interface: IdentifierFactory
      Gets the method signature.
      Specified by:
      getMethodSignature in interface IdentifierFactory
      Parameters:
      declaringClassSignature - the declaring class signature
      subSignature - the sub signature
      Returns:
      the method signature
    • parseMethodSignature

      @Nonnull public MethodSignature parseMethodSignature(@Nonnull String methodSignature)
      Parses a MethodSignature 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 interface IdentifierFactory
      Parameters:
      methodSignature - A Soot- or JavaDoc-like method signature.
      Returns:
      The parsed MethodSignature.
    • getMethodSubSignature

      @Nonnull public 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 interface IdentifierFactory
      Parameters:
      name - the name
      returnType - the return type
      parameterSignatures - the parameter signatures
      Returns:
      the method sub signature
    • parseMethodSubSignature

      @Nonnull public MethodSubSignature parseMethodSubSignature(@Nonnull String subSignature)
      Parses a MethodSubSignature 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 interface IdentifierFactory
      Parameters:
      subSignature - A Soot- or Kotlin-like method sub-signature.
      Returns:
      The parsed MethodSubSignature.
    • parseFieldSignature

      @Nonnull public FieldSignature parseFieldSignature(@Nonnull String fieldSignature)
      Parses a MethodSignature 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 interface IdentifierFactory
      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 interface IdentifierFactory
      Parameters:
      fieldName - the field name
      declaringClassSignature - the declaring class signature
      fieldType - 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 interface IdentifierFactory
      Parameters:
      fieldName - the field name
      declaringClassSignature - the declaring class signature
      fieldType - the field type
      Returns:
      the field signature
    • getFieldSignature

      @Nonnull public FieldSignature getFieldSignature(@Nonnull ClassType declaringClassSignature, @Nonnull FieldSubSignature subSignature)
      Description copied from interface: IdentifierFactory
      Gets the field signature.
      Specified by:
      getFieldSignature in interface IdentifierFactory
      Parameters:
      declaringClassSignature - the declaring class signature
      subSignature - the sub signature
      Returns:
      the field signature
    • getFieldSubSignature

      @Nonnull public FieldSubSignature getFieldSubSignature(@Nonnull String name, @Nonnull Type type)
      Description copied from interface: IdentifierFactory
      Gets the field sub signature.
      Specified by:
      getFieldSubSignature in interface IdentifierFactory
      Parameters:
      name - the name
      type - the type
      Returns:
      the field sub signature
    • parseFieldSubSignature

      @Nonnull public FieldSubSignature parseFieldSubSignature(@Nonnull String subSignature)
      Parses a FieldSubSignature 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 interface IdentifierFactory
      Parameters:
      subSignature - A Soot- or Kotlin-like method sub-signature.
      Returns:
      The parsed FieldSubSignature.
    • getStaticInitializerSignature

      public MethodSignature getStaticInitializerSignature(ClassType declaringClassSignature)
      Description copied from interface: IdentifierFactory
      Gets the static initializer method signature.
      Specified by:
      getStaticInitializerSignature in interface IdentifierFactory
      Parameters:
      declaringClassSignature - the declaring class signature
      Returns:
      the static initializer method signature
    • isStaticInitializerSubSignature

      public boolean isStaticInitializerSubSignature(@Nonnull MethodSubSignature methodSubSignature)
      Specified by:
      isStaticInitializerSubSignature in interface IdentifierFactory
    • isConstructorSignature

      public boolean isConstructorSignature(@Nonnull MethodSignature methodSignature)
      Specified by:
      isConstructorSignature in interface IdentifierFactory
    • isConstructorSubSignature

      public boolean isConstructorSubSignature(@Nonnull MethodSubSignature methodSubSignature)
      Specified by:
      isConstructorSubSignature in interface IdentifierFactory
    • isMainSubSignature

      public boolean isMainSubSignature(@Nonnull MethodSubSignature methodSubSignature)
      Specified by:
      isMainSubSignature in interface IdentifierFactory