Пример #1
0
  private static void generateGetValue(
      Class owner,
      Type ownerType,
      Method method,
      boolean isStatic,
      Type resolvableType,
      Type[] arguments,
      MxGeneratorAdapter getValue,
      TransformGenerator[] tg,
      Type[] stored) {
    getValue.visitCode();

    if (!isStatic) {
      getValue.loadThis();
      getValue.getField(resolvableType, OWNER_FIELD_NAME, ownerType);
    }
    int index = 0;
    for (int i = 0; i < arguments.length; i++) {
      getValue.loadThis();
      getValue.getField(resolvableType, "arg" + i, stored[i]);
      if (tg != null) {
        tg[i].generateBackward(resolvableType, index, getValue);
        index += tg[i].getFieldCount();
      }
    }

    getValue.visitMethodInsn(
        isStatic ? INVOKESTATIC : owner.isInterface() ? INVOKEINTERFACE : INVOKEVIRTUAL,
        ownerType.getInternalName(),
        method.getName(),
        method.getDescriptor());
    getValue.returnValue();
    getValue.endMethod();
  }
Пример #2
0
  private static TransformGenerator[] getKeyTransformers(Class ownerClass, Method method) {
    TransformGeneratorFactory tgf = TransformGeneratorFactoryImpl.getInstance();

    Class[] params =
        CodegenHelper.getClasses(ownerClass.getClassLoader(), method.getArgumentTypes());
    Annotation[][] annotations;
    try {
      annotations =
          ownerClass.getDeclaredMethod(method.getName(), params).getParameterAnnotations();
    } catch (NoSuchMethodException e) {
      throw new IllegalStateException(e);
    }

    TransformGenerator[] tg = new TransformGenerator[params.length];
    for (int i = 0; i < params.length; i++) {
      tg[i] = tgf.forArgument(annotations[i], params[i]);
    }
    return tg;
  }
Пример #3
0
 public static void generateResolvable(Class ownerClass, int id, Method method, boolean isStatic) {
   Method nonProxiedMethod = new Method(getNonProxiedMethodName(method), method.getDescriptor());
   generateResolvable(
       ownerClass.getClassLoader(),
       getResolvableName(id, Type.getType(ownerClass)),
       ownerClass,
       nonProxiedMethod,
       nonProxiedMethod.getArgumentTypes(),
       isStatic,
       getKeyTransformers(ownerClass, method));
 }