Esempio n. 1
0
  public static boolean methodDescsCloseEnough(String mightHaveVMState, String desc) {
    Type[] d1 = Type.getArgumentTypes(mightHaveVMState);
    Type[] d2 = Type.getArgumentTypes(desc);
    if (Arrays.deepEquals(d1, d2)) return true;
    if (d1[d1.length - 1].getInternalName().equals(Type.getInternalName(VMState.class))) {

      if (d1.length - 1 != d2.length) return false;
      for (int i = 0; i < d1.length - 1; i++) if (!d1[i].equals(d2[i])) return false;
      return true;
    }
    return false;
  }
Esempio n. 2
0
  //	private static Logger log = Logger.getLogger(InvivoAdapter.class);
  public InvivoAdapter(
      int api,
      MethodVisitor mv,
      int access,
      String name,
      String desc,
      String className,
      boolean generateReverseStub) {
    //		super(api, mv, access, name, desc);
    super(mv);
    this.access = access;
    this.name = name;
    this.desc = desc;
    this.className = className;

    Type[] args = Type.getArgumentTypes(desc);
    firstLocal = (Opcodes.ACC_STATIC & access) == 0 ? 1 : 0;
    for (int i = 0; i < args.length; i++) {
      firstLocal += args[i].getSize();
    }
    sandboxVar = isMain() || isClinit() ? getFirstLocal() : getFirstLocal() - 1;

    if (generateReverseStub) {
      GeneratorAdapter gv = new GeneratorAdapter(mv, access, name, desc);
      gv.visitCode();
      gv.loadThis();
      for (int i = 0; i < args.length - 1; i++) {
        gv.loadArg(i);
      }
      Type[] args2 = new Type[args.length - 1];
      System.arraycopy(args, 0, args2, 0, args.length - 1);
      gv.visitMethodInsn(
          INVOKEVIRTUAL,
          className,
          name.substring(1),
          Type.getMethodDescriptor(Type.getReturnType(desc), args2),
          false);
      //			switch(Type.getReturnType(desc).getSort())
      //			{
      //			case Type.ARRAY:
      //			case Type.OBJECT:
      //				gv.visitLdcInsn(null);
      //			break;
      //			case Type.VOID:
      //				break;
      //			default:
      //				gv.push(0);
      //			}
      gv.returnValue();
      gv.visitMaxs(0, 0);
      //			mv.visitEnd();
    }
  }