Package org.aspectj.weaver

Examples of org.aspectj.weaver.ResolvedMember


      // @AJ style, we need to find the testMethod in the aspect defining the "if()" enclosing pointcut
      ResolvedPointcutDefinition def = bindings.peekEnclosingDefinition();
      if (def != null) {
        ResolvedType aspect = inAspect.getWorld().resolve(def.getDeclaringType());
        for (Iterator memberIter = aspect.getMethods(true, true); memberIter.hasNext();) {
          ResolvedMember method = (ResolvedMember) memberIter.next();
          if (def.getName().equals(method.getName())
              && def.getParameterTypes().length == method.getParameterTypes().length) {
            boolean sameSig = true;
            for (int j = 0; j < method.getParameterTypes().length; j++) {
              UnresolvedType argJ = method.getParameterTypes()[j];
              if (!argJ.equals(def.getParameterTypes()[j])) {
                sameSig = false;
                break;
              }
            }
View Full Code Here


      UnresolvedType declaringType = this.getDeclaringType();
      if (declaringType instanceof ReferenceType) {
        ReferenceType referenceDeclaringType = (ReferenceType) declaringType;
        if (referenceDeclaringType.getDelegate() instanceof BcelObjectType) {
          // worth a look!
          ResolvedMember field = ((ResolvedType) declaringType).lookupField(this);
          if (field != null) {
            return field.getAnnotations();
          }
        }
      }
      return null;
    }
View Full Code Here

      UnresolvedType declaringType = this.getDeclaringType();
      if (declaringType instanceof ReferenceType) {
        ReferenceType referenceDeclaringType = (ReferenceType) declaringType;
        if (referenceDeclaringType.getDelegate() instanceof BcelObjectType) {
          // worth a look!
          ResolvedMember field = ((ResolvedType) declaringType).lookupField(this);
          if (field != null) {
            return field.getAnnotationOfType(ofType);
          }
        }
      }
    }
    return null;
View Full Code Here

        if (declaringType instanceof ReferenceType) {
          ReferenceType referenceDeclaringType = (ReferenceType) declaringType;
          if (referenceDeclaringType.getDelegate() instanceof BcelObjectType) {
            // worth a look!
            if (this.getKind() == Member.METHOD) {
              ResolvedMember method = ((ResolvedType) declaringType).lookupMethod(this);
              if (method != null) {
                cachedAnnotationTypes = method.getAnnotationTypes();
              }
            } else {
              ResolvedMember field = ((ResolvedType) declaringType).lookupField(this);
              if (field != null) {
                cachedAnnotationTypes = field.getAnnotationTypes();
              }
            }
          }
        }
      }
View Full Code Here

              ResolvedMember[] mm = impl.getDeclaredMethods();
              int implModifiers = impl.getModifiers();
              boolean defaultVisibilityImpl = !(Modifier.isPrivate(implModifiers)
                  || Modifier.isProtected(implModifiers) || Modifier.isPublic(implModifiers));
              boolean hasNoCtorOrANoArgOne = true;
              ResolvedMember foundOneOfIncorrectVisibility = null;
              for (int i = 0; i < mm.length; i++) {
                ResolvedMember resolvedMember = mm[i];
                if (resolvedMember.getName().equals("<init>")) {
                  hasNoCtorOrANoArgOne = false;

                  if (resolvedMember.getParameterTypes().length == 0) {
                    if (defaultVisibilityImpl) { // default
                      // visibility
                      // implementation
                      if (resolvedMember.isPublic() || resolvedMember.isDefault()) {
                        hasNoCtorOrANoArgOne = true;
                      } else {
                        foundOneOfIncorrectVisibility = resolvedMember;
                      }
                    } else if (Modifier.isPublic(implModifiers)) { // public
                      // implementation
                      if (resolvedMember.isPublic()) {
                        hasNoCtorOrANoArgOne = true;
                      } else {
                        foundOneOfIncorrectVisibility = resolvedMember;
                      }
                    }
                  }
                }
                if (hasNoCtorOrANoArgOne) {
                  break;
                }
              }
              if (!hasNoCtorOrANoArgOne) {
                if (foundOneOfIncorrectVisibility != null) {
                  reportError(
                      "@DeclareParents: defaultImpl=\""
                          + defaultImplClassName
                          + "\" has a no argument constructor, but it is of incorrect visibility.  It must be at least as visible as the type.",
                      struct);
                } else {
                  reportError("@DeclareParents: defaultImpl=\"" + defaultImplClassName
                      + "\" has no public no-arg constructor", struct);
                }
              }
              if (!fieldType.isAssignableFrom(impl)) {
                reportError("@DeclareParents: defaultImpl=\"" + defaultImplClassName
                    + "\" does not implement the interface '" + fieldType.toString() + "'", struct);
              }
            }

          }

          // then iterate on field interface hierarchy (not object)
          boolean hasAtLeastOneMethod = false;
          Iterator<ResolvedMember> methodIterator = fieldType.getMethodsIncludingIntertypeDeclarations(false, true);
          while (methodIterator.hasNext()) {
            ResolvedMember method = methodIterator.next();

            // ResolvedMember[] methods = fieldType.getMethodsWithoutIterator(true, false, false).toArray(
            // new ResolvedMember[0]);
            // for (int i = 0; i < methods.length; i++) {
            // ResolvedMember method = methods[i];
            if (method.isAbstract()) {
              // moved to be detected at weave time if the target
              // doesnt implement the methods
              // if (defaultImplClassName == null) {
              // // non marker interface with no default impl
              // provided
              // reportError("@DeclareParents: used with a non marker interface and no defaultImpl=\"...\" provided",
              // struct);
              // return false;
              // }
              hasAtLeastOneMethod = true;
              // What we are saying here:
              // We have this method 'method' and we want to put a
              // forwarding method into a type that matches
              // typePattern that should delegate to the version
              // of the method in 'defaultImplClassName'

              // Now the method may be from a supertype but the
              // declaring type of the method we pass into the
              // type
              // munger is what is used to determine the type of
              // the field that hosts the delegate instance.
              // So here we create a modified method with an
              // alternative declaring type so that we lookup
              // the right field. See pr164016.
              MethodDelegateTypeMunger mdtm = new MethodDelegateTypeMunger(method, struct.enclosingType,
                  defaultImplClassName, typePattern);
              mdtm.setFieldType(fieldType);
              mdtm.setSourceLocation(struct.enclosingType.getSourceLocation());
              struct.ajAttributes.add(new AjAttribute.TypeMunger(mdtm));
            }
          }
          // successfull so far, we thus need a bcel type munger to
          // have
          // a field hosting the mixin in the target type
          if (hasAtLeastOneMethod && defaultImplClassName != null) {
            ResolvedMember fieldHost = AjcMemberMaker.itdAtDeclareParentsField(null, fieldType, struct.enclosingType);
            struct.ajAttributes.add(new AjAttribute.TypeMunger(new MethodDelegateTypeMunger.FieldHostTypeMunger(
                fieldHost, struct.enclosingType, typePattern)));
          }

          return true;
View Full Code Here

      // TODO check for overlapping interfaces. Eg. A implements I, I extends J - if they specify interfaces={I,J} we dont
      // want to do any methods twice
      ResolvedMember[] methods = typeForDelegation.getMethodsWithoutIterator(true, false, false).toArray(
          new ResolvedMember[0]);
      for (int i = 0; i < methods.length; i++) {
        ResolvedMember method = methods[i];
        if (method.isAbstract()) {
          hasAtLeastOneMethod = true;
          if (method.hasBackingGenericMember()) {
            method = method.getBackingGenericMember();
          }
          MethodDelegateTypeMunger mdtm = new MethodDelegateTypeMunger(method, struct.enclosingType, "",
              targetTypePattern, struct.method.getName(), struct.method.getSignature());
          mdtm.setFieldType(methodReturnType);
          mdtm.setSourceLocation(struct.enclosingType.getSourceLocation());
          struct.ajAttributes.add(new AjAttribute.TypeMunger(mdtm));
        }
      }
    }
    // if any method delegate was created then a field to hold the delegate instance must also be added
    if (hasAtLeastOneMethod) {
      ResolvedMember fieldHost = AjcMemberMaker.itdAtDeclareParentsField(null, methodReturnType, struct.enclosingType);
      struct.ajAttributes.add(new AjAttribute.TypeMunger(new MethodDelegateTypeMunger.FieldHostTypeMunger(fieldHost,
          struct.enclosingType, targetTypePattern)));
    }
    return true;
  }
View Full Code Here

    // For intertype decls, use the modifiers from the original signature,
    // not the generated method

    if (methodDeclaration instanceof InterTypeDeclaration) {
      InterTypeDeclaration itd = (InterTypeDeclaration) methodDeclaration;
      ResolvedMember sig = itd.getSignature();
      peNode = new ProgramElement(activeStructureModel, null, IProgramElement.Kind.ERROR, makeLocation(methodDeclaration),
          (sig != null ? sig.getModifiers() : 0), null, null);

    } else {
      peNode = new ProgramElement(activeStructureModel, null, IProgramElement.Kind.ERROR, makeLocation(methodDeclaration),
          methodDeclaration.modifiers, null, null);
    }
View Full Code Here

  public AbstractMethodDeclaration sourceMethod;

  public InterTypeMethodBinding(EclipseFactory world, ResolvedTypeMunger munger, UnresolvedType withinType,
      AbstractMethodDeclaration sourceMethod) {
    super();
    ResolvedMember signature = munger.getSignature();
    MethodBinding mb = world.makeMethodBinding(signature, munger.getTypeVariableAliases());
    this.modifiers = mb.modifiers;
    this.selector = mb.selector;
    this.returnType = mb.returnType;
    this.parameters = mb.parameters;
    this.thrownExceptions = mb.thrownExceptions;
    this.typeVariables = mb.typeVariables;
    this.sourceMethod = sourceMethod;
    this.targetType = (ReferenceBinding) world.makeTypeBinding(signature.getDeclaringType());
    this.declaringClass = (ReferenceBinding) world.makeTypeBinding(withinType);

    // Ok, we need to set the typevariable declaring elements
    // 1st set:
    // If the typevariable is one declared on the source method, then we know we are the declaring element
    for (int i = 0; i < typeVariables.length; i++) {
      typeVariables[i].declaringElement = this;
    }
    for (int i = 0; i < typeVariables.length; i++) {
      if (typeVariables[i].declaringElement == null)
        throw new RuntimeException("Declaring element not set");

    }
    // typeVariables[0].declaringElement=this;
    // if (tVar.getDeclaringElement() instanceof Member) {
    // declaringElement = makeMethodBinding((ResolvedMember)tVar.getDeclaringElement());
    // } else {
    // declaringElement = makeTypeBinding((UnresolvedType)tVar.getDeclaringElement());
    // }
    if (signature.getKind() == Member.METHOD) {
      syntheticMethod = world.makeMethodBinding(AjcMemberMaker.interMethodDispatcher(signature, withinType));
      postDispatchMethod = world.makeMethodBinding(AjcMemberMaker.interMethodBody(signature, withinType));
    } else {
      syntheticMethod = world.makeMethodBinding(AjcMemberMaker.interConstructor(world.getWorld().resolve(
          signature.getDeclaringType()), signature, withinType));
      postDispatchMethod = syntheticMethod;
    }

  }
View Full Code Here

      // so we don't have to worry about interfaces, just the superclass.
      onTypeX = factory.fromEclipse(type.superclass()); // abstractMethod.declaringClass);
    }
    for (Iterator i = onTypeX.getInterTypeMungersIncludingSupers().iterator(); i.hasNext();) {
      ConcreteTypeMunger m = (ConcreteTypeMunger) i.next();
      ResolvedMember sig = m.getSignature();
      if (!Modifier.isAbstract(sig.getModifiers())) {
        if (ResolvedType.matches(
            AjcMemberMaker.interMethod(sig, m.getAspectType(), sig.getDeclaringType().resolve(factory.getWorld())
                .isInterface()), factory.makeResolvedMember(concreteMethod))) {
          return;
        }
      }
    }
View Full Code Here

    if (onTypeX.isRawType())
      onTypeX = onTypeX.getGenericType();

    List<ConcreteTypeMunger> mungers = onTypeX.getInterTypeMungersIncludingSupers();
    for (ConcreteTypeMunger m : mungers) {
      ResolvedMember sig = m.getSignature();
      if (sig != null && !Modifier.isAbstract(sig.getModifiers())) {
        ResolvedMember abstractMember = factory.makeResolvedMember(abstractMethod);
        if (abstractMember.getName().startsWith("ajc$interMethodDispatch")) {
          ResolvedType dType = factory.getWorld().resolve(sig.getDeclaringType(), false);
          if (ResolvedType.matches(AjcMemberMaker.interMethod(sig, m.getAspectType(), dType.isInterface()),
              abstractMember)) {
            return;
          }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.ResolvedMember

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.