Package org.aspectj.apache.bcel.generic

Examples of org.aspectj.apache.bcel.generic.ObjectType


                Modifier.PUBLIC + Constants.ACC_SUPER,
                EMPTY_STRINGS,
                m_world
        );
        AnnotationGen ag = new AnnotationGen(
                new ObjectType("org/aspectj/lang/annotation/Aspect"),
                Collections.EMPTY_LIST,
                true,
                cg.getConstantPoolGen()
        );
        cg.addAnnotation(ag.getAnnotation());
        if (m_concreteAspect.precedence != null) {
            SimpleElementValueGen svg = new SimpleElementValueGen(
                    ElementValueGen.STRING,
                    cg.getConstantPoolGen(),
                    m_concreteAspect.precedence
            );
            List elems = new ArrayList();
            elems.add(new ElementNameValuePairGen("value", svg, cg.getConstantPoolGen()));
            AnnotationGen agprec = new AnnotationGen(
                    new ObjectType("org/aspectj/lang/annotation/DeclarePrecedence"),
                    elems,
                    true,
                    cg.getConstantPoolGen()
            );
            cg.addAnnotation(agprec.getAnnotation());
        }

        // default constructor
        LazyMethodGen init = new LazyMethodGen(
                Modifier.PUBLIC,
                Type.VOID,
                "<init>",
                EMPTY_TYPES,
                EMPTY_STRINGS,
                cg
        );
        InstructionList cbody = init.getBody();
        cbody.append(InstructionConstants.ALOAD_0);
        cbody.append(cg.getFactory().createInvoke(
                (m_parent==null)?"java/lang/Object":m_parent.getName().replace('.', '/'),
                "<init>",
                Type.VOID,
                EMPTY_TYPES,
                Constants.INVOKESPECIAL
        ));
        cbody.append(InstructionConstants.RETURN);
        cg.addMethodGen(init);

        for (Iterator it = m_concreteAspect.pointcuts.iterator(); it.hasNext();) {
            Definition.Pointcut abstractPc = (Definition.Pointcut) it.next();

            LazyMethodGen mg = new LazyMethodGen(
                    Modifier.PUBLIC,//TODO AV - respect visibility instead of opening up?
                    Type.VOID,
                    abstractPc.name,
                    EMPTY_TYPES,
                    EMPTY_STRINGS,
                    cg
            );
            SimpleElementValueGen svg = new SimpleElementValueGen(
                    ElementValueGen.STRING,
                    cg.getConstantPoolGen(),
                    abstractPc.expression
            );
            List elems = new ArrayList();
            elems.add(new ElementNameValuePairGen("value", svg, cg.getConstantPoolGen()));
            AnnotationGen mag = new AnnotationGen(
                    new ObjectType("org/aspectj/lang/annotation/Pointcut"),
                    elems,
                    true,
                    cg.getConstantPoolGen()
            );
            AnnotationX max = new AnnotationX(mag.getAnnotation(), m_world);
View Full Code Here


        // I will now jump through some firey BCEL hoops to generate a trivial bit of code:
        // if (exc instanceof ExceptionInInitializerError)
        //    throw (ExceptionInInitializerError)exc;
        if (this.getEnclosingMethod().getName().equals("<clinit>")) {
            ResolvedType eiieType = world.resolve("java.lang.ExceptionInInitializerError");
            ObjectType eiieBcelType = (ObjectType)BcelWorld.makeBcelType(eiieType);
          InstructionList ih = new InstructionList(InstructionConstants.NOP);
          handler.append(exceptionVar.createLoad(fact));
          handler.append(fact.createInstanceOf(eiieBcelType));
          BranchInstruction bi =
                InstructionFactory.createBranchInstruction(Constants.IFEQ,ih.getStart());
View Full Code Here

    // ENH 42737
        exceptionVar.appendStore(rtExHandler, fact);
    // aload_1
    rtExHandler.append(exceptionVar.createLoad(fact));
    // instanceof class java/lang/RuntimeException
    rtExHandler.append(fact.createInstanceOf(new ObjectType("java.lang.RuntimeException")));
    // ifeq go to new SOFT_EXCEPTION_TYPE instruction
    rtExHandler.append(InstructionFactory.createBranchInstruction(Constants.IFEQ,handler.getStart()));
    // aload_1
    rtExHandler.append(exceptionVar.createLoad(fact));
    // athrow
View Full Code Here

    String aspectname = munger.getConcreteAspect().getName();
   
    String ptwField = NameMangler.perTypeWithinFieldForTarget(munger.getConcreteAspect());
    entrySuccessInstructions.append(new PUSH(fact.getConstantPool(),t.getName()));
   
    entrySuccessInstructions.append(fact.createInvoke(aspectname,"ajc$createAspectInstance",new ObjectType(aspectname),
        new Type[]{new ObjectType("java.lang.String")},Constants.INVOKESTATIC));
    entrySuccessInstructions.append(fact.createPutStatic(t.getName(),ptwField,
        new ObjectType(aspectname)));
   
    entryInstructions.append(entrySuccessInstructions);
   
    range.insert(entryInstructions, Range.InsideBefore);
  }
View Full Code Here

        if (thisJoinPointVar != null) {
          arrayVar.appendConvertableArrayStore(il, fact, stateIndex, thisJoinPointVar);
          thisJoinPointVar.setPositionInAroundState(stateIndex);
          stateIndex++;
        }
        il.append(fact.createNew(new ObjectType(constructor.getDeclaringType().getName())));
        il.append(new DUP());
        arrayVar.appendLoad(il, fact);
        il.append(Utility.createInvoke(fact, world, constructor));
        if (getKind() == PreInitialization) {
      il.append(InstructionConstants.DUP);
View Full Code Here

      modifiers |= Modifier.PUBLIC;
    }
    else {
      modifiers |= Modifier.PRIVATE;
    }
    ObjectType jpType = null;
    if (world.isTargettingAspectJRuntime12()) { // TAG:SUPPORTING12: We didn't have different staticjp types in 1.2
      jpType = staticTjpType;
    } else {
      jpType = isEnclosingJp?enclosingStaticTjpType:staticTjpType;
    }
View Full Code Here

     
      if (world.isTargettingAspectJRuntime12()) { // TAG:SUPPORTING12: We didn't have optimized factory methods in 1.2
          list.append(new PUSH(getConstantPoolGen(), sig.getSignatureString(shadow.getWorld())));
        list.append(fact.createInvoke(factoryType.getClassName(),
              sig.getSignatureMakerName(),
              new ObjectType(sig.getSignatureType()),
              new Type[] { Type.STRING },
              Constants.INVOKEVIRTUAL));
      } else   if (sig.getKind().equals(Member.METHOD)) {
        BcelWorld w = shadow.getWorld();
        // For methods, push the parts of the signature on.
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getModifiers(w))));
        list.append(new PUSH(getConstantPoolGen(),sig.getName()));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getDeclaringType())));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterTypes())));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterNames(w))));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getExceptions(w))));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getReturnType())));
        // And generate a call to the variant of makeMethodSig() that takes 7 strings
        list.append(fact.createInvoke(factoryType.getClassName(),
            sig.getSignatureMakerName(),
            new ObjectType(sig.getSignatureType()),
            new Type[] { Type.STRING,Type.STRING,Type.STRING,Type.STRING,Type.STRING,Type.STRING,Type.STRING },
            Constants.INVOKEVIRTUAL));
      } else if (sig.getKind().equals(Member.HANDLER)) {
        BcelWorld w = shadow.getWorld();
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getDeclaringType())));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterTypes())));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterNames(w))));
        list.append(fact.createInvoke(factoryType.getClassName(),
            sig.getSignatureMakerName(),
            new ObjectType(sig.getSignatureType()),
            new Type[] { Type.STRING, Type.STRING, Type.STRING },
            Constants.INVOKEVIRTUAL));     
      } else if(sig.getKind().equals(Member.CONSTRUCTOR)) {
        BcelWorld w = shadow.getWorld();
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getModifiers(w))))
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getDeclaringType())));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterTypes())));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterNames(w))));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getExceptions(w))));
        list.append(fact.createInvoke(factoryType.getClassName(),
            sig.getSignatureMakerName(),
            new ObjectType(sig.getSignatureType()),
            new Type[] { Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING },
            Constants.INVOKEVIRTUAL));     
      } else if(sig.getKind().equals(Member.FIELD)) {
        BcelWorld w = shadow.getWorld();
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getModifiers(w))));
        list.append(new PUSH(getConstantPoolGen(),sig.getName()));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getDeclaringType())));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getReturnType())));
        list.append(fact.createInvoke(factoryType.getClassName(),
            sig.getSignatureMakerName(),
            new ObjectType(sig.getSignatureType()),
            new Type[] { Type.STRING, Type.STRING, Type.STRING, Type.STRING },
            Constants.INVOKEVIRTUAL));     
      } else if(sig.getKind().equals(Member.ADVICE)) {
        BcelWorld w = shadow.getWorld();
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getModifiers(w))));
        list.append(new PUSH(getConstantPoolGen(),sig.getName()));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getDeclaringType())));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterTypes())));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterNames(w))));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getExceptions(w))));
        list.append(new PUSH(getConstantPoolGen(),makeString((sig.getReturnType()))));       
        list.append(fact.createInvoke(factoryType.getClassName(),
            sig.getSignatureMakerName(),
            new ObjectType(sig.getSignatureType()),
            new Type[] { Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING },
            Constants.INVOKEVIRTUAL));     
      } else if(sig.getKind().equals(Member.STATIC_INITIALIZATION)) {
        BcelWorld w = shadow.getWorld();
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getModifiers(w))));
        list.append(new PUSH(getConstantPoolGen(),makeString(sig.getDeclaringType())));
        list.append(fact.createInvoke(factoryType.getClassName(),
            sig.getSignatureMakerName(),
            new ObjectType(sig.getSignatureType()),
            new Type[] { Type.STRING, Type.STRING },
            Constants.INVOKEVIRTUAL));
      } else {
        list.append(new PUSH(getConstantPoolGen(), sig.getSignatureString(shadow.getWorld())));
        list.append(fact.createInvoke(factoryType.getClassName(),
             sig.getSignatureMakerName(),
             new ObjectType(sig.getSignatureType()),
             new Type[] { Type.STRING },
             Constants.INVOKEVIRTUAL));
      }    
     
      //XXX should load source location from shadow
View Full Code Here

      // Something like: "ajc$cflowCounter$0 = new CflowCounter();"
    LazyMethodGen clinit = gen.getAjcPreClinit(); //StaticInitializer();
    InstructionList setup = new InstructionList();
    InstructionFactory fact = gen.getFactory();

    setup.append(fact.createNew(new ObjectType(NameMangler.CFLOW_COUNTER_TYPE)));
    setup.append(InstructionFactory.createDup(1));
    setup.append(fact.createInvoke(
      NameMangler.CFLOW_COUNTER_TYPE,
      "<init>",
      Type.VOID,
View Full Code Here

        InstructionList il = new InstructionList();
        Member getClass = MemberImpl.method(UnresolvedType.OBJECT, 0, "getClass", "()Ljava/lang/Class;");
        il.append(Utility.createInvoke(fact, world, getClass));
        // aload annotationClass
        String s = hasAnnotation.getAnnotationType().getName();
        il.append(fact.createConstant(new ObjectType(hasAnnotation.getAnnotationType().getName())));
//        int annClassIndex = fact.getConstantPool().addClass(hasAnnotation.getAnnotationType().getSignature());
//        il.append(new LDC_W(annClassIndex));
        Member isAnnotationPresent = MemberImpl.method(UnresolvedType.forName("java/lang/Class"),0,
                "isAnnotationPresent","(Ljava/lang/Class;)Z");
        il.append(Utility.createInvoke(fact,world,isAnnotationPresent));
View Full Code Here

    /**
     * Visit a CHECKCAST
     * @param castExpr
     */
    public void visit(CastExpr castExpr) {
        instructions.append(fact.createCheckCast(new ObjectType(castExpr.getTypeName())));
    }
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.generic.ObjectType

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.