public final class Util extends Object
Modifier and Type | Method and Description |
---|---|
static Pair<boolean[],boolean[]> |
computeBasicBlocks(IInstruction[] instructions,
ExceptionHandler[][] handlers) |
static String |
computeSignature(Class<?>[] params,
Class<?> result)
Given a Java Method, compute the VM-style type signature.
|
static void |
error(String s)
General "print an error" routine.
|
static Method |
findMethod(Class<?> c,
String name) |
static Method |
findMethod(Class<?> c,
String name,
Class<?>[] paramTypes) |
static String[] |
getParamsTypes(String thisClassType,
String type)
Extract the types of the parameters given by method signature "type".
|
static String[] |
getParamsTypesInLocals(String thisClassType,
String type)
Compute the types of the local variables on entry to a method.
|
static int |
getParamsWordSize(String type)
Compute the total number of JVM "stack words" occupied by the method parameters for method signature "type".
|
static String |
getReturnType(String s)
Get the return type from a method signature.
|
static String |
getStackType(String t)
Compute the promoted type that the JVM uses to manipulate values of type "t" on its working stack.
|
static byte |
getWordSize(String s) |
static boolean |
isArrayType(String t) |
static boolean |
isPrimitiveType(String t) |
static String |
makeArray(String t)
Compute the type "array of t".
|
static String |
makeClass(String t)
Convert a JVM type name back into a Java class name.
|
static GetInstruction |
makeGet(Class<?> c,
String name)
Make an Instruction which loads the value of a field, given its name and Java Class.
|
static InvokeInstruction |
makeInvoke(Class<?> c,
String name)
Make an Instruction which calls a method, given its name and Java Class.
|
static InvokeInstruction |
makeInvoke(Class<?> c,
String name,
Class<?>[] paramTypes)
Make an Instruction which calls a method, given its name, Java Class, and a list of parameter classes to use for overload
resolution.
|
static PutInstruction |
makePut(Class<?> c,
String name)
Make an Instruction which stores the value of a field, given its name and Java Class.
|
static String |
makeType(Class<?> c)
Compute the JVM type name for an actual Java class.
|
static String |
makeType(String c)
Convert a fully-qualified Java class name ('.' separated) into an internal JVM type name ('/' separated, starting with 'L' and
ending with ';').
|
static String |
makeTypeAll(String c)
Convert a fully-qualified Java type name (either primitive or class name, '.' separated) into an internal JVM type name (one
letter for primitive and '/' separated, starting with 'L' and ending with ';' for class name).
|
static byte[] |
readFully(InputStream s) |
static void |
readFully(InputStream s,
byte[] bytes) |
public static byte getWordSize(String s)
IllegalArgumentException
- if s is nullpublic static int getParamsWordSize(String type) throws IllegalArgumentException
IllegalArgumentException
- if type is nullpublic static String makeType(String c)
IllegalArgumentException
- if c is nullpublic static String makeTypeAll(String c)
public static String makeClass(String t) throws IllegalArgumentException
IllegalArgumentException
- if t is nullpublic static String makeType(Class<?> c)
IllegalArgumentException
- if c is nullpublic static String[] getParamsTypes(String thisClassType, String type) throws IllegalArgumentException
thisClassType
- null if the method is static, otherwise the type of "this"IllegalArgumentException
- if type == nullpublic static String[] getParamsTypesInLocals(String thisClassType, String type) throws IllegalArgumentException
IllegalArgumentException
- if type == nullpublic static String getStackType(String t)
IllegalArgumentException
- if t is nullpublic static boolean isArrayType(String t)
public static boolean isPrimitiveType(String t)
public static String getReturnType(String s)
IllegalArgumentException
- if s is nullpublic static void error(String s)
public static String computeSignature(Class<?>[] params, Class<?> result) throws IllegalArgumentException
IllegalArgumentException
- if params == nullpublic static GetInstruction makeGet(Class<?> c, String name)
IllegalArgumentException
- if c is nullpublic static PutInstruction makePut(Class<?> c, String name)
IllegalArgumentException
- if c is nullpublic static InvokeInstruction makeInvoke(Class<?> c, String name, Class<?>[] paramTypes)
IllegalArgumentException
- if name is nullpublic static InvokeInstruction makeInvoke(Class<?> c, String name)
IllegalArgumentException
- if name is nullpublic static void readFully(InputStream s, byte[] bytes) throws IllegalArgumentException, IllegalArgumentException, IOException
IllegalArgumentException
IOException
public static byte[] readFully(InputStream s) throws IOException
IOException
public static Pair<boolean[],boolean[]> computeBasicBlocks(IInstruction[] instructions, ExceptionHandler[][] handlers)