src/share/classes/jdk/internal/org/objectweb/asm/Type.java

Print this page




 395 
 396     /**
 397      * Returns the Java type corresponding to the return type of the given
 398      * method.
 399      *
 400      * @param method a method.
 401      * @return the Java type corresponding to the return type of the given
 402      *         method.
 403      */
 404     public static Type getReturnType(final Method method) {
 405         return getType(method.getReturnType());
 406     }
 407 
 408     /**
 409      * Computes the size of the arguments and of the return value of a method.
 410      *
 411      * @param desc the descriptor of a method.
 412      * @return the size of the arguments of the method (plus one for the
 413      *         implicit this argument), argSize, and the size of its return
 414      *         value, retSize, packed into a single int i =
 415      *         <tt>(argSize << 2) | retSize</tt> (argSize is therefore equal
 416      *         to <tt>i >> 2</tt>, and retSize to <tt>i & 0x03</tt>).
 417      */
 418     public static int getArgumentsAndReturnSizes(final String desc) {
 419         int n = 1;
 420         int c = 1;
 421         while (true) {
 422             char car = desc.charAt(c++);
 423             if (car == ')') {
 424                 car = desc.charAt(c);
 425                 return n << 2
 426                         | (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
 427             } else if (car == 'L') {
 428                 while (desc.charAt(c++) != ';') {
 429                 }
 430                 n += 1;
 431             } else if (car == '[') {
 432                 while ((car = desc.charAt(c)) == '[') {
 433                     ++c;
 434                 }
 435                 if (car == 'D' || car == 'J') {
 436                     n -= 1;


 598     public Type[] getArgumentTypes() {
 599         return getArgumentTypes(getDescriptor());
 600     }
 601 
 602     /**
 603      * Returns the return type of methods of this type. This method should only
 604      * be used for method types.
 605      *
 606      * @return the return type of methods of this type.
 607      */
 608     public Type getReturnType() {
 609         return getReturnType(getDescriptor());
 610     }
 611 
 612     /**
 613      * Returns the size of the arguments and of the return value of methods of
 614      * this type. This method should only be used for method types.
 615      *
 616      * @return the size of the arguments (plus one for the implicit this
 617      *         argument), argSize, and the size of the return value, retSize,
 618      *         packed into a single int i = <tt>(argSize << 2) | retSize</tt>
 619      *         (argSize is therefore equal to <tt>i >> 2</tt>, and retSize to
 620      *         <tt>i & 0x03</tt>).
 621      */
 622     public int getArgumentsAndReturnSizes() {
 623         return getArgumentsAndReturnSizes(getDescriptor());
 624     }
 625 
 626     // ------------------------------------------------------------------------
 627     // Conversion to type descriptors
 628     // ------------------------------------------------------------------------
 629 
 630     /**
 631      * Returns the descriptor corresponding to this Java type.
 632      *
 633      * @return the descriptor corresponding to this Java type.
 634      */
 635     public String getDescriptor() {
 636         StringBuffer buf = new StringBuffer();
 637         getDescriptor(buf);
 638         return buf.toString();
 639     }
 640 




 395 
 396     /**
 397      * Returns the Java type corresponding to the return type of the given
 398      * method.
 399      *
 400      * @param method a method.
 401      * @return the Java type corresponding to the return type of the given
 402      *         method.
 403      */
 404     public static Type getReturnType(final Method method) {
 405         return getType(method.getReturnType());
 406     }
 407 
 408     /**
 409      * Computes the size of the arguments and of the return value of a method.
 410      *
 411      * @param desc the descriptor of a method.
 412      * @return the size of the arguments of the method (plus one for the
 413      *         implicit this argument), argSize, and the size of its return
 414      *         value, retSize, packed into a single int i =
 415      *         <tt>(argSize {@literal <<} 2) | retSize</tt> (argSize is therefore equal
 416      *         to <tt>i {@literal >>} 2</tt>, and retSize to <tt>i {@literal &} 0x03</tt>).
 417      */
 418     public static int getArgumentsAndReturnSizes(final String desc) {
 419         int n = 1;
 420         int c = 1;
 421         while (true) {
 422             char car = desc.charAt(c++);
 423             if (car == ')') {
 424                 car = desc.charAt(c);
 425                 return n << 2
 426                         | (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
 427             } else if (car == 'L') {
 428                 while (desc.charAt(c++) != ';') {
 429                 }
 430                 n += 1;
 431             } else if (car == '[') {
 432                 while ((car = desc.charAt(c)) == '[') {
 433                     ++c;
 434                 }
 435                 if (car == 'D' || car == 'J') {
 436                     n -= 1;


 598     public Type[] getArgumentTypes() {
 599         return getArgumentTypes(getDescriptor());
 600     }
 601 
 602     /**
 603      * Returns the return type of methods of this type. This method should only
 604      * be used for method types.
 605      *
 606      * @return the return type of methods of this type.
 607      */
 608     public Type getReturnType() {
 609         return getReturnType(getDescriptor());
 610     }
 611 
 612     /**
 613      * Returns the size of the arguments and of the return value of methods of
 614      * this type. This method should only be used for method types.
 615      *
 616      * @return the size of the arguments (plus one for the implicit this
 617      *         argument), argSize, and the size of the return value, retSize,
 618      *         packed into a single int i = <tt>(argSize {@literal <<} 2) | retSize</tt>
 619      *         (argSize is therefore equal to <tt>i {@literal >>} 2</tt>, and retSize to
 620      *         <tt>i {@literal &} 0x03</tt>).
 621      */
 622     public int getArgumentsAndReturnSizes() {
 623         return getArgumentsAndReturnSizes(getDescriptor());
 624     }
 625 
 626     // ------------------------------------------------------------------------
 627     // Conversion to type descriptors
 628     // ------------------------------------------------------------------------
 629 
 630     /**
 631      * Returns the descriptor corresponding to this Java type.
 632      *
 633      * @return the descriptor corresponding to this Java type.
 634      */
 635     public String getDescriptor() {
 636         StringBuffer buf = new StringBuffer();
 637         getDescriptor(buf);
 638         return buf.toString();
 639     }
 640