|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jode.bytecode.TypeSignature
public class TypeSignature
This class contains some static methods to handle type signatures.
A type signature is a compact textual representation of a java
types. It is described in the Java Virtual Machine Specification.
Primitive types have a one letter type signature. Type signature
of classes contains the class name. Type signatures for arrays and
methods are recursively build from the type signatures of their
elements.
Since java 5 there is a new class of type
signatures supporting generics. These can be accessed with the
getSignature methods of ClassInfo, MethodInfo and FieldInfo.
Here are a few examples:
type signature | Java type |
---|---|
Z | boolean |
B | byte |
S | short |
C | char |
I | int |
F | float |
J | long |
D | double |
Ljava/lang/Object; |
java.lang.Object |
[[I | int[][] |
(Ljava/lang/Object;I)V |
method with argument types Object and
int and void return type. |
()I |
method without arguments
and int return type. |
<E:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/Collection<TE;>; |
|
generic class over <E extends Object> extending Object and implementing Collections<E> | |
<T:Ljava/lang/Object;>([TT;)[TT; |
|
generic method over <T extends Object> taking an array of T as parameters and returning an array of T. |
Constructor Summary | |
---|---|
TypeSignature()
|
Method Summary | |
---|---|
static void |
checkMethodTypeSig(String typesig)
Checks whether a given type signature is a valid method type signature. |
static void |
checkTypeSig(String typesig)
Checks whether a given type signature is a valid (not method) type signature. |
static Class |
getClass(String typeSig)
Generates a Class object for a type signature. |
static ClassInfo |
getClassInfo(ClassPath classpath,
String typeSig)
Gets the ClassInfo for a class type. |
static Object |
getDefaultValue(String typeSig)
Gets the default value an object of the given type has. |
static String |
getElementType(String typeSig)
Gets the element type of an array. |
static int |
getParameterSize(String methodTypeSig)
Gets the number of words the parameters for the given method type signature takes. |
static String[] |
getParameterTypes(String methodTypeSig)
Gets the parameter type signatures of the given method signature. |
static int |
getReturnSize(String methodTypeSig)
Gets the size of the return type of the given method in words. |
static String |
getReturnType(String methodTypeSig)
Gets the return type for a method signature |
static String |
getSignature(Class clazz)
Generates the type signature of the given Class. |
static String |
getSignature(Class[] paramT,
Class returnT)
Generates a method signature. |
static int |
getTypeSize(String typeSig)
Returns the number of words, an object of the given simple type signature takes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TypeSignature()
Method Detail |
---|
public static String getSignature(Class clazz)
clazz
- a java.lang.Class, this may also be a primitive or
array type.
public static String getSignature(Class[] paramT, Class returnT)
paramT
- the java.lang.Class of the parameter types of the method.returnT
- the java.lang.Class of the return type of the method.
public static Class getClass(String typeSig) throws ClassNotFoundException
typeSig
- a single type signature
ClassNotFoundException
public static int getTypeSize(String typeSig)
public static String getElementType(String typeSig)
typeSig
- type signature of the array.
IllegalArgumentException
- if typeSig is not an array
type signature.public static ClassInfo getClassInfo(ClassPath classpath, String typeSig)
classpath
- the classpath in which the ClassInfo is searched.typeSig
- type signature of the class.
IllegalArgumentException
- if typeSig is not an class
type signature.public static int getParameterSize(String methodTypeSig)
methodTypeSig
- the method type signature.
public static int getReturnSize(String methodTypeSig)
methodTypeSig
- the method type signature.
public static String[] getParameterTypes(String methodTypeSig)
methodTypeSig
- the method type signature.
public static String getReturnType(String methodTypeSig)
methodTypeSig
- the method signature.
public static Object getDefaultValue(String typeSig)
typeSig
- the type signature.
IllegalArgumentException
- if this is a method type signature.public static void checkTypeSig(String typesig) throws IllegalArgumentException
typesig
- the type signature.
NullPointerException
- if typeSig is null.
IllegalArgumentException
- if typeSig is not a valid
type signature or if it's a method type signature.public static void checkMethodTypeSig(String typesig) throws IllegalArgumentException
typesig
- the type signature.
NullPointerException
- if typeSig is null.
IllegalArgumentException
- if typeSig is not a valid
method type signature.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |