@@ -401,8 +401,8 @@ public static Type getReturnType(final Method method) {
401
401
* @return the size of the arguments of the method (plus one for the
402
402
* implicit this argument), argSize, and the size of its return
403
403
* value, retSize, packed into a single int i =
404
- * <tt>(argSize << 2) | retSize</tt> (argSize is therefore equal to
405
- * <tt>i >> 2</tt>, and retSize to <tt>i & 0x03</tt>).
404
+ * <tt>(argSize << 2) | retSize</tt> (argSize is therefore equal to
405
+ * <tt>i >> 2</tt>, and retSize to <tt>i & 0x03</tt>).
406
406
*/
407
407
public static int getArgumentsAndReturnSizes (final String desc ) {
408
408
int n = 1 ;
@@ -556,11 +556,11 @@ public String getClassName() {
556
556
case DOUBLE :
557
557
return "double" ;
558
558
case ARRAY :
559
- StringBuffer b = new StringBuffer (getElementType ().getClassName ());
559
+ StringBuilder sb = new StringBuilder (getElementType ().getClassName ());
560
560
for (int i = getDimensions (); i > 0 ; --i ) {
561
- b .append ("[]" );
561
+ sb .append ("[]" );
562
562
}
563
- return b .toString ();
563
+ return sb .toString ();
564
564
case OBJECT :
565
565
return new String (buf , off , len ).replace ('/' , '.' );
566
566
default :
@@ -606,9 +606,10 @@ public Type getReturnType() {
606
606
*
607
607
* @return the size of the arguments (plus one for the implicit this
608
608
* argument), argSize, and the size of the return value, retSize,
609
- * packed into a single int i = <tt>(argSize << 2) | retSize</tt>
610
- * (argSize is therefore equal to <tt>i >> 2</tt>, and retSize to
611
- * <tt>i & 0x03</tt>).
609
+ * packed into a single
610
+ * int i = <tt>(argSize << 2) | retSize</tt>
611
+ * (argSize is therefore equal to <tt>i >> 2</tt>,
612
+ * and retSize to <tt>i & 0x03</tt>).
612
613
*/
613
614
public int getArgumentsAndReturnSizes () {
614
615
return getArgumentsAndReturnSizes (getDescriptor ());
@@ -624,9 +625,9 @@ public int getArgumentsAndReturnSizes() {
624
625
* @return the descriptor corresponding to this Java type.
625
626
*/
626
627
public String getDescriptor () {
627
- StringBuffer buf = new StringBuffer ();
628
- getDescriptor (buf );
629
- return buf .toString ();
628
+ StringBuilder sb = new StringBuilder ();
629
+ getDescriptor (sb );
630
+ return sb .toString ();
630
631
}
631
632
632
633
/**
@@ -642,34 +643,34 @@ public String getDescriptor() {
642
643
*/
643
644
public static String getMethodDescriptor (final Type returnType ,
644
645
final Type ... argumentTypes ) {
645
- StringBuffer buf = new StringBuffer ();
646
- buf .append ('(' );
646
+ StringBuilder sb = new StringBuilder ();
647
+ sb .append ('(' );
647
648
for (int i = 0 ; i < argumentTypes .length ; ++i ) {
648
- argumentTypes [i ].getDescriptor (buf );
649
+ argumentTypes [i ].getDescriptor (sb );
649
650
}
650
- buf .append (')' );
651
- returnType .getDescriptor (buf );
652
- return buf .toString ();
651
+ sb .append (')' );
652
+ returnType .getDescriptor (sb );
653
+ return sb .toString ();
653
654
}
654
655
655
656
/**
656
657
* Appends the descriptor corresponding to this Java type to the given
657
- * string buffer .
658
+ * string builder .
658
659
*
659
- * @param buf
660
- * the string buffer to which the descriptor must be appended.
660
+ * @param sb
661
+ * the string builder to which the descriptor must be appended.
661
662
*/
662
- private void getDescriptor (final StringBuffer buf ) {
663
+ private void getDescriptor (final StringBuilder sb ) {
663
664
if (this .buf == null ) {
664
665
// descriptor is in byte 3 of 'off' for primitive types (buf ==
665
666
// null)
666
- buf .append ((char ) ((off & 0xFF000000 ) >>> 24 ));
667
+ sb .append ((char ) ((off & 0xFF000000 ) >>> 24 ));
667
668
} else if (sort == OBJECT ) {
668
- buf .append ('L' );
669
- buf .append (this .buf , off , len );
670
- buf .append (';' );
669
+ sb .append ('L' );
670
+ sb .append (this .buf , off , len );
671
+ sb .append (';' );
671
672
} else { // sort == ARRAY || sort == METHOD
672
- buf .append (this .buf , off , len );
673
+ sb .append (this .buf , off , len );
673
674
}
674
675
}
675
676
@@ -699,9 +700,9 @@ public static String getInternalName(final Class<?> c) {
699
700
* @return the descriptor corresponding to the given class.
700
701
*/
701
702
public static String getDescriptor (final Class <?> c ) {
702
- StringBuffer buf = new StringBuffer ();
703
- getDescriptor (buf , c );
704
- return buf .toString ();
703
+ StringBuilder sb = new StringBuilder ();
704
+ getDescriptor (sb , c );
705
+ return sb .toString ();
705
706
}
706
707
707
708
/**
@@ -713,12 +714,12 @@ public static String getDescriptor(final Class<?> c) {
713
714
*/
714
715
public static String getConstructorDescriptor (final Constructor <?> c ) {
715
716
Class <?>[] parameters = c .getParameterTypes ();
716
- StringBuffer buf = new StringBuffer ();
717
- buf .append ('(' );
717
+ StringBuilder sb = new StringBuilder ();
718
+ sb .append ('(' );
718
719
for (int i = 0 ; i < parameters .length ; ++i ) {
719
- getDescriptor (buf , parameters [i ]);
720
+ getDescriptor (sb , parameters [i ]);
720
721
}
721
- return buf .append (")V" ).toString ();
722
+ return sb .append (")V" ).toString ();
722
723
}
723
724
724
725
/**
@@ -730,25 +731,25 @@ public static String getConstructorDescriptor(final Constructor<?> c) {
730
731
*/
731
732
public static String getMethodDescriptor (final Method m ) {
732
733
Class <?>[] parameters = m .getParameterTypes ();
733
- StringBuffer buf = new StringBuffer ();
734
- buf .append ('(' );
734
+ StringBuilder sb = new StringBuilder ();
735
+ sb .append ('(' );
735
736
for (int i = 0 ; i < parameters .length ; ++i ) {
736
- getDescriptor (buf , parameters [i ]);
737
+ getDescriptor (sb , parameters [i ]);
737
738
}
738
- buf .append (')' );
739
- getDescriptor (buf , m .getReturnType ());
740
- return buf .toString ();
739
+ sb .append (')' );
740
+ getDescriptor (sb , m .getReturnType ());
741
+ return sb .toString ();
741
742
}
742
743
743
744
/**
744
- * Appends the descriptor of the given class to the given string buffer .
745
+ * Appends the descriptor of the given class to the given string builder .
745
746
*
746
- * @param buf
747
+ * @param sb
747
748
* the string buffer to which the descriptor must be appended.
748
749
* @param c
749
750
* the class whose descriptor must be computed.
750
751
*/
751
- private static void getDescriptor (final StringBuffer buf , final Class <?> c ) {
752
+ private static void getDescriptor (final StringBuilder sb , final Class <?> c ) {
752
753
Class <?> d = c ;
753
754
while (true ) {
754
755
if (d .isPrimitive ()) {
@@ -772,20 +773,20 @@ private static void getDescriptor(final StringBuffer buf, final Class<?> c) {
772
773
} else /* if (d == Long.TYPE) */ {
773
774
car = 'J' ;
774
775
}
775
- buf .append (car );
776
+ sb .append (car );
776
777
return ;
777
778
} else if (d .isArray ()) {
778
- buf .append ('[' );
779
+ sb .append ('[' );
779
780
d = d .getComponentType ();
780
781
} else {
781
- buf .append ('L' );
782
+ sb .append ('L' );
782
783
String name = d .getName ();
783
784
int len = name .length ();
784
785
for (int i = 0 ; i < len ; ++i ) {
785
786
char car = name .charAt (i );
786
- buf .append (car == '.' ? '/' : car );
787
+ sb .append (car == '.' ? '/' : car );
787
788
}
788
- buf .append (';' );
789
+ sb .append (';' );
789
790
return ;
790
791
}
791
792
}
0 commit comments