private static CstMethodRef makePolymorphicMethod(final CstMethodRef callSiteMethod) {
    CstType definingClass = callSiteMethod.getDefiningClass();
    CstString cstMethodName = callSiteMethod.getNat().getName();
    String methodName = callSiteMethod.getNat().getName().getString();

    if (definingClass.equals(CstType.METHOD_HANDLE)) {
      if (methodName.equals("invoke") || methodName.equals("invokeExact")) {
        CstNat cstNat = new CstNat(cstMethodName, DEFAULT_DESCRIPTOR);
        return new CstMethodRef(definingClass, cstNat);
      }
    }

    if (definingClass.equals(CstType.VAR_HANDLE)) {
      switch (methodName) {
        case "compareAndExchange":
        case "compareAndExchangeAcquire":
        case "compareAndExchangeRelease":
        case "get":
        case "getAcquire":
        case "getAndAdd":
        case "getAndAddAcquire":
        case "getAndAddRelease":
        case "getAndBitwiseAnd":
        case "getAndBitwiseAndAcquire":
        case "getAndBitwiseAndRelease":
        case "getAndBitwiseOr":
        case "getAndBitwiseOrAcquire":
        case "getAndBitwiseOrRelease":
        case "getAndBitwiseXor":
        case "getAndBitwiseXorAcquire":
        case "getAndBitwiseXorRelease":
        case "getAndSet":
        case "getAndSetAcquire":
        case "getAndSetRelease":
        case "getOpaque":
        case "getVolatile":
          {
            CstNat cstNat = new CstNat(cstMethodName, DEFAULT_DESCRIPTOR);
            return new CstMethodRef(definingClass, cstNat);
          }
        case "set":
        case "setOpaque":
        case "setRelease":
        case "setVolatile":
          {
            CstNat cstNat = new CstNat(cstMethodName, VARHANDLE_SET_DESCRIPTOR);
            return new CstMethodRef(definingClass, cstNat);
          }
        case "compareAndSet":
        case "weakCompareAndSet":
        case "weakCompareAndSetAcquire":
        case "weakCompareAndSetPlain":
        case "weakCompareAndSetRelease":
          {
            CstNat cstNat = new CstNat(cstMethodName, VARHANDLE_COMPARE_AND_SET_DESCRIPTOR);
            return new CstMethodRef(definingClass, cstNat);
          }
        default:
          break;
      }
    }
    throw new IllegalArgumentException(
        "Unknown signature polymorphic method: " + callSiteMethod.toHuman());
  }
Constructs an instance.

@param opcode {@code non-null;} the opcode
@param position {@code non-null;} source position
@param sources {@code non-null;} specs for all the sources
@param catches {@code non-null;} list of exceptions caught
@param callSiteMethod {@code non-null;} the method called by invoke-virtual that this instance
    will replace.
android/android_framework/dex-maker/src/main/java/com/android/dx/rop/code/InvokePolymorphicInsn.java