Package org.aspectj.apache.bcel.classfile.annotation

Examples of org.aspectj.apache.bcel.classfile.annotation.Annotation


     * @param runtimeAnnotations
     * @param struct
     * @return true if found
     */
    private static boolean handleDeclareErrorOrWarningAnnotation(RuntimeAnnotations runtimeAnnotations, AjAttributeFieldStruct struct) {
        Annotation error = getAnnotation(runtimeAnnotations, AjcMemberMaker.DECLAREERROR_ANNOTATION);
        boolean hasError = false;
        if (error != null) {
            ElementNameValuePair declareError = getAnnotationElement(error, VALUE);
            if (declareError != null) {
                if (!STRING_DESC.equals(struct.field.getSignature()) || struct.field.getConstantValue() == null) {
                    reportError("@DeclareError used on a non String constant field", struct);
                    return false;
                }
                FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
                IScope binding = new BindingScope(
                        struct.enclosingType,
                        struct.context,
                        bindings
                );
                Pointcut pc = parsePointcut(declareError.getValue().stringifyValue(), struct, false);
                if (pc == null) {
                    hasError = false;//cannot parse pointcut
                } else {
                    pc .resolve(binding);
                    DeclareErrorOrWarning deow = new DeclareErrorOrWarning(true, pc, struct.field.getConstantValue().toString());
                    deow.setLocation(struct.context, -1, -1);
                    struct.ajAttributes.add(new AjAttribute.DeclareAttribute(deow));
                    hasError = true;
                }
            }
        }
        Annotation warning = getAnnotation(runtimeAnnotations, AjcMemberMaker.DECLAREWARNING_ANNOTATION);
        boolean hasWarning = false;
        if (warning != null) {
            ElementNameValuePair declareWarning = getAnnotationElement(warning, VALUE);
            if (declareWarning != null) {
                if (!STRING_DESC.equals(struct.field.getSignature()) || struct.field.getConstantValue() == null) {
View Full Code Here


     * @return annotation
     */
    private static Annotation getAnnotation(RuntimeAnnotations rvs, UnresolvedType annotationType) {
        final String annotationTypeName = annotationType.getName();
        for (Iterator iterator = rvs.getAnnotations().iterator(); iterator.hasNext();) {
            Annotation rv = (Annotation) iterator.next();
            if (annotationTypeName.equals(rv.getTypeName())) {
                return rv;
            }
        }
        return null;
    }
View Full Code Here

 
  /**
   * Retrieve an immutable version of this AnnotationGen
   */
  public Annotation getAnnotation() {
    Annotation a = new Annotation(typeIndex,cpool.getConstantPool(),isRuntimeVisible);
    for (Iterator iter = evs.iterator(); iter.hasNext();) {
      ElementNameValuePairGen element = (ElementNameValuePairGen) iter.next();
      a.addElementNameValuePair(element.getElementNameValuePair());
    }
    return a;
  }
View Full Code Here

      setValue(((ConstantValue)attrs[i]).getConstantValueIndex());
      } 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

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

    method.addAnnotation(annotation.getBcelAnnotation());
   }
  
   private void ensureAnnotationTypesRetrieved() {
    if (annotationTypes == null || method.getAnnotations().length!=annotations.length) { // sometimes the list changes underneath us!
        Annotation annos[] = method.getAnnotations();
        annotationTypes = new HashSet();
        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

    Attribute attr = attrs[i];
    if (attr instanceof RuntimeVisibleAnnotations) {
      RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations)attr;
      List annos = rva.getAnnotations();
      for (Iterator iter = annos.iterator(); iter.hasNext();) {
        Annotation a = (Annotation) iter.next();
        annotationGenObjs.add(new AnnotationGen(a,getConstantPool(),false));
      }
    } else if (attr instanceof RuntimeInvisibleAnnotations) {
      RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations)attr;
      List annos = ria.getAnnotations();
      for (Iterator iter = annos.iterator(); iter.hasNext();) {
        Annotation a = (Annotation) iter.next();
        annotationGenObjs.add(new AnnotationGen(a,getConstantPool(),false));
      }
    }
  }
    return (AnnotationGen[])annotationGenObjs.toArray(new AnnotationGen[]{});
View Full Code Here

      return ret;
    }
   
  private void ensureAnnotationTypesRetrieved() {
    if (annotationTypes == null) {
        Annotation annos[] = field.getAnnotations();
        annotationTypes = new HashSet();
        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

        }
   
        if (memberView!=null && memberView.getAnnotations()!=null && memberView.getAnnotations().length!=0) {
      AnnotationX[] ans = memberView.getAnnotations();
          for (int i = 0, len = ans.length; i < len; i++) {
      Annotation a= ans[i].getBcelAnnotation();
            gen.addAnnotation(new AnnotationGen(a,gen.getConstantPool(),true));
          }
        }
       
        if (isSynthetic) {
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.classfile.annotation.Annotation

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.