Package org.aspectj.apache.bcel.classfile

Examples of org.aspectj.apache.bcel.classfile.Method


    if (exceptionsThrown.size() > 0) {
      addAttribute(et = getExceptionTable(cp)); // Add `Exceptions' if there are "throws" clauses
    }

    Method m = new Method(modifiers, name_index, signature_index, getAttributesImmutable(), cp);

    // Undo effects of adding attributes
    // OPTIMIZE why redo this? is there a better way to clean up?
    if (lvt != null) {
      removeCodeAttribute(lvt);
View Full Code Here


    // 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
View Full Code Here

    if (declareMixinAnnotation == null) {
      // No annotation found
      return false;
    }

    Method annotatedMethod = struct.method;
    World world = struct.enclosingType.getWorld();
    NameValuePair declareMixinPatternNameValuePair = getAnnotationElement(declareMixinAnnotation, VALUE);

    // declareMixinPattern could be of the form "Bar*" or "A || B" or "Foo+"
    String declareMixinPattern = declareMixinPatternNameValuePair.getValue().stringifyValue();
    TypePattern targetTypePattern = parseTypePattern(declareMixinPattern, struct);

    // Return value of the annotated method is the interface or class that the mixin delegate should have
    ResolvedType methodReturnType = UnresolvedType.forSignature(annotatedMethod.getReturnType().getSignature()).resolve(world);

    if (methodReturnType.isPrimitiveType()) {
      reportError(getMethodForMessage(struct) + ":  factory methods for a mixin cannot return void or a primitive type",
          struct);
      return false;
    }

    if (annotatedMethod.getArgumentTypes().length > 1) {
      reportError(getMethodForMessage(struct) + ": factory methods for a mixin can take a maximum of one parameter", struct);
      return false;
    }

    // The set of interfaces to be mixed in is either:
View Full Code Here

   *
   * @param struct
   * @return null if no debug info is available
   */
  private static FormalBinding[] extractBindings(AjAttributeMethodStruct struct) throws UnreadableDebugInfoException {
    Method method = struct.method;
    String[] argumentNames = struct.getArgumentNames();

    // assert debug info was here
    if (argumentNames.length != method.getArgumentTypes().length) {
      reportError(
          "Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)",
          struct);
      throw new UnreadableDebugInfoException();
    }

    List<FormalBinding> bindings = new ArrayList<FormalBinding>();
    for (int i = 0; i < argumentNames.length; i++) {
      String argumentName = argumentNames[i];
      UnresolvedType argumentType = UnresolvedType.forSignature(method.getArgumentTypes()[i].getSignature());

      // do not bind JoinPoint / StaticJoinPoint /
      // EnclosingStaticJoinPoint
      // TODO solve me : this means that the JP/SJP/ESJP cannot appear as
      // binding
View Full Code Here

              }
            }
            worthRetrying.removeAll(forRemoval);
          }
          if (annotationsToAdd != null) {
            Method oldMethod = mg.getMethod();
            MethodGen myGen = new MethodGen(oldMethod, clazz.getClassName(), clazz.getConstantPool(), false);
            for (AnnotationGen a : annotationsToAdd) {
              myGen.addAnnotation(a);
            }
            Method newMethod = myGen.getMethod();
            members.set(memberCounter, new LazyMethodGen(newMethod, clazz));
          }

        }
      }
View Full Code Here

              }
            }
            worthRetrying.removeAll(forRemoval);
          }
          if (annotationsToAdd != null) {
            Method oldMethod = mg.getMethod();
            MethodGen myGen = new MethodGen(oldMethod, clazz.getClassName(), clazz.getConstantPool(), false);
            for (AnnotationGen a : annotationsToAdd) {
              myGen.addAnnotation(a);
            }
            Method newMethod = myGen.getMethod();
            members.set(memberCounter, new LazyMethodGen(newMethod, clazz));
          }

        }
      }
View Full Code Here

    if (exceptionsThrown.size() > 0) {
      addAttribute(et = getExceptionTable(cp)); // Add `Exceptions' if there are "throws" clauses
    }

    Method m = new Method(modifiers, name_index, signature_index, getAttributesImmutable(), cp);

    // Undo effects of adding attributes
    // OPTIMIZE why redo this? is there a better way to clean up?
    if (lvt != null) {
      removeCodeAttribute(lvt);
View Full Code Here

    // 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
View Full Code Here

    if (declareMixinAnnotation == null) {
      // No annotation found
      return false;
    }

    Method annotatedMethod = struct.method;
    World world = struct.enclosingType.getWorld();
    NameValuePair declareMixinPatternNameValuePair = getAnnotationElement(declareMixinAnnotation, VALUE);

    // declareMixinPattern could be of the form "Bar*" or "A || B" or "Foo+"
    String declareMixinPattern = declareMixinPatternNameValuePair.getValue().stringifyValue();
    TypePattern targetTypePattern = parseTypePattern(declareMixinPattern, struct);

    // Return value of the annotated method is the interface or class that the mixin delegate should have
    ResolvedType methodReturnType = UnresolvedType.forSignature(annotatedMethod.getReturnType().getSignature()).resolve(world);

    if (methodReturnType.isPrimitiveType()) {
      reportError(getMethodForMessage(struct) + ":  factory methods for a mixin cannot return void or a primitive type",
          struct);
      return false;
    }

    if (annotatedMethod.getArgumentTypes().length > 1) {
      reportError(getMethodForMessage(struct) + ": factory methods for a mixin can take a maximum of one parameter", struct);
      return false;
    }

    // The set of interfaces to be mixed in is either:
View Full Code Here

   *
   * @param struct
   * @return null if no debug info is available
   */
  private static FormalBinding[] extractBindings(AjAttributeMethodStruct struct) throws UnreadableDebugInfoException {
    Method method = struct.method;
    String[] argumentNames = struct.getArgumentNames();

    // assert debug info was here
    if (argumentNames.length != method.getArgumentTypes().length) {
      reportError(
          "Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)",
          struct);
      throw new UnreadableDebugInfoException();
    }

    List<FormalBinding> bindings = new ArrayList<FormalBinding>();
    for (int i = 0; i < argumentNames.length; i++) {
      String argumentName = argumentNames[i];
      UnresolvedType argumentType = UnresolvedType.forSignature(method.getArgumentTypes()[i].getSignature());

      // do not bind JoinPoint / StaticJoinPoint /
      // EnclosingStaticJoinPoint
      // TODO solve me : this means that the JP/SJP/ESJP cannot appear as
      // binding
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.classfile.Method

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.