Package org.objectweb.asm.commons

Examples of org.objectweb.asm.commons.Method


      fv.visitEnd();
    }
    MethodVisitor mv;
    mv = cv.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    if (mv != null) {
      Method m = Method.getMethod("void <init>()");
      GeneratorAdapter ga = new GeneratorAdapter(ACC_PUBLIC, m, mv);
      ga.visitCode();
      ga.loadThis();
      ga.invokeConstructor(Type.getType("Ljava/lang/Object;"), m);
      ga.returnValue();
      ga.endMethod();
    }
    mv = cv.visitMethod(ACC_PUBLIC, "getF", "()I", null, null);
    if (mv != null) {
      Type bean = Type.getType("Lpkg/Bean;");
      Method m = Method.getMethod("int getF()");
      GeneratorAdapter ga = new GeneratorAdapter(ACC_PUBLIC, m, mv);
      ga.visitCode();
      ga.loadThis();
      ga.getField(bean, "f", Type.INT_TYPE);
      ga.returnValue();
      ga.endMethod();
    }
    mv = cv.visitMethod(ACC_PUBLIC, "setF", "(I)V", null, null);
    if (mv != null) {
      Type bean = Type.getType("Lpkg/Bean;");
      Method m = Method.getMethod("void setF(int)");
      GeneratorAdapter ga = new GeneratorAdapter(ACC_PUBLIC, m, mv);
      ga.visitCode();
      ga.loadThis();
      ga.loadArg(0);
      ga.putField(bean, "f", Type.INT_TYPE);
      ga.returnValue();
      ga.endMethod();
    }
    mv = cv.visitMethod(ACC_PUBLIC, "checkAndSetF", "(I)V", null, null);
    if (mv != null) {
      Type bean = Type.getType("Lpkg/Bean;");
      Method m = Method.getMethod("void checkAndSetF(int)");
      GeneratorAdapter ga = new GeneratorAdapter(ACC_PUBLIC, m, mv);
      ga.visitCode();
      ga.loadArg(0);
      Label label = new Label();
      ga.ifZCmp(GeneratorAdapter.LT, label);
View Full Code Here


      clinit = new GeneratorAdapter(ACC_STATIC, CLINIT, mv);
      clinit.visitCode();
    }

    for (int i = 0; i < itf.getMethods().length; ++i) {
      Method m = getMethod(itf.getMethods()[i]);

      mv = cv.visitMethod(ACC_PUBLIC, m.getName(), m.getDescriptor(),
          null, null);
      if (mv != null) {
        String field = "_M" + i;
        FieldVisitor fv = cv.visitField(ACC_PRIVATE + ACC_STATIC,
            field, METHOD.getDescriptor(), null, null);
        if (fv != null) {
          fv.visitEnd();
        }

        if (clinit != null) {
          Type[] formals = m.getArgumentTypes();
          clinit.push(Type.getType(itf));
          clinit.push(m.getName());
          clinit.push(formals.length);
          clinit.newArray(CLASS);
          for (int j = 0; j < formals.length; ++j) {
            clinit.dup();
            clinit.push(j);
            clinit.push(formals[j]);
            clinit.arrayStore(CLASS);
          }
          clinit.invokeVirtual(CLASS, GET_METHOD);
          clinit.putStatic(type, field, METHOD);
        }

        GeneratorAdapter ga = new GeneratorAdapter(ACC_PUBLIC, m, mv);
        ga.visitCode();
        ga.loadThis();
        ga.getField(PROXY, "h", HANDLER);
        ga.loadThis();
        ga.getStatic(type, field, METHOD);
        ga.loadArgArray();
        ga.invokeInterface(HANDLER, INVOKE);
        if (m.getReturnType() != Type.VOID_TYPE) {
          ga.unbox(m.getReturnType());
        }
        ga.returnValue();
        ga.endMethod();
      }
    }
View Full Code Here

    Type returnType = Type.getType(m.getReturnType());
    Type[] argTypes = new Type[m.getParameterTypes().length];
    for (int i = 0; i < argTypes.length; ++i) {
      argTypes[i] = Type.getType(m.getParameterTypes()[i]);
    }
    return new Method(m.getName(), returnType, argTypes);
  }
View Full Code Here

            // drop exception and just return
            pop();
            visitInsn(Opcodes.RETURN);
        } else {
            // fetch value from exception, unbox if needed and return value
            Method getReturnValueMethod = Method.getMethod("Object getReturnValue()");
            invokeVirtual(CFG.EARLY_RETURN_EXCEPTION_TYPE, getReturnValueMethod);
            unbox(returnType);
            returnValue();
        }

        iterator = cfg.triggerDetails();

        while (iterator.hasNext()) {
            TriggerDetails details = iterator.next();
            visitLabel(details.getThrowHandler());
        }

        if (Transformer.isVerbose()) {
            getStatic(Type.getType(System.class), "out", Type.getType(PrintStream.class));
            visitLdcInsn("caught ThrowException");
            invokeVirtual(Type.getType(PrintStream.class), Method.getMethod("void println(String)"));
        }
        // fetch value from exception, unbox if needed and return value
        Method getThrowableMethod = Method.getMethod("Throwable getThrowable()");
        invokeVirtual(CFG.THROW_EXCEPTION_TYPE, getThrowableMethod);
        throwException();

        // execute exception  comes last because it is the super of the othher two classes
       
View Full Code Here

        // we need to set this here to avoid recursive re-entry into inject routine

        rule.setTypeInfo(getTriggerClass(), access, name, descriptor, exceptions);
        String key = rule.getKey();
        Type ruleType = Type.getType(TypeHelper.externalizeType("org.jboss.byteman.rule.Rule"));
        Method method = Method.getMethod("void execute(String, Object, Object[])");
        // we are at the relevant line in the method -- so add a trigger call here
        if (Transformer.isVerbose()) {
            System.out.println("RuleTriggerMethodAdapter.injectTriggerPoint : inserting trigger into " + getTriggerClass() + "." + getMethodName() + " for rule " + rule.getName());
        }
        Label startLabel = newLabel();
View Full Code Here

          mv.visitMethodInsn(INVOKESTATIC, ERT_NAME, "box", "(I)L" + ESMALL_TYPE + ";");
        }
       
       
       
        Method test_bif = get_test_bif(test, arg1.type);

        // System.err.println(test_bif);

        push(arg1, arg1.type);

        mv.visitMethodInsn(INVOKEVIRTUAL, EOBJECT_NAME,
            test_bif.getName(), test_bif.getDescriptor());

        Type returnType = test_bif.getReturnType();
        if (failLabel != 0) {
          // guard
          if (returnType.getSort() != Type.OBJECT)
            throw new Error("guards must return object type: "
                + test_bif);
View Full Code Here

   * @param m
   */
  public BuiltInFunction(java.lang.reflect.Method m) {
    this.javaMethod = m;
    this.owner = Type.getType(m.getDeclaringClass());
    this.method = new Method(m.getName(),
          Type.getType(m.getReturnType()),
          Type.getArgumentTypes(m));
    isVirtual = !Modifier.isStatic(m.getModifiers());
    boolean p = false;
    for (Class<?> c : m.getExceptionTypes()) {
View Full Code Here

    mark(beginTry);
   
    //Start dispatching, get the target object and store it
    loadThis();
    getField(typeBeingWoven, DISPATCHER_FIELD, DISPATCHER_TYPE);
    invokeInterface(DISPATCHER_TYPE, new Method("call", OBJECT_TYPE, NO_ARGS));
    storeLocal(dispatchTarget);
   
    //Pre-invoke, invoke, post-invoke, return
    writePreInvoke();
    //Start the real method
View Full Code Here

    //So arg is a WovenProxy, but not the same as last time, cast it and store
    //the result of unwrap.call in the arg
    loadArg(0);
    checkCast(WOVEN_PROXY_IFACE_TYPE);
    //Now unwrap
    invokeInterface(WOVEN_PROXY_IFACE_TYPE, new Method("org_apache_aries_proxy_weaving_WovenProxy_unwrap",
        DISPATCHER_TYPE, NO_ARGS));
   
    //Now we may have a Callable to invoke
    int callable = newLocal(DISPATCHER_TYPE);
    storeLocal(callable);
    loadLocal(callable);
    ifNull(unwrapFinished);
    loadLocal(callable);
    invokeInterface(DISPATCHER_TYPE, new Method("call",
        OBJECT_TYPE, NO_ARGS));
    //Store the result and we're done (for this iteration)
    storeArg(0);
    goTo(startUnwrap);
   
View Full Code Here

    } catch (Exception e) {
      //Should be impossible!
      throw new RuntimeException(NLS.MESSAGES.getMessage("error.finding.invocation.listener.method", name, Arrays.toString(argTypes)), e);
    }
    //get the ASM method
    return new Method(name, Type.getReturnType(ilMethod), Type.getArgumentTypes(ilMethod));
  }
View Full Code Here

TOP

Related Classes of org.objectweb.asm.commons.Method

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.