Package org.aspectj.apache.bcel.generic

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


    if (getType().isInterface() || shadowIsInAroundAdvice) {
      modifiers |= Modifier.PUBLIC;
    } else {
      modifiers |= Modifier.PRIVATE;
    }
    ObjectType jpType = null;
    // Did not have different static joinpoint types in 1.2
    if (world.isTargettingAspectJRuntime12()) {
      jpType = staticTjpType;
    } else {
      jpType = isEnclosingJp ? enclosingStaticTjpType : staticTjpType;
View Full Code Here


    if (world.isTargettingAspectJRuntime12() || !isFastSJPAvailable || !sig.getKind().equals(Member.METHOD)) {
      list.append(InstructionFactory.createLoad(factoryType, 0));
    }

    String signatureMakerName = SignatureUtils.getSignatureMakerName(sig);
    ObjectType signatureType = new ObjectType(SignatureUtils.getSignatureType(sig));
    UnresolvedType[] exceptionTypes = null;
    if (world.isTargettingAspectJRuntime12()) { // TAG:SUPPORTING12: We
      // didn't have optimized
      // factory methods in 1.2
      list.append(InstructionFactory.PUSH(cp, SignatureUtils.getSignatureString(sig, shadow.getWorld())));
View Full Code Here

                // Build the initial frame situation for this method.
                Frame f = new Frame(mg.getMaxLocals(), mg.getMaxStack());
                if (!mg.isStatic()) {
                    if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)) {
                        Frame._this = new UninitializedObjectType(new ObjectType(jc.getClassName()));
                        f.getLocals().set(0, Frame._this);
                    } else {
                        Frame._this = null;
                        f.getLocals().set(0, new ObjectType(jc.getClassName()));
                    }
                }
                Type[] argtypes = mg.getArgumentTypes();
                int twoslotoffset = 0;
                for (int j = 0; j < argtypes.length; j++) {
View Full Code Here

    if (getType().isInterface() || shadowIsInAroundAdvice) {
      modifiers |= Modifier.PUBLIC;
    } else {
      modifiers |= Modifier.PRIVATE;
    }
    ObjectType jpType = null;
    // Did not have different static joinpoint types in 1.2
    if (world.isTargettingAspectJRuntime12()) {
      jpType = staticTjpType;
    } else {
      jpType = isEnclosingJp ? enclosingStaticTjpType : staticTjpType;
View Full Code Here

    if (world.isTargettingAspectJRuntime12() || !isFastSJPAvailable || !sig.getKind().equals(Member.METHOD)) {
      list.append(InstructionFactory.createLoad(factoryType, 0));
    }

    String signatureMakerName = SignatureUtils.getSignatureMakerName(sig);
    ObjectType signatureType = new ObjectType(SignatureUtils.getSignatureType(sig));
    UnresolvedType[] exceptionTypes = null;
    if (world.isTargettingAspectJRuntime12()) { // TAG:SUPPORTING12: We
      // didn't have optimized
      // factory methods in 1.2
      list.append(InstructionFactory.PUSH(cp, SignatureUtils.getSignatureString(sig, shadow.getWorld())));
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, new Type[0], Constants.INVOKESPECIAL));

    setup.append(Utility.createSet(fact, cflowCounterField));
    clinit.getBody().insert(setup);
View Full Code Here

        + Constants.ACC_SUPER, EMPTY_STRINGS, world);
    if (parent != null && parent.isParameterizedType()) {
      cg.setSuperClass(parent);
    }
    if (perclauseString == null) {
      AnnotationGen ag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Aspect"),
          Collections.<NameValuePair> emptyList(), true, cg.getConstantPool());
      cg.addAnnotation(ag);
    } else {
      // List elems = new ArrayList();
      List<NameValuePair> elems = new ArrayList<NameValuePair>();
      elems.add(new NameValuePair("value",
          new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), perclauseString), cg.getConstantPool()));
      AnnotationGen ag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Aspect"), elems, true,
          cg.getConstantPool());
      cg.addAnnotation(ag);
    }
    if (concreteAspect.precedence != null) {
      SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), concreteAspect.precedence);
      List<NameValuePair> elems = new ArrayList<NameValuePair>();
      elems.add(new NameValuePair("value", svg, cg.getConstantPool()));
      AnnotationGen agprec = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/DeclarePrecedence"), elems, true,
          cg.getConstantPool());
      cg.addAnnotation(agprec);
    }

    // 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(parentName, "<init>", Type.VOID, EMPTY_TYPES, Constants.INVOKESPECIAL));
    cbody.append(InstructionConstants.RETURN);
    cg.addMethodGen(init);

    for (Iterator<Definition.Pointcut> it = concreteAspect.pointcuts.iterator(); it.hasNext();) {
      Definition.Pointcut abstractPc = (Definition.Pointcut) it.next();
      // TODO AV - respect visibility instead of opening up as public?
      LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, abstractPc.name, EMPTY_TYPES, EMPTY_STRINGS, cg);
      SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), abstractPc.expression);
      List<NameValuePair> elems = new ArrayList<NameValuePair>();
      elems.add(new NameValuePair("value", svg, cg.getConstantPool()));
      AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Pointcut"), elems, true,
          cg.getConstantPool());
      AnnotationAJ max = new BcelAnnotation(mag, world);
      mg.addAnnotation(max);

      InstructionList body = mg.getBody();
      body.append(InstructionConstants.RETURN);
      cg.addMethodGen(mg);
    }

    // Construct any defined declare error/warnings
    if (concreteAspect.deows.size() > 0) {
      int counter = 1;
      for (Definition.DeclareErrorOrWarning deow : concreteAspect.deows) {
        // Building this:
        // @DeclareWarning("call(* javax.sql..*(..)) && !within(org.xyz.daos..*)")
        // static final String aMessage = "Only DAOs should be calling JDBC.";

        FieldGen field = new FieldGen(Modifier.FINAL, ObjectType.STRING, "rule" + (counter++), cg.getConstantPool());
        SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), deow.pointcut);
        List<NameValuePair> elems = new ArrayList<NameValuePair>();
        elems.add(new NameValuePair("value", svg, cg.getConstantPool()));
        AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Declare"
            + (deow.isError ? "Error" : "Warning")), elems, true, cg.getConstantPool());
        field.addAnnotation(mag);

        field.setValue(deow.message);
        cg.addField(field, null);
View Full Code Here

   */
  private AnnotationAJ buildAdviceAnnotation(LazyClassGen cg, PointcutAndAdvice paa) {
    SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), paa.pointcut);
    List<NameValuePair> elems = new ArrayList<NameValuePair>();
    elems.add(new NameValuePair("value", svg, cg.getConstantPool()));
    AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/" + paa.adviceKind.toString()), elems,
        true, cg.getConstantPool());
    AnnotationAJ aaj = new BcelAnnotation(mag, world);
    return aaj;
  }
View Full Code Here

      retval = MemberImpl.method(ut, Modifier.PUBLIC, UnresolvedType.VOID, "<init>", new ResolvedType[] { INT });
    } else if (i instanceof MULTIANEWARRAY) {
      MULTIANEWARRAY arrayInstruction = (MULTIANEWARRAY) i;
      UnresolvedType ut = null;
      short dimensions = arrayInstruction.getDimensions();
      ObjectType ot = arrayInstruction.getLoadClassType(cpg);
      if (ot != null) {
        ut = fromBcel(ot);
        ut = UnresolvedType.makeArray(ut, dimensions);
      } else {
        Type t = arrayInstruction.getType(cpg);
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));
      InstructionBranch bi = InstructionFactory.createBranchInstruction(Constants.IFEQ, ih.getStart());
      handler.append(bi);
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.