Package org.aspectj.weaver

Examples of org.aspectj.weaver.AnnotationAJ


    // which is holding them.
    if (weaver.getWorld().isInJava5Mode()) {

      ResolvedMember interMethodDispatcher = AjcMemberMaker.postIntroducedConstructor(aspectType, onType,
          newConstructorTypeMunger.getSignature().getParameterTypes());
      AnnotationAJ annotationsOnRealMember[] = null;
      ResolvedMember realMember = getRealMemberForITDFromAspect(aspectType, interMethodDispatcher, true);
      // 266602 - consider it missing to mean that the corresponding aspect had errors
      if (realMember == null) {
        // signalWarning("Unable to apply any annotations attached to " + munger.getSignature(), weaver);
        // throw new BCException("Couldn't find ITD init member '" + interMethodBody + "' on aspect " + aspectType);
      } else {
        annotationsOnRealMember = realMember.getAnnotations();
      }
      if (annotationsOnRealMember != null) {
        for (int i = 0; i < annotationsOnRealMember.length; i++) {
          AnnotationAJ annotationX = annotationsOnRealMember[i];
          AnnotationGen a = ((BcelAnnotation) annotationX).getBcelAnnotation();
          AnnotationGen ag = new AnnotationGen(a, weaver.getLazyClassGen().getConstantPool(), true);
          mg.addAnnotation(new BcelAnnotation(ag, weaver.getWorld()));
        }
      }
View Full Code Here


      return false;
    }

    ResolvedMember interMethodBody = munger.getInitMethod(aspectType);

    AnnotationAJ 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) {
        // signalWarning("Unable to apply any annotations attached to " + munger.getSignature(), weaver);
        // throw new BCException("Couldn't find ITD init member '" + interMethodBody + "' on aspect " + aspectType);
      } else {
        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);
        ResolvedMember newField = AjcMemberMaker.interFieldClassField(field, aspectType,
            munger.version == NewFieldTypeMunger.VersionTwo);
        FieldGen fg = makeFieldGen(gen, newField);

        if (annotationsOnRealMember != null) {
          for (int i = 0; i < annotationsOnRealMember.length; i++) {
            AnnotationAJ annotationX = annotationsOnRealMember[i];
            AnnotationGen a = ((BcelAnnotation) annotationX).getBcelAnnotation();
            AnnotationGen ag = new AnnotationGen(a, weaver.getLazyClassGen().getConstantPool(), true);
            fg.addAnnotation(ag);
          }
        }

        if (weaver.getWorld().isInJava5Mode()) {
          String basicSignature = field.getSignature();
          String genericSignature = field.getReturnType().resolve(weaver.getWorld()).getSignatureForAttribute();
          // String genericSignature =
          // ((ResolvedMemberImpl)field).getSignatureForAttribute();
          if (!basicSignature.equals(genericSignature)) {
            // Add a signature attribute to it
            fg.addAttribute(createSignatureAttribute(gen.getConstantPool(), genericSignature));
          }
        }
        gen.addField(fg, 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 (Modifier.isStatic(field.getModifiers())) {
        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++) {
          AnnotationAJ annotationX = annotationsOnRealMember[i];
          AnnotationGen a = ((BcelAnnotation) annotationX).getBcelAnnotation();
          AnnotationGen ag = new AnnotationGen(a, weaver.getLazyClassGen().getConstantPool(), true);
          fg.addAnnotation(ag);
        }
      }
View Full Code Here

    if (varTable == null) {
      // do we have an annotation with the argNames value specified...
      if (hasAnnotations()) {
        AnnotationAJ[] axs = getAnnotations();
        for (int i = 0; i < axs.length; i++) {
          AnnotationAJ annotationX = axs[i];
          String typename = annotationX.getTypeName();
          if (typename.charAt(0) == 'o') {
            if (typename.equals("org.aspectj.lang.annotation.Pointcut")
                || typename.equals("org.aspectj.lang.annotation.Before")
                || typename.equals("org.aspectj.lang.annotation.Around")
                || typename.startsWith("org.aspectj.lang.annotation.After")) {
View Full Code Here

    return isChanged;
  }

  private boolean dontAddTwice(DeclareAnnotation decaF, AnnotationAJ[] dontAddMeTwice) {
    for (int i = 0; i < dontAddMeTwice.length; i++) {
      AnnotationAJ ann = dontAddMeTwice[i];
      if (ann != null && decaF.getAnnotation().getTypeName().equals(ann.getTypeName())) {
        // dontAddMeTwice[i] = null; // incase it really has been added
        // twice!
        return true;
      }
    }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.AnnotationAJ

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.