Class JavaTypeUtil

java.lang.Object
com.pnfsoftware.jeb.core.units.code.java.JavaTypeUtil

public class JavaTypeUtil extends Object
Utility methods to generate or verify Java type names and signatures.
  • Constructor Details

    • JavaTypeUtil

      public JavaTypeUtil()
  • Method Details

    • isLegalInternalClassname

      public static boolean isLegalInternalClassname(String classname)
      Check whether the class (or interface) name is a valid Java object type internal representation.

      Example: Labc/def/Bla;

      Parameters:
      classname -
      Returns:
    • checkLegalInternalClassname

      public static void checkLegalInternalClassname(String classname)
      Parameters:
      classname -
    • generateClassnameStandardRepresentation

      public static String generateClassnameStandardRepresentation(String classname)
      Transform an internal classname representation to its external representation.

      Examples:

      • Lcom/bla/Animal; becomes com.bla.Animal
      • Lcom/bla/Animal$Trainer; becomes com.bla.Animal$Trainer
      Parameters:
      classname - internal representation
      Returns:
    • generateClassnameWithoutPackage

      public static String generateClassnameWithoutPackage(String classname)
      Get the non fully-qualified internal representation of the class name.
      Example: Lcom/pnfsoftware/Raasta; will generate LRaasta;
      Parameters:
      classname - internal representation
      Returns:
    • generatePackageNameStandardRepresentation

      public static String generatePackageNameStandardRepresentation(String classname)
      Extract the standard representation of a package name provided the internal representation of the FQ classname.
      Example: Lcom/foo/Crap$Bla; will generate com.foo
      Parameters:
      classname - internal representation
      Returns:
      standard representation of the package containing the provided classname
    • parseShortyPrototype

      public static IJavaType[] parseShortyPrototype(String shorty, IJavaTypeFactory tf)
      Parse a DEX shorty prototype string to an array of IR/AST Types. Note that a type factory is not needed as no detailed complex type is created (shorty prototypes simply indicate if a type is an object, they do not define the object type itself).
      Parameters:
      shorty -
      tf -
      Returns:
      Array of types:
      • index=0 : return
      • index=1+ : arguments
      Note: the instance (first argument for non-static methods) is NOT present!
    • parseFullPrototype

      public static IJavaType[] parseFullPrototype(IDexPrototype proto, IJavaTypeFactory tf)
      Parse a DEX prototype to an array of IR/AST Types.
      Parameters:
      proto -
      tf -
      Returns:
    • parseMethodParameters

      public static SortedMap<Integer,IJavaType> parseMethodParameters(IDexUnit dex, IDexMethod m, IJavaTypeFactory tf)
      Determine method parameters and register association.
      Parameters:
      dex - DEX Parser
      m - internal, non-abstract method (must contain bytecode)
      Returns:
      Map of (register number, parameter type), including the 'this' pointer if any. The return value, if any, is mapped to fake register number -1.
      Throws:
      RuntimeException - If the frame is too small, or the type cannot be processed.