Package org.aspectj.weaver

Examples of org.aspectj.weaver.AnnotationX


        annotations = new AnnotationX[annos.length];
        for (int i = 0; i < annos.length; i++) {
        Annotation annotation = annos[i];
        ResolvedType rtx = getResolvedTypeX().getWorld().resolve(UnresolvedType.forName(annotation.getTypeName()));
        annotationTypes[i] = rtx;
        annotations[i] = new AnnotationX(annotation,getResolvedTypeX().getWorld());
      }
      }
  }
View Full Code Here


     
      // pr98901
        // For copying the annotations across, we have to discover the real member in the aspect
        // which is holding them.
      if (weaver.getWorld().isInJava5Mode()){
        AnnotationX annotationsOnRealMember[] = null;
        ResolvedType toLookOn = aspectType;
        if (aspectType.isRawType()) toLookOn = aspectType.getGenericType();
        ResolvedMember realMember = getRealMemberForITDFromAspect(toLookOn,memberHoldingAnyAnnotations,false);
        if (realMember==null) throw new BCException("Couldn't find ITD holder member '"+
            memberHoldingAnyAnnotations+"' on aspect "+aspectType);
        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);
            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

                    gen
            );

            //annotation copy from annotation on ITD interface
            if (weaver.getWorld().isInJava5Mode()){
                AnnotationX annotationsOnRealMember[] = null;
                ResolvedType toLookOn = weaver.getWorld().lookupOrCreateName(introduced.getDeclaringType());
                if (fromType.isRawType()) toLookOn = fromType.getGenericType();
                // lookup the method
                ResolvedMember[] ms = toLookOn.getDeclaredJavaMethods();
                for (int i = 0; i < ms.length; i++) {
                    ResolvedMember m = ms[i];
                    if (introduced.getName().equals(m.getName()) && introduced.getSignature().equals(m.getSignature())) {
                        annotationsOnRealMember = m.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()));
                    }
                }
            }

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

      // For copying the annotations across, we have to discover the real member in the aspect
      // which is holding them.
    if (weaver.getWorld().isInJava5Mode()){
     
      ResolvedMember interMethodDispatcher =AjcMemberMaker.postIntroducedConstructor(aspectType,onType,newConstructorTypeMunger.getSignature().getParameterTypes());
      AnnotationX annotationsOnRealMember[] = null;
      ResolvedMember realMember = getRealMemberForITDFromAspect(aspectType,interMethodDispatcher,true);
      if (realMember==null) throw new BCException("Couldn't find ITD holder member '"+
          interMethodDispatcher+"' on aspect "+aspectType);
      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

      return false;
    }
   
    ResolvedMember interMethodBody = munger.getInitMethod(aspectType);
   
    AnnotationX annotationsOnRealMember[] = null;
    // pr98901
      // For copying the annotations across, we have to discover the real member in the aspect
      // which is holding them.
    if (weaver.getWorld().isInJava5Mode()){
        // the below line just gets the method with the same name in aspectType.getDeclaredMethods();
        ResolvedType toLookOn = aspectType;
        if (aspectType.isRawType()) toLookOn = aspectType.getGenericType();
        ResolvedMember realMember = getRealMemberForITDFromAspect(toLookOn,interMethodBody,false);
        if (realMember==null) throw new BCException("Couldn't find ITD init member '"+
            interMethodBody+"' on aspect "+aspectType);
        annotationsOnRealMember = realMember.getAnnotations();
    }
   
    if (onType.equals(gen.getType())) {
      if (onInterface) {
        ResolvedMember itdfieldGetter = AjcMemberMaker.interFieldInterfaceGetter(field, onType, aspectType);
        LazyMethodGen mg = makeMethodGen(gen, itdfieldGetter);
        gen.addMethodGen(mg);
       
        LazyMethodGen mg1 = makeMethodGen(gen,
          AjcMemberMaker.interFieldInterfaceSetter(field, onType, aspectType));
        gen.addMethodGen(mg1);
      } else {
        weaver.addInitializer(this);
        FieldGen fg = makeFieldGen(gen,
          AjcMemberMaker.interFieldClassField(field, 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());
         
      }
        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);
          }
        }
       
View Full Code Here

//                onType.getSourceLocation(),new ISourceLocation[]{decA.getSourceLocation()});
//          }
          return false;
        }
     
      AnnotationX annoX = decA.getAnnotationX();
     
      // check the annotation is suitable for the target
      boolean problemReported = verifyTargetIsOK(decA, onType, annoX,reportProblems);

      if (!problemReported) {
View Full Code Here

                    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

        annotations = new AnnotationX[annos.length];
        for (int i = 0; i < annos.length; i++) {
        Annotation annotation = annos[i];
        ResolvedType rtx = world.resolve(UnresolvedType.forName(annotation.getTypeName()));
        annotationTypes.add(rtx);
        annotations[i] = new AnnotationX(annotation,world);
      }
      }
  }
View Full Code Here

        annotations = new AnnotationX[annos.length];
        for (int i = 0; i < annos.length; i++) {
        Annotation annotation = annos[i];
        ResolvedType rtx = world.resolve(UnresolvedType.forName(annotation.getTypeName()));
        annotationTypes.add(rtx);
        annotations[i] = new AnnotationX(annotation,world);
      }
      }
  }
View Full Code Here

    initialize();
    if (memberView==null) {
      // Check local annotations first
      if (newAnnotations!=null) {
        for (Iterator iter = newAnnotations.iterator(); iter.hasNext();) {
          AnnotationX element = (AnnotationX) iter.next();
          if (element.getBcelAnnotation().getTypeName().equals(annotationTypeX.getName())) return true;
        }
      }
            memberView = new BcelMethod(getEnclosingClass().getBcelObjectType(), getMethod());
            return memberView.hasAnnotation(annotationTypeX);
    }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.AnnotationX

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.