Exemple #1
0
 private String getFieldName(Remapper remapper, String desc, int idx) {
   char[] chars = desc.toCharArray();
   int i = 0;
   for (int len = chars.length; i < len; ++i) {
     if (chars[i] != '[') {
       break;
     }
   }
   StringBuilder builder = new StringBuilder();
   switch (chars[i]) {
     case 'I':
       builder.append("anInt");
       break;
     case 'Z':
       builder.append("aBoolean");
       break;
     case 'B':
       builder.append("aByte");
       break;
     case 'S':
       builder.append("aShort");
       break;
     case 'C':
       builder.append("aChar");
       break;
     case 'J':
       builder.append("aLong");
       break;
     case 'F':
       builder.append("aFloat");
       break;
     case 'D':
       builder.append("aDouble");
       break;
     case 'L':
       String name = remapper.map(desc.substring(i + 1, desc.indexOf(";")));
       name = name.substring(name.lastIndexOf('/') + 1);
       char first = name.toLowerCase().charAt(0);
       if (first == 'a' || first == 'e' || first == 'i' || first == 'o' || first == 'u') {
         builder.append("an");
       } else {
         builder.append("a");
       }
       builder.append(name);
       while (i-- > 0) {
         builder.append("Array");
       }
       char last = builder.charAt(builder.length() - 1);
       if (last >= '0' && last <= '9') {
         builder.append("_");
       }
       return builder.append(idx).toString();
     default:
       builder.append("aField");
   }
   while (i-- > 0) {
     builder.append("Array");
   }
   return builder.append(idx).toString();
 }
Exemple #2
0
 @SuppressWarnings("unchecked")
 private static void processReflection(Remapper remapper, ClassNode node) {
   for (MethodNode mn : (List<MethodNode>) node.methods) {
     InsnList insns = mn.instructions;
     ListIterator<AbstractInsnNode> iterator = insns.iterator();
     while (iterator.hasNext()) {
       AbstractInsnNode insn = iterator.next();
       if (insn.getOpcode() == Opcodes.INVOKESTATIC) {
         MethodInsnNode min = (MethodInsnNode) insn;
         if (min.desc.equals("(Ljava/lang/String;)Ljava/lang/Class;")) {
           AbstractInsnNode push = insn.getPrevious();
           if (push.getOpcode() == Opcodes.LDC) {
             LdcInsnNode lin = (LdcInsnNode) push;
             lin.cst = remapper.map(((String) lin.cst).replace('.', '/')).replace('/', '.');
           }
         }
       }
     }
   }
 }