Class Descriptor
java.lang.Object
javassist.bytecode.Descriptor
A support class for dealing with descriptors.
See chapter 4.3 in "The Java Virtual Machine Specification (2nd ed.)"
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringappendParameter(String classname, String desc) Appends a parameter type to the parameter list represented by the given descriptor.static StringappendParameter(CtClass type, String descriptor) Appends a parameter type to the parameter list represented by the given descriptor.static intarrayDimension(String desc) Computes the dimension of the array represented by the given descriptor.static StringchangeReturnType(String classname, String desc) Changes the return type included in the given descriptor.static intComputes the data size specified by the given descriptor.static booleaneqParamTypes(String desc1, String desc2) Returns true if the list of the parameter types of desc1 is equal to that of desc2.static StringgetParamDescriptor(String decl) Returns the signature of the given descriptor.static CtClass[]getParameterTypes(String desc, ClassPool cp) Returns theCtClassobjects representing the parameter types specified by the given descriptor.static CtClassgetReturnType(String desc, ClassPool cp) Returns theCtClassobject representing the return type specified by the given descriptor.static StringinsertParameter(String classname, String desc) Inserts a parameter type at the beginning of the parameter list represented by the given descriptor.static StringinsertParameter(CtClass type, String descriptor) Inserts a parameter type at the beginning of the parameter list represented by the given descriptor.static intnumOfParameters(String desc) Returns the number of the prameters included in the given descriptor.static StringConverts to a descriptor from a Java class namestatic StringReturns the descriptor representing the given type.static StringofConstructor(CtClass[] paramTypes) Returns the descriptor representing a constructor receiving the given parameter types.static StringReturns the descriptor representing a method that receives the given parameter types and returns the given type.static StringofParameters(CtClass[] paramTypes) Returns the descriptor representing a list of parameter types.static intComputes the data size of parameters.static StringSubstitutes a class name in the given descriptor string.static StringSubstitutes class names in the given descriptor string according to the givenmap.static StringtoArrayComponent(String desc, int dim) Returns the descriptor of the type of the array component.static StringtoClassName(String descriptor) Converts to a Java class name from a descriptor.static CtClassReturns aCtClassobject representing the type specified by the given descriptor.static StringtoJavaName(String classname) Converts a class name from the internal representation used in the JVM to the normal one used in Java.static StringConverts a class name into the internal representation used in the JVM.static StringReturns the internal representation of the class name in the JVM.static StringReturns a human-readable representation of the given descriptor.
-
Constructor Details
-
Descriptor
public Descriptor()
-
-
Method Details
-
toJvmName
-
toJavaName
-
toJvmName
-
toClassName
-
of
-
rename
-
rename
-
of
-
ofConstructor
-
ofMethod
-
ofParameters
-
appendParameter
-
insertParameter
-
appendParameter
-
insertParameter
-
changeReturnType
-
getParameterTypes
Returns theCtClassobjects representing the parameter types specified by the given descriptor.- Parameters:
desc- descriptorcp- the class pool used for obtaining aCtClassobject.- Throws:
NotFoundException
-
eqParamTypes
-
getParamDescriptor
-
getReturnType
Returns theCtClassobject representing the return type specified by the given descriptor.- Parameters:
desc- descriptorcp- the class pool used for obtaining aCtClassobject.- Throws:
NotFoundException
-
numOfParameters
Returns the number of the prameters included in the given descriptor.- Parameters:
desc- descriptor
-
toCtClass
Returns aCtClassobject representing the type specified by the given descriptor.This method works even if the package-class separator is not
/but.(period). For example, it acceptsLjava.lang.Object;as well asLjava/lang/Object;.- Parameters:
desc- descriptor.cp- the class pool used for obtaining aCtClassobject.- Throws:
NotFoundException
-
arrayDimension
Computes the dimension of the array represented by the given descriptor. For example, if the descriptor is"[[I", then this method returns 2.- Parameters:
desc- the descriptor.- Returns:
- 0 if the descriptor does not represent an array type.
-
toArrayComponent
Returns the descriptor of the type of the array component. For example, if the given descriptor is"[[Ljava/lang/String;"and the given dimension is 2, then this method returns"Ljava/lang/String;".- Parameters:
desc- the descriptor.dim- the array dimension.
-
dataSize
Computes the data size specified by the given descriptor. For example, if the descriptor is "D", this method returns 2.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).- Parameters:
desc- descriptor
-
paramSize
Computes the data size of parameters. If one of the parameters is double type, the size of that parameter is 2 words. For example, if the given descriptor is"(IJ)D", then this method returns 3. The size of the return type is not computed.- Parameters:
desc- a method descriptor.
-
toString
-