Package org.aspectj.apache.bcel.generic

Examples of org.aspectj.apache.bcel.generic.InstructionFactory.createInvoke()


    il.append(InstructionFactory.createReturn(Type.VOID));

    // patch <clinit> to delegate to ajc$postClinit at the end
    LazyMethodGen clinit = classGen.getStaticInitializer();
    il = new InstructionList();
    InstructionHandle tryStart = il.append(factory.createInvoke(aspectType.getName(), NameMangler.AJC_POST_CLINIT_NAME,
        Type.VOID, Type.NO_ARGS, Constants.INVOKESTATIC));
    InstructionBranch tryEnd = InstructionFactory.createBranchInstruction(Constants.GOTO, null);
    il.append(tryEnd);
    InstructionHandle handler = il.append(InstructionConstants.ASTORE_0);
    il.append(InstructionConstants.ALOAD_0);
View Full Code Here


    InstructionHandle ifNullElse = il.append(InstructionConstants.POP);
    ifNull.setTarget(ifNullElse);
    InstructionHandle ifEqElse = il.append(factory.createNew(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName()));
    ifEq.setTarget(ifEqElse);
    il.append(InstructionConstants.DUP);
    il.append(factory.createInvoke(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName(), "<init>", Type.VOID, Type.NO_ARGS,
        Constants.INVOKESPECIAL));
    il.append(InstructionConstants.ATHROW);
  }

  private void generatePerObjectHasAspectMethod(LazyClassGen classGen) {
View Full Code Here

    il.append(ifNonNull);
    il.append(InstructionConstants.ALOAD_0);
    il.append(factory.createCheckCast(interfaceType));
    il.append(factory.createNew(aspectType.getName()));
    il.append(InstructionConstants.DUP);
    il.append(factory.createInvoke(aspectType.getName(), "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
    il.append(Utility.createInvoke(factory, Constants.INVOKEINTERFACE, AjcMemberMaker.perObjectInterfaceSet(aspectType)));
    InstructionHandle end = il.append(InstructionFactory.createReturn(Type.VOID));
    ifEq.setTarget(end);
    ifNonNull.setTarget(end);
  }
View Full Code Here

    InstructionList il = method.getBody();
    il.append(Utility.createGet(factory, AjcMemberMaker.perCflowField(aspectType)));
    il.append(factory.createNew(aspectType.getName()));
    il.append(InstructionConstants.DUP);
    il.append(factory.createInvoke(aspectType.getName(), "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
    il.append(Utility.createInvoke(factory, Constants.INVOKEVIRTUAL, AjcMemberMaker.cflowStackPushInstance()));
    il.append(InstructionFactory.createReturn(Type.VOID));
  }

  private void generatePerCflowAjcClinitMethod(LazyClassGen classGen) {
View Full Code Here

    LazyMethodGen method = classGen.getAjcPreClinit(); // Creates a clinit if there isn't one

    InstructionList il = new InstructionList();
    il.append(factory.createNew(AjcMemberMaker.CFLOW_STACK_TYPE.getName()));
    il.append(InstructionConstants.DUP);
    il.append(factory.createInvoke(AjcMemberMaker.CFLOW_STACK_TYPE.getName(), "<init>", Type.VOID, Type.NO_ARGS,
        Constants.INVOKESPECIAL));
    il.append(Utility.createSet(factory, AjcMemberMaker.perCflowField(aspectType)));
    method.getBody().insert(il);
  }
View Full Code Here

    il.append(ifNonNull);
    il.append(factory.createNew(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName()));
    il.append(InstructionConstants.DUP);
    il.append(InstructionFactory.PUSH(classGen.getConstantPool(), aspectType.getName()));
    il.append(InstructionConstants.ACONST_NULL);
    il.append(factory.createInvoke(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName(), "<init>", Type.VOID, new Type[] {
        Type.STRING, new ObjectType("java.lang.Throwable") }, Constants.INVOKESPECIAL));
    il.append(InstructionConstants.ATHROW);
    InstructionHandle ifElse = il.append(InstructionConstants.ALOAD_1);
    ifNonNull.setTarget(ifElse);
    il.append(InstructionFactory.createReturn(Type.OBJECT));
View Full Code Here

    il.append(InstructionFactory.createReturn(Type.OBJECT));

    InstructionHandle handler = il.append(InstructionConstants.ASTORE_1);
    il.append(factory.createNew(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName()));
    il.append(InstructionConstants.DUP);
    il.append(factory.createInvoke(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName(), "<init>", Type.VOID, Type.NO_ARGS,
        Constants.INVOKESPECIAL));
    il.append(InstructionConstants.ATHROW);

    method.addExceptionHandler(tryStart, handler.getPrev(), handler, new ObjectType("java.lang.Exception"), false);
  }
View Full Code Here

    InstructionList il = method.getBody();
    InstructionHandle tryStart = il.append(InstructionConstants.ALOAD_0);
    il.append(InstructionFactory.PUSH(factory.getConstantPool(), NameMangler.perTypeWithinLocalAspectOf(aspectType)));
    il.append(InstructionConstants.ACONST_NULL);// Class[] for "getDeclaredMethod"
    il.append(factory.createInvoke("java/lang/Class", "getDeclaredMethod", Type.getType("Ljava/lang/reflect/Method;"),
        new Type[] { Type.getType("Ljava/lang/String;"), Type.getType("[Ljava/lang/Class;") }, Constants.INVOKEVIRTUAL));
    il.append(InstructionConstants.ACONST_NULL);// Object for "invoke", static method
    il.append(InstructionConstants.ACONST_NULL);// Object[] for "invoke", no arg
    il.append(factory.createInvoke("java/lang/reflect/Method", "invoke", Type.OBJECT, new Type[] {
        Type.getType("Ljava/lang/Object;"), Type.getType("[Ljava/lang/Object;") }, Constants.INVOKEVIRTUAL));
View Full Code Here

    il.append(InstructionConstants.ACONST_NULL);// Class[] for "getDeclaredMethod"
    il.append(factory.createInvoke("java/lang/Class", "getDeclaredMethod", Type.getType("Ljava/lang/reflect/Method;"),
        new Type[] { Type.getType("Ljava/lang/String;"), Type.getType("[Ljava/lang/Class;") }, Constants.INVOKEVIRTUAL));
    il.append(InstructionConstants.ACONST_NULL);// Object for "invoke", static method
    il.append(InstructionConstants.ACONST_NULL);// Object[] for "invoke", no arg
    il.append(factory.createInvoke("java/lang/reflect/Method", "invoke", Type.OBJECT, new Type[] {
        Type.getType("Ljava/lang/Object;"), Type.getType("[Ljava/lang/Object;") }, Constants.INVOKEVIRTUAL));
    il.append(factory.createCheckCast((ReferenceType) BcelWorld.makeBcelType(aspectType)));
    il.append(InstructionConstants.ARETURN);

    InstructionHandle handler = il.append(InstructionConstants.ASTORE_1);
View Full Code Here

    classGen.addMethodGen(method);

    InstructionList il = method.getBody();
    il.append(factory.createNew(aspectType.getName()));
    il.append(InstructionConstants.DUP);
    il.append(factory.createInvoke(aspectType.getName(), "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
    il.append(InstructionConstants.ASTORE_1);
    il.append(InstructionConstants.ALOAD_1);
    il.append(InstructionConstants.ALOAD_0);
    il.append(Utility.createSet(factory, AjcMemberMaker.perTypeWithinWithinTypeField(aspectType, aspectType)));
    il.append(InstructionConstants.ALOAD_1);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.