public class Descriptor extends Object
See chapter 4.3 in "The Java Virtual Machine Specification (2nd ed.)"
| Modifier and Type | Class and Description | 
|---|---|
| static class  | Descriptor.IteratorAn Iterator over a descriptor. | 
| Constructor and Description | 
|---|
| Descriptor() | 
| Modifier and Type | Method and Description | 
|---|---|
| static String | appendParameter(CtClass type,
               String descriptor)Appends a parameter type to the parameter list represented
 by the given descriptor. | 
| static String | appendParameter(String classname,
               String desc)Appends a parameter type to the parameter list represented
 by the given descriptor. | 
| static int | arrayDimension(String desc)Computes the dimension of the array represented by the given
 descriptor. | 
| static String | changeReturnType(String classname,
                String desc)Changes the return type included in the given descriptor. | 
| static int | dataSize(String desc)Computes the data size specified by the given descriptor. | 
| static boolean | eqParamTypes(String desc1,
            String desc2)Returns true if the list of the parameter types of desc1 is equal to
 that of desc2. | 
| static String | getParamDescriptor(String decl)Returns the signature of the given descriptor. | 
| static CtClass[] | getParameterTypes(String desc,
                 ClassPool cp)Returns the  CtClassobjects representing the parameter
 types specified by the given descriptor. | 
| static CtClass | getReturnType(String desc,
             ClassPool cp)Returns the  CtClassobject representing the return
 type specified by the given descriptor. | 
| static String | insertParameter(CtClass type,
               String descriptor)Inserts a parameter type at the beginning of the parameter
 list represented
 by the given descriptor. | 
| static String | insertParameter(String classname,
               String desc)Inserts a parameter type at the beginning of the parameter
 list represented
 by the given descriptor. | 
| static int | numOfParameters(String desc)Returns the number of the prameters included in the given
 descriptor. | 
| static String | of(CtClass type)Returns the descriptor representing the given type. | 
| static String | of(String classname)Converts to a descriptor from a Java class name | 
| static String | ofConstructor(CtClass[] paramTypes)Returns the descriptor representing a constructor receiving
 the given parameter types. | 
| static String | ofMethod(CtClass returnType,
        CtClass[] paramTypes)Returns the descriptor representing a method that receives
 the given parameter types and returns the given type. | 
| static String | ofParameters(CtClass[] paramTypes)Returns the descriptor representing a list of parameter types. | 
| static int | paramSize(String desc)Computes the data size of parameters. | 
| static String | rename(String desc,
      Map map)Substitutes class names in the given descriptor string
 according to the given  map. | 
| static String | rename(String desc,
      String oldname,
      String newname)Substitutes a class name
 in the given descriptor string. | 
| static String | toArrayComponent(String desc,
                int dim)Returns the descriptor of the type of the array component. | 
| static String | toClassName(String descriptor)Converts to a Java class name from a descriptor. | 
| static CtClass | toCtClass(String desc,
         ClassPool cp)Returns a  CtClassobject representing the type
 specified by the given descriptor. | 
| static String | toJavaName(String classname)Converts a class name from the internal representation used in
 the JVM to the normal one used in Java. | 
| static String | toJvmName(CtClass clazz)Returns the internal representation of the class name in the
 JVM. | 
| static String | toJvmName(String classname)Converts a class name into the internal representation used in
 the JVM. | 
| static String | toString(String desc)Returns a human-readable representation of the
 given descriptor. | 
public static String toJvmName(String classname)
Note that toJvmName(toJvmName(s)) is equivalent
 to toJvmName(s).
public static String toJavaName(String classname)
toClassName().toClassName(String)public static String toJvmName(CtClass clazz)
public static String toClassName(String descriptor)
descriptor - type descriptor.public static String rename(String desc, String oldname, String newname)
desc - descriptor stringoldname - replaced JVM class namenewname - substituted JVM class nametoJvmName(String)public static String rename(String desc, Map map)
map.map - a map between replaced and substituted
            JVM class names.toJvmName(String)public static String ofConstructor(CtClass[] paramTypes)
paramTypes - parameter typespublic static String ofMethod(CtClass returnType, CtClass[] paramTypes)
returnType - return typeparamTypes - parameter typespublic static String ofParameters(CtClass[] paramTypes)
int,
 then this method returns "(II)".paramTypes - parameter typespublic static String appendParameter(String classname, String desc)
classname must not be an array type.
classname - parameter type (not primitive type)desc - descriptorpublic static String insertParameter(String classname, String desc)
classname must not be an array type.
classname - parameter type (not primitive type)desc - descriptorpublic static String appendParameter(CtClass type, String descriptor)
type - the type of the appended parameter.descriptor - the original descriptor.public static String insertParameter(CtClass type, String descriptor)
type - the type of the inserted parameter.descriptor - the descriptor of the method.public static String changeReturnType(String classname, String desc)
classname must not be an array type.
classname - return typedesc - descriptorpublic static CtClass[] getParameterTypes(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.NotFoundExceptionpublic static boolean eqParamTypes(String desc1, String desc2)
public static String getParamDescriptor(String decl)
public static CtClass getReturnType(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.NotFoundExceptionpublic static int numOfParameters(String desc)
desc - descriptorpublic static CtClass toCtClass(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 - descriptor.cp - the class pool used for obtaining
             a CtClass object.NotFoundExceptionpublic static int arrayDimension(String desc)
"[[I",
 then this method returns 2.desc - the descriptor.public static String toArrayComponent(String desc, int dim)
"[[Ljava/lang/String;" and the given dimension is 2,
 then this method returns "Ljava/lang/String;".desc - the descriptor.dim - the array dimension.public static int dataSize(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 - descriptorpublic static int paramSize(String desc)
"(IJ)D", then this method returns 3.  The size of the
 return type is not computed.desc - a method descriptor.Copyright © 2016 Shigeru Chiba, www.javassist.org. All Rights Reserved.