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

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


    boolean hasAtPrecedenceAnnotation = false;

    for (int i = 0; i < attributes.length; i++) {
      Attribute attribute = attributes[i];
      if (acceptAttribute(attribute)) {
        RuntimeAnnos rvs = (RuntimeAnnos) attribute;
        // we don't need to look for several attribute occurrences since
        // it cannot happen as per JSR175
        if (!isCodeStyleAspect && !javaClass.isInterface()) {
          hasAtAspectAnnotation = handleAspectAnnotation(rvs, struct);
          // TODO AV - if put outside the if isCodeStyleAspect then we
          // would enable mix style
          hasAtPrecedenceAnnotation = handlePrecedenceAnnotation(rvs, struct);
        }
        // there can only be one RuntimeVisible bytecode attribute
        break;
      }
    }

    // basic semantic check
    if (hasAtPrecedenceAnnotation && !hasAtAspectAnnotation) {
      msgHandler.handleMessage(new Message("Found @DeclarePrecedence on a non @Aspect type '" + type.getName() + "'",
          IMessage.WARNING, null, type.getSourceLocation()));
      // bypass what we have read
      return NO_ATTRIBUTES;
    }

    // the following block will not detect @Pointcut in non @Aspect types
    // for optimization purpose
    if (!(hasAtAspectAnnotation || isCodeStyleAspect) && !containsPointcut) {
      return NO_ATTRIBUTES;
    }

    // FIXME AV - turn on when ajcMightHaveAspect
    // if (hasAtAspectAnnotation && type.isInterface()) {
    // msgHandler.handleMessage(
    // new Message(
    // "Found @Aspect on an interface type '" + type.getName() + "'",
    // IMessage.WARNING,
    // null,
    // type.getSourceLocation()
    // )
    // );
    // // bypass what we have read
    // return EMPTY_LIST;
    // }

    // semantic check: @Aspect must be public
    // FIXME AV - do we really want to enforce that?
    // if (hasAtAspectAnnotation && !javaClass.isPublic()) {
    // msgHandler.handleMessage(
    // new Message(
    // "Found @Aspect annotation on a non public class '" +
    // javaClass.getClassName() + "'",
    // IMessage.ERROR,
    // null,
    // type.getSourceLocation()
    // )
    // );
    // return EMPTY_LIST;
    // }

    // code style pointcuts are class attributes
    // we need to gather the @AJ pointcut right now and not at method level
    // annotation extraction time
    // in order to be able to resolve the pointcut references later on
    // we don't need to look in super class, the pointcut reference in the
    // grammar will do it

    for (int i = 0; i < javaClass.getMethods().length; i++) {
      Method method = javaClass.getMethods()[i];
      if (method.getName().startsWith(NameMangler.PREFIX)) {
        continue; // already dealt with by ajc...
      }
      // FIXME alex optimize, this method struct will gets recreated for
      // advice extraction
      AjAttributeMethodStruct mstruct = null;
      boolean processedPointcut = false;
      Attribute[] mattributes = method.getAttributes();
      for (int j = 0; j < mattributes.length; j++) {
        Attribute mattribute = mattributes[j];
        if (acceptAttribute(mattribute)) {
          // TODO speed all this nonsense up rather than looking
          // through all the annotations every time
          // same for fields
          mstruct = new AjAttributeMethodStruct(method, null, type, context, msgHandler);
          processedPointcut = handlePointcutAnnotation((RuntimeAnnos) mattribute, mstruct);
          if (!processedPointcut) {
            processedPointcut = handleDeclareMixinAnnotation((RuntimeAnnos) mattribute, mstruct);
          }
          // there can only be one RuntimeVisible bytecode attribute
          break;
        }
      }
      if (processedPointcut) {
        // FIXME asc should check we aren't adding multiple versions...
        // will do once I get the tests passing again...
        struct.ajAttributes.add(new AjAttribute.WeaverVersionInfo());
        struct.ajAttributes.addAll(mstruct.ajAttributes);
      }
    }

    // code style declare error / warning / implements / parents are field
    // attributes
    Field[] fs = javaClass.getFields();
    for (int i = 0; i < fs.length; i++) {
      Field field = fs[i];
      if (field.getName().startsWith(NameMangler.PREFIX)) {
        continue; // already dealt with by ajc...
      }
      // FIXME alex optimize, this method struct will gets recreated for
      // advice extraction
      AjAttributeFieldStruct fstruct = new AjAttributeFieldStruct(field, null, type, context, msgHandler);
      Attribute[] fattributes = field.getAttributes();

      for (int j = 0; j < fattributes.length; j++) {
        Attribute fattribute = fattributes[j];
        if (acceptAttribute(fattribute)) {
          RuntimeAnnos frvs = (RuntimeAnnos) fattribute;
          if (handleDeclareErrorOrWarningAnnotation(model, frvs, fstruct)
              || handleDeclareParentsAnnotation(frvs, fstruct)) {
            // semantic check - must be in an @Aspect [remove if
            // previous block bypassed in advance]
            if (!type.isAnnotationStyleAspect() && !isCodeStyleAspect) {
View Full Code Here


    boolean hasAtAspectJAnnotationMustReturnVoid = false;
    for (int i = 0; i < attributes.length; i++) {
      Attribute attribute = attributes[i];
      try {
        if (acceptAttribute(attribute)) {
          RuntimeAnnos rvs = (RuntimeAnnos) attribute;
          hasAtAspectJAnnotationMustReturnVoid = hasAtAspectJAnnotationMustReturnVoid
              || handleBeforeAnnotation(rvs, struct, preResolvedPointcut);
          hasAtAspectJAnnotationMustReturnVoid = hasAtAspectJAnnotationMustReturnVoid
              || handleAfterAnnotation(rvs, struct, preResolvedPointcut);
          hasAtAspectJAnnotationMustReturnVoid = hasAtAspectJAnnotationMustReturnVoid
View Full Code Here

    for (int i = 0; i < attrs.length; i++) {
      if (attrs[i] instanceof ConstantValue) {
        setValue(((ConstantValue) attrs[i]).getConstantValueIndex());
      } else if (attrs[i] instanceof RuntimeAnnos) {
        RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attrs[i];
        List<AnnotationGen> l = runtimeAnnotations.getAnnotations();
        for (Iterator<AnnotationGen> it = l.iterator(); it.hasNext();) {
          AnnotationGen element = it.next();
          addAnnotation(new AnnotationGen(element, cp, false));
        }
      } else {
View Full Code Here

TOP

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

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.