Class Descriptor

  • All Implemented Interfaces:
    VMConstants

    public class Descriptor
    extends Object
    implements VMConstants
    A collection of static methods which manipulate type descriptors
    • Constructor Detail

      • Descriptor

        public Descriptor()
    • Method Detail

      • countMethodArgWords

        public static int countMethodArgWords​(String sig)
        Return the number of words of arguments to the method based on the method signature
      • countMethodReturnWords

        public static int countMethodReturnWords​(String sig)
        Return the number of words of return value for the method based on the method signature
      • extractResultSig

        public static String extractResultSig​(String methodSig)
        Return the stack descriptor for the result of a method invocation. Void return values yield "V".
      • extractArgSig

        public static String extractArgSig​(String methodSig)
        Return the stack descriptor for the arguments to a method invocation (not including any "this" argument)
      • extractReversedArgSig

        public static String extractReversedArgSig​(String methodSig)
        Return the reversed stack descriptor for the arguments to a method invocation (not including any "this" argument). The top of stack element will be first.
      • countFieldWords

        public static int countFieldWords​(String sig)
        Return the number of words of a field based on its signature.
      • elementType

        public static int elementType​(String sig)
        Return the element type for the first char in the type descriptor string.
      • elementSig

        public static String elementSig​(int valueType)
        Return the element type descriptor char for the element type. The element type must be one of the T_ or TC_OBJECT.
      • elementSize

        public static int elementSize​(int elementType)
        Return the number of stack words required for a value of the specified type on the operand stack.
      • computeStackTypes

        public static void computeStackTypes​(String stackSig,
                                             Stack stack)
        stackSig is a signature for a list of types on the JVM stack with the last type in the signature intended to be on the top of JVM stack. For each type in the signature, pushes an Integer objects identifying the types on top of the input Stack object.
      • nextSigElement

        public static int nextSigElement​(String stackSig,
                                         int idx)
        stackSig is a signature for the types on the stack with the last type in the signature on the top of stack. idx is the index of the start of a valid signature type element. Return the index of the next element (which may be past the end of the string).
      • remapTypes

        public static String remapTypes​(String sig,
                                        Map classTranslations)
        classTranslations contains a set of mappings of class names. For any types within the input signature which appear as keys in the translation table, change the signature to replace the original type with the translation. Return a string containing the original signature with any translations applied.
      • translateClass

        public static String translateClass​(String cls,
                                            Map classTranslations)
        classTranslations contains a set of mappings of class names. Translate the class name (which may be an array class) according to the entries in the translation table. Return either the original string if no translation applies or else the translated string.
      • userFieldSig

        public static String userFieldSig​(String vmSig)
        Translates a VM type field signature into a user-format signature. Just a front for the two argument overload of this method.
      • userFieldSig

        public static String userFieldSig​(String vmSig,
                                          int idx)
        Translates a VM type field signature into a user-format signature.
      • userMethodArgs

        public static String userMethodArgs​(String methodSig)
        Produce a user consumable representation of a method argument list from the method signature. The return value is ignored.