sandbox/src/main/java/org/robolectric/internal/bytecode/ClassInstrumentor.java
private void rewriteMethodBody(MutableClass mutableClass, MethodNode callingMethod) {
    ListIterator<AbstractInsnNode> instructions = callingMethod.instructions.iterator();
    while (instructions.hasNext()) {
      AbstractInsnNode node = instructions.next();

      switch (node.getOpcode()) {
        case Opcodes.NEW:
          TypeInsnNode newInsnNode = (TypeInsnNode) node;
          newInsnNode.desc = mutableClass.config.mappedTypeName(newInsnNode.desc);
          break;

        case Opcodes.GETFIELD:
          /* falls through */
        case Opcodes.PUTFIELD:
          /* falls through */
        case Opcodes.GETSTATIC:
          /* falls through */
        case Opcodes.PUTSTATIC:
          FieldInsnNode fieldInsnNode = (FieldInsnNode) node;
          fieldInsnNode.desc = mutableClass.config.mappedTypeName(fieldInsnNode.desc); // todo test
          break;

        case Opcodes.INVOKESTATIC:
          /* falls through */
        case Opcodes.INVOKEINTERFACE:
          /* falls through */
        case Opcodes.INVOKESPECIAL:
          /* falls through */
        case Opcodes.INVOKEVIRTUAL:
          MethodInsnNode targetMethod = (MethodInsnNode) node;
          targetMethod.desc = mutableClass.config.remapParams(targetMethod.desc);
          if (isGregorianCalendarBooleanConstructor(targetMethod)) {
            replaceGregorianCalendarBooleanConstructor(instructions, targetMethod);
          } else if (mutableClass.config.shouldIntercept(targetMethod)) {
            interceptInvokeVirtualMethod(mutableClass, instructions, targetMethod);
          }
          break;

        case Opcodes.INVOKEDYNAMIC:
          /* no unusual behavior */
          break;

        default:
          break;
      }
    }
  }
private void rewriteMethodBody(MutableClass mutableClass, MethodNode callingMethod) {
    ListIterator<AbstractInsnNode> instructions = callingMethod.instructions.iterator();
    while (instructions.hasNext()) {
      AbstractInsnNode node = instructions.next();

      switch (node.getOpcode()) {
        case Opcodes.NEW:
          TypeInsnNode newInsnNode = (TypeInsnNode) node;
          newInsnNode.desc = mutableClass.config.mappedTypeName(newInsnNode.desc);
          break;

        case Opcodes.GETFIELD:
          /* falls through */
        case Opcodes.PUTFIELD:
          /* falls through */
        case Opcodes.GETSTATIC:
          /* falls through */
        case Opcodes.PUTSTATIC:
          FieldInsnNode fieldInsnNode = (FieldInsnNode) node;
          fieldInsnNode.desc = mutableClass.config.mappedTypeName(fieldInsnNode.desc); // todo test
          break;

        case Opcodes.INVOKESTATIC:
          /* falls through */
        case Opcodes.INVOKEINTERFACE:
          /* falls through */
        case Opcodes.INVOKESPECIAL:
          /* falls through */
        case Opcodes.INVOKEVIRTUAL:
          MethodInsnNode targetMethod = (MethodInsnNode) node;
          targetMethod.desc = mutableClass.config.remapParams(targetMethod.desc);
          if (isGregorianCalendarBooleanConstructor(targetMethod)) {
            replaceGregorianCalendarBooleanConstructor(instructions, targetMethod);
          } else if (mutableClass.config.shouldIntercept(targetMethod)) {
            interceptInvokeVirtualMethod(mutableClass, instructions, targetMethod);
          }
          break;

        case Opcodes.INVOKEDYNAMIC:
          /* no unusual behavior */
          break;

        default:
          break;
      }
    }
  }
private void rewriteMethodBody ( MutableClass mutableClass , MethodNode callingMethod ) { ListIterator < AbstractInsnNode > instructions = callingMethod . instructions . iterator ( ) ; while ( instructions . hasNext ( ) ) { AbstractInsnNode node = instructions . next ( ) ; switch ( node . getOpcode ( ) ) { case Opcodes . NEW : TypeInsnNode newInsnNode = ( TypeInsnNode ) node ; newInsnNode . desc = mutableClass . config . mappedTypeName ( newInsnNode . desc ) ; break ; case Opcodes . GETFIELD : /* falls through */ case Opcodes . PUTFIELD : /* falls through */ case Opcodes . GETSTATIC : /* falls through */ case Opcodes . PUTSTATIC : FieldInsnNode fieldInsnNode = ( FieldInsnNode ) node ; fieldInsnNode . desc = mutableClass . config . mappedTypeName ( fieldInsnNode . desc ) ; // todo test break ; case Opcodes . INVOKESTATIC : /* falls through */ case Opcodes . INVOKEINTERFACE : /* falls through */ case Opcodes . INVOKESPECIAL : /* falls through */ case Opcodes . INVOKEVIRTUAL : MethodInsnNode targetMethod = ( MethodInsnNode ) node ; targetMethod . desc = mutableClass . config . remapParams ( targetMethod . desc ) ; if ( isGregorianCalendarBooleanConstructor ( targetMethod ) ) { replaceGregorianCalendarBooleanConstructor ( instructions , targetMethod ) ; } else if ( mutableClass . config . shouldIntercept ( targetMethod ) ) { interceptInvokeVirtualMethod ( mutableClass , instructions , targetMethod ) ; } break ; case Opcodes . INVOKEDYNAMIC : /* no unusual behavior */ break ; default : break ; } } }
Filters methods that might need special treatment because of various reasons
Filters methods that might need special treatment because of various reasons