|
Jode 1.90-CVS Build Aug 6, 2004 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jode.bytecode.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(java.lang.String typesig)
Checks whether a given type signature is a valid method type signature. |
static void |
checkTypeSig(java.lang.String typesig)
Checks whether a given type signature is a valid (not method) type signature. |
static java.lang.Class |
getClass(java.lang.String typeSig)
Generates a Class object for a type signature. |
static ClassInfo |
getClassInfo(ClassPath classpath,
java.lang.String typeSig)
Gets the ClassInfo for a class type. |
static java.lang.Object |
getDefaultValue(java.lang.String typeSig)
Gets the default value an object of the given type has. |
static java.lang.String |
getElementType(java.lang.String typeSig)
Gets the element type of an array. |
static int |
getParameterSize(java.lang.String methodTypeSig)
Gets the number of words the parameters for the given method type signature takes. |
static java.lang.String[] |
getParameterTypes(java.lang.String methodTypeSig)
Gets the parameter type signatures of the given method signature. |
static int |
getReturnSize(java.lang.String methodTypeSig)
Gets the size of the return type of the given method in words. |
static java.lang.String |
getReturnType(java.lang.String methodTypeSig)
Gets the return type for a method signature |
static java.lang.String |
getSignature(java.lang.Class clazz)
Generates the type signature of the given Class. |
static java.lang.String |
getSignature(java.lang.Class[] paramT,
java.lang.Class returnT)
Generates a method signature. |
static int |
getTypeSize(java.lang.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 java.lang.String getSignature(java.lang.Class clazz)
clazz
- a java.lang.Class, this may also be a primitive or
array type.
public static java.lang.String getSignature(java.lang.Class[] paramT, java.lang.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 java.lang.Class getClass(java.lang.String typeSig) throws java.lang.ClassNotFoundException
typeSig
- a single type signature
java.lang.ClassNotFoundException
public static int getTypeSize(java.lang.String typeSig)
public static java.lang.String getElementType(java.lang.String typeSig)
typeSig
- type signature of the array.
java.lang.IllegalArgumentException
- if typeSig is not an array
type signature.public static ClassInfo getClassInfo(ClassPath classpath, java.lang.String typeSig)
classpath
- the classpath in which the ClassInfo is searched.typeSig
- type signature of the class.
java.lang.IllegalArgumentException
- if typeSig is not an class
type signature.public static int getParameterSize(java.lang.String methodTypeSig)
methodTypeSig
- the method type signature.
public static int getReturnSize(java.lang.String methodTypeSig)
methodTypeSig
- the method type signature.
public static java.lang.String[] getParameterTypes(java.lang.String methodTypeSig)
methodTypeSig
- the method type signature.
public static java.lang.String getReturnType(java.lang.String methodTypeSig)
methodTypeSig
- the method signature.
public static java.lang.Object getDefaultValue(java.lang.String typeSig)
typeSig
- the type signature.
java.lang.IllegalArgumentException
- if this is a method type signature.public static void checkTypeSig(java.lang.String typesig) throws java.lang.IllegalArgumentException
typesig
- the type signature.
java.lang.NullPointerException
- if typeSig is null.
java.lang.IllegalArgumentException
- if typeSig is not a valid
type signature or if it's a method type signature.public static void checkMethodTypeSig(java.lang.String typesig) throws java.lang.IllegalArgumentException
typesig
- the type signature.
java.lang.NullPointerException
- if typeSig is null.
java.lang.IllegalArgumentException
- if typeSig is not a valid
method type signature.
|
Jode 1.90-CVS Build Aug 6, 2004 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |