Package org.aspectj.weaver

Examples of org.aspectj.weaver.ResolvedMember


   * @return
   */
  private ResolvedMember createOrGetInlineAccessorForFieldSet(ResolvedMember resolvedMember) {
    String accessor = NameMangler.inlineAccessMethodForFieldSet(resolvedMember.getName(), resolvedMember.getDeclaringType(),
        aspectType);
    ResolvedMember inlineAccessor = m_inlineAccessorBcelMethods.get(accessor);
    if (inlineAccessor == null) {
      // add static method to aspect
      inlineAccessor = AjcMemberMaker.inlineAccessMethodForFieldSet(aspectType, resolvedMember);

      // add new accessor method to aspect bytecode
View Full Code Here


  }

  private Annotation[] retrieveAnnotationFromBinaryTypeBinding(DeclareAnnotation decA, ReferenceBinding declaringBinding) {
    ReferenceType rt = (ReferenceType) factory.fromEclipse(declaringBinding);
    ResolvedMember[] methods = rt.getDeclaredMethods();
    ResolvedMember decaMethod = null;
    String nameToLookFor = decA.getAnnotationMethod();
    for (int i = 0; i < methods.length; i++) {
      if (methods[i].getName().equals(nameToLookFor)) {
        decaMethod = methods[i];
        break;
      }
    }
    if (decaMethod != null) { // could assert this ...
      AnnotationAJ[] axs = decaMethod.getAnnotations();
      if (axs != null) { // another error has occurred, dont crash here because of it
        Annotation[] toAdd = new Annotation[1];
        toAdd[0] = createAnnotationFromBcelAnnotation(axs[0], decaMethod.getSourceLocation().getOffset(), factory);
        // BUG BUG BUG - We dont test these abits are correct, in fact
        // we'll be very lucky if they are.
        // What does that mean? It means on an incremental compile you
        // might get away with an
        // annotation that isn't allowed on a type being put on a type.
View Full Code Here

   * @see org.aspectj.weaver.patterns.Pointcut#match(org.aspectj.weaver.Shadow)
   */
  protected FuzzyBoolean matchInternal(Shadow shadow) {
    AnnotatedElement toMatchAgainst = null;
    Member member = shadow.getSignature();
    ResolvedMember rMember = member.resolve(shadow.getIWorld());

    if (rMember == null) {
      if (member.getName().startsWith(NameMangler.PREFIX)) {
        return FuzzyBoolean.NO;
      }
      shadow.getIWorld().getLint().unresolvableMember.signal(member.toString(), getSourceLocation());
      return FuzzyBoolean.NO;
    }

    Shadow.Kind kind = shadow.getKind();
    if (kind == Shadow.StaticInitialization) {
      toMatchAgainst = rMember.getDeclaringType().resolve(shadow.getIWorld());
    } else if ((kind == Shadow.ExceptionHandler)) {
      toMatchAgainst = rMember.getParameterTypes()[0].resolve(shadow.getIWorld());
    } else {
      toMatchAgainst = rMember;
      // FIXME asc I'd like to get rid of this bit of logic altogether, shame ITD fields don't have an effective sig attribute
      // FIXME asc perf cache the result of discovering the member that contains the real annotations
      if (rMember.isAnnotatedElsewhere()) {
        if (kind == Shadow.FieldGet || kind == Shadow.FieldSet) {
          // FIXME asc should include supers with getInterTypeMungersIncludingSupers ?
          List mungers = rMember.getDeclaringType().resolve(shadow.getIWorld()).getInterTypeMungers();
          for (Iterator iter = mungers.iterator(); iter.hasNext();) {
            ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) iter.next();
            if (typeMunger.getMunger() instanceof NewFieldTypeMunger) {
              ResolvedMember fakerm = typeMunger.getSignature();
              if (fakerm.equals(member)) {
                ResolvedMember ajcMethod = AjcMemberMaker.interFieldInitializer(fakerm, typeMunger.getAspectType());
                ResolvedMember rmm = findMethod(typeMunger.getAspectType(), ajcMethod);
                toMatchAgainst = rmm;
              }
            }
          }
        }
View Full Code Here

    annotationTypePattern.resolve(shadow.getIWorld());
    return annotationTypePattern.matches(toMatchAgainst);
  }

  private ResolvedMember findMethod(ResolvedType aspectType, ResolvedMember ajcMethod) {
    ResolvedMember decMethods[] = aspectType.getDeclaredMethods();
    for (int i = 0; i < decMethods.length; i++) {
      ResolvedMember member = decMethods[i];
      if (member.equals(ajcMethod)) {
        return member;
      }
    }
    return null;
  }
View Full Code Here

    // Check that the formal is bound to a type that is represented by one field in the annotation type
    ReferenceType theAnnotationType = (ReferenceType) annotationType;
    ResolvedMember[] annotationFields = theAnnotationType.getDeclaredMethods();
    field = null;
    for (int i = 0; i < annotationFields.length; i++) {
      ResolvedMember resolvedMember = annotationFields[i];
      if (resolvedMember.getReturnType().equals(formalBinding.getType())) {
        if (field != null) {
          scope.message(IMessage.ERROR, this, "The field type '" + formalBinding.getType()
              + "' is ambiguous for annotation type '" + theAnnotationType.getName() + "'");
        }
        field = resolvedMember;
View Full Code Here

    for (Iterator<String> kIter = keys.iterator(); kIter.hasNext();) {
      String k = kIter.next();
      String v = annotationValues.get(k);
      boolean validKey = false;
      for (int i = 0; i < ms.length; i++) {
        ResolvedMember resolvedMember = ms[i];
        if (resolvedMember.getName().equals(k) && resolvedMember.isAbstract()) {
          validKey = true;
          ResolvedType t = resolvedMember.getReturnType().resolve(scope.getWorld());
          if (t.isEnum()) {
            // value must be an enum reference X.Y
            int pos = v.lastIndexOf(".");
            if (pos == -1) {
              IMessage m = MessageUtil.error(WeaverMessages
View Full Code Here

      // }
      hasSerialVersionUIDField = hasSerialVersionUIDField(getType());

      ResolvedMember[] methods = getType().getDeclaredMethods();
      for (int i = 0; i < methods.length; i++) {
        ResolvedMember method = methods[i];
        if (method.getName().equals("<clinit>")) {
          if (method.getKind() != Member.STATIC_INITIALIZATION) {
            throw new RuntimeException("qui?");
          }
          hasClinit = true;
        }
      }
View Full Code Here

  public static boolean hasSerialVersionUIDField(ResolvedType type) {

    ResolvedMember[] fields = type.getDeclaredFields();
    for (int i = 0; i < fields.length; i++) {
      ResolvedMember field = fields[i];
      if (field.getName().equals("serialVersionUID") && Modifier.isStatic(field.getModifiers())
          && field.getType().equals(ResolvedType.LONG)) {
        return true;
      }
    }

    return false;
View Full Code Here

      return;
    }

    // if the method in the declaring type is *not* visible to the
    // exact declaring type then warning not needed.
    ResolvedMember rm = shadow.getSignature().resolve(world);
    // rm can be null in the case where we are binary weaving, and looking at a class with a call to a method in another class,
    // but because of class incompatibilities, the method does not exist on the target class anymore.
    // this will be reported elsewhere.
    if (rm == null) {
      return;
    }

    int shadowModifiers = rm.getModifiers();
    if (!ResolvedType.isVisible(shadowModifiers, shadowDeclaringType, exactDeclaringType.resolve(world))) {
      return;
    }

    if (!signature.getReturnType().matchesStatically(shadow.getSignature().getReturnType().resolve(world))) {
View Full Code Here

    writeLocation(s);
  }

  public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException {
    boolean hasTestMethod = s.readBoolean();
    ResolvedMember resolvedTestMethod = null;
    if (hasTestMethod) { // should always have a test method unless @AJ style
      resolvedTestMethod = ResolvedMemberImpl.readResolvedMember(s, context);
    }
    IfPointcut ret = new IfPointcut(resolvedTestMethod, s.readByte());
    ret.readLocation(context, s);
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.