Package org.aspectj.apache.bcel.generic.annotation

Examples of org.aspectj.apache.bcel.generic.annotation.AnnotationGen


       
        if (annotationsOnRealMember!=null) {
          for (int i = 0; i < annotationsOnRealMember.length; i++) {
            AnnotationX annotationX = annotationsOnRealMember[i];
            Annotation a = annotationX.getBcelAnnotation();
            AnnotationGen ag = new AnnotationGen(a,weaver.getLazyClassGen().getConstantPoolGen(),true);
            newMethod.addAnnotation(new AnnotationX(ag.getAnnotation(),weaver.getWorld()));
          }
        }
        // the below loop fixes the very special (and very stupid)
        // case where an aspect declares an annotation
        // on an ITD it declared on itself.
View Full Code Here


                }
                if (annotationsOnRealMember!=null) {
                    for (int i = 0; i < annotationsOnRealMember.length; i++) {
                        AnnotationX annotationX = annotationsOnRealMember[i];
                        Annotation a = annotationX.getBcelAnnotation();
                        AnnotationGen ag = new AnnotationGen(a,weaver.getLazyClassGen().getConstantPoolGen(),true);
                        mg.addAnnotation(new AnnotationX(ag.getAnnotation(),weaver.getWorld()));
                    }
                }
            }

            InstructionList body = new InstructionList();
View Full Code Here

      annotationsOnRealMember = realMember.getAnnotations();
      if (annotationsOnRealMember!=null) {
        for (int i = 0; i < annotationsOnRealMember.length; i++) {
          AnnotationX annotationX = annotationsOnRealMember[i];
          Annotation a = annotationX.getBcelAnnotation();
          AnnotationGen ag = new AnnotationGen(a,weaver.getLazyClassGen().getConstantPoolGen(),true);
          mg.addAnnotation(new AnnotationX(ag.getAnnotation(),weaver.getWorld()));
        }
      }
      // the below loop fixes the very special (and very stupid)
      // case where an aspect declares an annotation
      // on an ITD it declared on itself.
View Full Code Here

       
        if (annotationsOnRealMember!=null) {
          for (int i = 0; i < annotationsOnRealMember.length; i++) {
            AnnotationX annotationX = annotationsOnRealMember[i];
            Annotation a = annotationX.getBcelAnnotation();
            AnnotationGen ag = new AnnotationGen(a,weaver.getLazyClassGen().getConstantPoolGen(),true)
            fg.addAnnotation(ag);
          }
        }
       
        gen.addField(fg.getField(),getSourceLocation());
         
      }
        return true;
    } else if (onInterface && gen.getType().isTopmostImplementor(onType)) {
      // wew know that we can't be static since we don't allow statics on interfaces
      if (field.isStatic()) throw new RuntimeException("unimplemented");
      weaver.addInitializer(this);
      //System.err.println("impl body on " + gen.getType() + " for " + munger);
     
     
      Type fieldType =   BcelWorld.makeBcelType(field.getType());
       
      FieldGen fg = makeFieldGen(gen,AjcMemberMaker.interFieldInterfaceField(field, onType, aspectType));
         
        if (annotationsOnRealMember!=null) {
          for (int i = 0; i < annotationsOnRealMember.length; i++) {
            AnnotationX annotationX = annotationsOnRealMember[i];
            Annotation a = annotationX.getBcelAnnotation();
            AnnotationGen ag = new AnnotationGen(a,weaver.getLazyClassGen().getConstantPoolGen(),true)
            fg.addAnnotation(ag);
          }
        }
       
          gen.addField(fg.getField(),getSourceLocation());
View Full Code Here

                    unusedDecams.remove(decaM);
                    continue; // skip this one...
                  }
                 
                  Annotation a = decaM.getAnnotationX().getBcelAnnotation();
                  AnnotationGen ag = new AnnotationGen(a,clazz.getConstantPoolGen(),true);
                  Method oldMethod = mg.getMethod();
                  MethodGen myGen = new MethodGen(oldMethod,clazz.getClassName(),clazz.getConstantPoolGen());
                  myGen.addAnnotation(ag);
                  Method newMethod = myGen.getMethod();
                  mg.addAnnotation(decaM.getAnnotationX());
View Full Code Here

           
            if(decaF.getAnnotationX().isRuntimeVisible()){ // isAnnotationWithRuntimeRetention(clazz.getJavaClass(world))){
            //if(decaF.getAnnotationTypeX().isAnnotationWithRuntimeRetention(world)){           
              // it should be runtime visible, so put it on the Field
              Annotation a = decaF.getAnnotationX().getBcelAnnotation();
              AnnotationGen ag = new AnnotationGen(a,clazz.getConstantPoolGen(),true);
              FieldGen myGen = new FieldGen(fields[fieldCounter],clazz.getConstantPoolGen());
              myGen.addAnnotation(ag);
              Field newField = myGen.getField();
             
              aBcelField.addAnnotation(decaF.getAnnotationX());
View Full Code Here

      int countVisible   = 0;
      int countInvisible = 0;
   
      //  put the annotations in the right output stream
      for (int i=0; i<vec.size(); i++) {
        AnnotationGen a = (AnnotationGen)vec.get(i);
        if (a.isRuntimeVisible()) countVisible++;
        else         countInvisible++;
      }
   
      ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream();
      ByteArrayOutputStream riaBytes = new ByteArrayOutputStream();
      DataOutputStream rvaDos = new DataOutputStream(rvaBytes);
      DataOutputStream riaDos = new DataOutputStream(riaBytes);
   
      rvaDos.writeShort(countVisible);
      riaDos.writeShort(countInvisible);

      // put the annotations in the right output stream
      for (int i=0; i<vec.size(); i++) {
        AnnotationGen a = (AnnotationGen)vec.get(i);
        if (a.isRuntimeVisible()) a.dump(rvaDos);
        else         a.dump(riaDos);
      }

    rvaDos.close();
    riaDos.close();
   
View Full Code Here

   
      for (int i=0; i<vec.length; i++) {
          List l = vec[i];
          if (l!=null) {
            for (Iterator iter = l.iterator(); iter.hasNext();) {
        AnnotationGen element = (AnnotationGen) iter.next();
        if (element.isRuntimeVisible()) {visCount[i]++;totalVisCount++;}
        else                            {invisCount[i]++;totalInvisCount++;}
        }
          }
        }     
     
      // Lets do the visible ones
      ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream();
      DataOutputStream rvaDos = new DataOutputStream(rvaBytes);
      rvaDos.writeByte(vec.length); // First goes number of parameters
     
      for (int i=0; i<vec.length; i++) {
        rvaDos.writeShort(visCount[i]);
        if (visCount[i]>0) {
          List l = vec[i];
          for (Iterator iter = l.iterator(); iter.hasNext();) {
          AnnotationGen element = (AnnotationGen) iter.next();
          if (element.isRuntimeVisible()) element.dump(rvaDos);
        }
        }
      }
        rvaDos.close();
     
      // Lets do the invisible ones
      ByteArrayOutputStream riaBytes = new ByteArrayOutputStream();
      DataOutputStream riaDos = new DataOutputStream(riaBytes);
      riaDos.writeByte(vec.length); // First goes number of parameters
     
     for (int i=0; i<vec.length; i++) {
        riaDos.writeShort(invisCount[i]);
        if (invisCount[i]>0) {
          List l = vec[i];
          for (Iterator iter = l.iterator(); iter.hasNext();) {
          AnnotationGen element = (AnnotationGen) iter.next();
          if (!element.isRuntimeVisible()) element.dump(riaDos);
        }
        }
      }
        riaDos.close();
     
View Full Code Here

                null,//TODO AV - we could point to the aop.xml that defines it and use JSR-45
                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);
            mg.addAnnotation(max);

            InstructionList body = mg.getBody();
            body.append(InstructionConstants.RETURN);
View Full Code Here

      } else if (attrs[i] instanceof RuntimeAnnotations) {
    RuntimeAnnotations runtimeAnnotations = (RuntimeAnnotations)attrs[i];
    List l = runtimeAnnotations.getAnnotations();
    for (Iterator it = l.iterator(); it.hasNext();) {
      Annotation element = (Annotation) it.next();
      addAnnotation(new AnnotationGen(element,cp,false));
    }
      } else {
      addAttribute(attrs[i]);
      }
    }
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.generic.annotation.AnnotationGen

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.