|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectclassUtils.javassist.bytecode.Descriptor
public class Descriptor
A support class for dealing with descriptors.
See chapter 4.3 in "The Java Virtual Machine Specification (2nd ed.)"
Constructor Summary | |
---|---|
Descriptor()
|
Method Summary | |
---|---|
static java.lang.String |
appendParameter(java.lang.String classname,
java.lang.String desc)
Appends a parameter type to the parameter list represented by the given descriptor. |
static java.lang.String |
changeReturnType(java.lang.String classname,
java.lang.String desc)
Changes the return type included in the given descriptor. |
static int |
dataSize(java.lang.String desc)
Computes the data size specified by the given descriptor. |
static CompileTimeClass[] |
getParameterTypes(java.lang.String desc,
ClassPool cp)
Returns the CtClass objects representing the parameter
types specified by the given descriptor. |
static CompileTimeClass |
getReturnType(java.lang.String desc,
ClassPool cp)
Returns the CtClass object representing the return
type specified by the given descriptor. |
static java.lang.String |
insertParameter(java.lang.String classname,
java.lang.String desc)
Inserts a parameter type affineTransform the beginning of the parameter list represented by the given descriptor. |
static int |
numOfParameters(java.lang.String desc)
Returns the number of the prameters included in the given descriptor. |
static java.lang.String |
of(CompileTimeClass type)
Returns the descriptor representing the given type. |
static java.lang.String |
ofConstructor(CompileTimeClass[] paramTypes)
Returns the descriptor representing a constructor receiving the given parameter types. |
static java.lang.String |
ofMethod(CompileTimeClass returnType,
CompileTimeClass[] paramTypes)
Returns the descriptor representing a method that receives the given parameter types and returns the given type. |
static java.lang.String |
ofParameters(CompileTimeClass[] paramTypes)
Returns the descriptor representing a list of parameter types. |
static java.lang.String |
rename(java.lang.String desc,
java.util.Map map)
Substitutes class names in the given descriptor string according to the given map . |
static java.lang.String |
rename(java.lang.String desc,
java.lang.String oldname,
java.lang.String newname)
Substitutes a class name in the given descriptor string. |
static CompileTimeClass |
toCtClass(java.lang.String desc,
ClassPool cp)
Returns a CtClass object representing the type
specified by the given descriptor. |
static java.lang.String |
toJavaName(java.lang.String classname)
Converts a class name from the internal representation used in the JVM to the normal one used in Java. |
static java.lang.String |
toJvmName(CompileTimeClass clazz)
Returns the internal representation of the class name in the JVM. |
static java.lang.String |
toJvmName(java.lang.String classname)
Converts a class name into the internal representation used in the JVM. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Descriptor()
Method Detail |
---|
public static java.lang.String toJvmName(java.lang.String classname)
Note that toJvmName(toJvmName(s))
is equivalent
to toJvmName(s)
.
public static java.lang.String toJavaName(java.lang.String classname)
public static java.lang.String toJvmName(CompileTimeClass clazz)
public static java.lang.String rename(java.lang.String desc, java.lang.String oldname, java.lang.String newname)
desc
- descriptor stringoldname
- replaced JVM class namenewname
- substituted JVM class nametoJvmName(String)
public static java.lang.String rename(java.lang.String desc, java.util.Map map)
map
.
map
- a map between replaced and substituted
JVM class names.toJvmName(String)
public static java.lang.String of(CompileTimeClass type)
public static java.lang.String ofConstructor(CompileTimeClass[] paramTypes)
paramTypes
- parameter typespublic static java.lang.String ofMethod(CompileTimeClass returnType, CompileTimeClass[] paramTypes)
returnType
- return typeparamTypes
- parameter typespublic static java.lang.String ofParameters(CompileTimeClass[] paramTypes)
int
,
then this method returns "(II)"
.
paramTypes
- parameter typespublic static java.lang.String appendParameter(java.lang.String classname, java.lang.String desc)
classname
must not be an array type.
classname
- parameter type (not primitive type)desc
- descriptorpublic static java.lang.String insertParameter(java.lang.String classname, java.lang.String desc)
classname
must not be an array type.
classname
- parameter type (not primitive type)desc
- descriptorpublic static java.lang.String changeReturnType(java.lang.String classname, java.lang.String desc)
classname
must not be an array type.
classname
- return typedesc
- descriptorpublic static CompileTimeClass[] getParameterTypes(java.lang.String desc, ClassPool cp) throws NotFoundException
CtClass
objects representing the parameter
types specified by the given descriptor.
desc
- descriptorcp
- the class pool used for obtaining
a CtClass
object.
NotFoundException
public static CompileTimeClass getReturnType(java.lang.String desc, ClassPool cp) throws NotFoundException
CtClass
object representing the return
type specified by the given descriptor.
desc
- descriptorcp
- the class pool used for obtaining
a CtClass
object.
NotFoundException
public static int numOfParameters(java.lang.String desc)
desc
- descriptorpublic static CompileTimeClass toCtClass(java.lang.String desc, ClassPool cp) throws NotFoundException
CtClass
object representing the type
specified by the given descriptor.
This method works even if the package-class separator is
not /
but .
(period). For example,
it accepts Ljava.lang.Object;
as well as Ljava/lang/Object;
.
desc
- descriptorcp
- the class pool used for obtaining
a CtClass
object.
NotFoundException
public static int dataSize(java.lang.String desc)
If the descriptor represents a method type, this method returns (the size of the returned value) - (the sum of the data sizes of all the parameters). For example, if the descriptor is "(I)D", then this method returns 1 (= 2 - 1).
desc
- descriptor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |