public class

JavaTypeUtil

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

Class Overview

Utility methods to generate or verify Java type names and signatures.

Summary

Public Constructors
JavaTypeUtil()
Public Methods
static void checkLegalInternalClassname(String classname)
static String generateClassnameStandardRepresentation(String classname)
Transform an internal classname representation to its external representation.
static String generateClassnameWithoutPackage(String classname)
Get the non fully-qualified internal representation of the class name.
static String generatePackageNameStandardRepresentation(String classname)
Extract the standard representation of a package name provided the internal representation of the FQ classname.
static boolean isLegalInternalClassname(String classname)
Check whether the class (or interface) name is a valid Java object type internal representation.
static IJavaType[] parseFullPrototype(IDexPrototype proto, IJavaTypeFactory tf)
Parse a DEX prototype to an array of IR/AST Types.
static SortedMap<Integer, IJavaType> parseMethodParameters(IDexUnit dex, IDexMethod m, IJavaTypeFactory tf)
Determine method parameters and register association.
static IJavaType[] parseShortyPrototype(String shorty, IJavaTypeFactory tf)
Parse a DEX shorty prototype string to an array of IR/AST Types.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public JavaTypeUtil ()

Public Methods

public static void checkLegalInternalClassname (String classname)

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

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

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

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;

public static IJavaType[] parseFullPrototype (IDexPrototype proto, IJavaTypeFactory tf)

Parse a DEX prototype to an array of IR/AST Types.

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.

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).

Returns
  • Array of types:
    • index=0 : return
    • index=1+ : arguments
    Note: the instance (first argument for non-static methods) is NOT present!