Esempio n. 1
0
 static int appendMethodSignature(Class[] argTypes, Class returnType, StringBuffer sb) {
   sb.append('(');
   int firstLocal = 1 + argTypes.length; // includes this.
   for (int i = 0; i < argTypes.length; i++) {
     Class type = argTypes[i];
     appendTypeString(sb, type);
     if (type == Long.TYPE || type == Double.TYPE) {
       // adjust for duble slot
       ++firstLocal;
     }
   }
   sb.append(')');
   appendTypeString(sb, returnType);
   return firstLocal;
 }
Esempio n. 2
0
 private static StringBuffer appendTypeString(StringBuffer sb, Class type) {
   while (type.isArray()) {
     sb.append('[');
     type = type.getComponentType();
   }
   if (type.isPrimitive()) {
     char typeLetter;
     if (type == Boolean.TYPE) {
       typeLetter = 'Z';
     } else if (type == Long.TYPE) {
       typeLetter = 'J';
     } else {
       String typeName = type.getName();
       typeLetter = Character.toUpperCase(typeName.charAt(0));
     }
     sb.append(typeLetter);
   } else {
     sb.append('L');
     sb.append(type.getName().replace('.', '/'));
     sb.append(';');
   }
   return sb;
 }