Package org.aspectj.weaver

Examples of org.aspectj.weaver.ResolvedMember


        // we're in a call shadow therefore need the line number of the
        // declared method (which may be in a different type). However,
        // we want to remove the problems from the CompilationResult
        // held within the current type's EclipseSourceContext so need
        // the enclosing shadow too
        ResolvedMember resolvedMember = shadow.getSignature().resolve(shadow.getWorld());
        if (resolvedMember instanceof BcelMethod && shadow.getEnclosingShadow() instanceof BcelShadow) {
          Member enclosingMember = shadow.getEnclosingShadow().getSignature();
          if (enclosingMember instanceof BcelMethod) {
            removeUnnecessaryProblems((BcelMethod) enclosingMember,
                ((BcelMethod) resolvedMember).getDeclarationLineNumber());
View Full Code Here


    if (thrownExceptions == null) {
      // ??? can we really lump in Around here, how does this interact with Throwable
      if (concreteAspect != null && concreteAspect.getWorld() != null && // null tests for test harness
          (getKind().isAfter() || getKind() == AdviceKind.Before || getKind() == AdviceKind.Around)) {
        World world = concreteAspect.getWorld();
        ResolvedMember m = world.resolve(signature);
        if (m == null) {
          thrownExceptions = Collections.emptyList();
        } else {
          thrownExceptions = collectCheckedExceptions(m.getExceptions());
        }
      } else {
        thrownExceptions = Collections.emptyList();
      }
    }
View Full Code Here

  @Override
  public Member getOriginalSignature() {
    Member sig = getSignature();
    if (sig instanceof ResolvedMember) {
      ResolvedMember rsig = (ResolvedMember) sig;
      if (rsig.hasBackingGenericMember()) {
        return rsig.getBackingGenericMember();
      }
    }
    return sig;
  }
View Full Code Here

      ResolvedMember theBridgeMethod) {
    InstructionList body;
    InstructionFactory fact;
    int pos = 0;

    ResolvedMember whatToBridgeTo = whatToBridgeToMethodGen.getMemberView();

    if (whatToBridgeTo == null) {
      whatToBridgeTo = new ResolvedMemberImpl(Member.METHOD, whatToBridgeToMethodGen.getEnclosingClass().getType(),
          whatToBridgeToMethodGen.getAccessFlags(), whatToBridgeToMethodGen.getName(),
          whatToBridgeToMethodGen.getSignature());
View Full Code Here

    // at visibility
    // rules

    ResolvedMember[] methods = typeToCheck.getDeclaredMethods();
    for (int ii = 0; ii < methods.length; ii++) {
      ResolvedMember methodThatMightBeGettingOverridden = methods[ii]; // the
      // method
      // we
      // are
      // going
      // to
      // check
      ResolvedMember isOverriding = isOverriding(typeToCheck, methodThatMightBeGettingOverridden, mname, mrettype, mmods,
          inSamePackage, methodParamsArray);
      if (isOverriding != null) {
        return isOverriding;
      }
    }
    // was: List l = typeToCheck.getInterTypeMungers();
    List<ConcreteTypeMunger> l = (typeToCheck.isRawType() ? typeToCheck.getGenericType().getInterTypeMungers() : typeToCheck
        .getInterTypeMungers());
    for (Iterator<ConcreteTypeMunger> iterator = l.iterator(); iterator.hasNext();) {
      ConcreteTypeMunger o = iterator.next();
      // FIXME asc if its not a BcelTypeMunger then its an
      // EclipseTypeMunger ... do I need to worry about that?
      if (o instanceof BcelTypeMunger) {
        BcelTypeMunger element = (BcelTypeMunger) o;
        if (element.getMunger() instanceof NewMethodTypeMunger) {
          if (typeToCheck.getWorld().forDEBUG_bridgingCode) {
            System.err.println("Possible ITD candidate " + element);
          }
          ResolvedMember aMethod = element.getSignature();
          ResolvedMember isOverriding = isOverriding(typeToCheck, aMethod, mname, mrettype, mmods, inSamePackage,
              methodParamsArray);
          if (isOverriding != null) {
            return isOverriding;
          }
        }
      }
    }

    if (typeToCheck.equals(UnresolvedType.OBJECT)) {
      return null;
    }

    ResolvedType superclass = typeToCheck.getSuperclass();
    ResolvedMember overriddenMethod = checkForOverride(superclass, mname, mparams, mrettype, mmods, mpkg, methodParamsArray);
    if (overriddenMethod != null) {
      return overriddenMethod;
    }

    ResolvedType[] interfaces = typeToCheck.getDeclaredInterfaces();
View Full Code Here

      if (world.forDEBUG_bridgingCode) {
        System.err.println("Bridging: Checking supertype " + theSuperclass);
      }
      String pkgName = clazz.getPackageName();
      UnresolvedType[] bm = BcelWorld.fromBcel(bridgeToCandidate.getArgumentTypes());
      ResolvedMember overriddenMethod = checkForOverride(theSuperclass, name, psig, rsig, bridgeToCandidate.getAccessFlags(),
          pkgName, bm);
      if (overriddenMethod != null) {
        String key = new StringBuffer().append(overriddenMethod.getName()).append(overriddenMethod.getSignatureErased())
            .toString(); // pr237419
        boolean alreadyHaveABridgeMethod = methodsSet.contains(key);
        if (!alreadyHaveABridgeMethod) {
          if (world.forDEBUG_bridgingCode) {
            System.err.println("Bridging:bridging to '" + overriddenMethod + "'");
          }
          createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
          methodsSet.add(key);
          didSomething = true;
          continue; // look at the next method
        }
      }

      // Check superinterfaces
      String[] interfaces = clazz.getInterfaceNames();
      for (int j = 0; j < interfaces.length; j++) {
        if (world.forDEBUG_bridgingCode) {
          System.err.println("Bridging:checking superinterface " + interfaces[j]);
        }
        ResolvedType interfaceType = world.resolve(interfaces[j]);
        overriddenMethod = checkForOverride(interfaceType, name, psig, rsig, bridgeToCandidate.getAccessFlags(),
            clazz.getPackageName(), bm);
        if (overriddenMethod != null) {
          String key = new StringBuffer().append(overriddenMethod.getName())
              .append(overriddenMethod.getSignatureErased()).toString(); // pr
          // 237419
          boolean alreadyHaveABridgeMethod = methodsSet.contains(key);
          if (!alreadyHaveABridgeMethod) {
            createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
            methodsSet.add(key);
View Full Code Here

    return subset;
  }

  public LazyMethodGen locateAnnotationHolderForFieldMunger(LazyClassGen clazz, ConcreteTypeMunger fieldMunger) {
    NewFieldTypeMunger newFieldMunger = (NewFieldTypeMunger) fieldMunger.getMunger();
    ResolvedMember lookingFor = AjcMemberMaker.interFieldInitializer(newFieldMunger.getSignature(), clazz.getType());
    for (LazyMethodGen method : clazz.getMethodGens()) {
      if (method.getName().equals(lookingFor.getName())) {
        return method;
      }
    }
    return null;
  }
View Full Code Here

  }

  // FIXME asc refactor this to neaten it up
  public LazyMethodGen locateAnnotationHolderForMethodCtorMunger(LazyClassGen clazz, ConcreteTypeMunger methodCtorMunger) {
    ResolvedTypeMunger rtMunger = methodCtorMunger.getMunger();
    ResolvedMember lookingFor = null;
    if (rtMunger instanceof NewMethodTypeMunger) {
      NewMethodTypeMunger nftm = (NewMethodTypeMunger) rtMunger;
      lookingFor = AjcMemberMaker.interMethodDispatcher(nftm.getSignature(), methodCtorMunger.getAspectType());
    } else if (rtMunger instanceof NewConstructorTypeMunger) {
      NewConstructorTypeMunger nftm = (NewConstructorTypeMunger) rtMunger;
      lookingFor = AjcMemberMaker.postIntroducedConstructor(methodCtorMunger.getAspectType(), nftm.getSignature()
          .getDeclaringType(), nftm.getSignature().getParameterTypes());
    } else {
      throw new BCException("Not sure what this is: " + methodCtorMunger);
    }
    String name = lookingFor.getName();
    String paramSignature = lookingFor.getParameterSignature();
    for (LazyMethodGen member : clazz.getMethodGens()) {
      if (member.getName().equals(name) && member.getParameterSignature().equals(paramSignature)) {
        return member;
      }
    }
View Full Code Here

  private boolean weaveAtFieldRepeatedly(List<DeclareAnnotation> decaFs, List<ConcreteTypeMunger> itdFields,
      List<Integer> reportedErrors) {
    boolean isChanged = false;
    for (Iterator<ConcreteTypeMunger> iter = itdFields.iterator(); iter.hasNext();) {
      BcelTypeMunger fieldMunger = (BcelTypeMunger) iter.next();
      ResolvedMember itdIsActually = fieldMunger.getSignature();
      Set<DeclareAnnotation> worthRetrying = new LinkedHashSet<DeclareAnnotation>();
      boolean modificationOccured = false;

      for (Iterator<DeclareAnnotation> iter2 = decaFs.iterator(); iter2.hasNext();) {
        DeclareAnnotation decaF = iter2.next();
        if (decaF.matches(itdIsActually, world)) {
          if (decaF.isRemover()) {
            LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
            if (annotationHolder.hasAnnotation(decaF.getAnnotationType())) {
              isChanged = true;
              // something to remove
              annotationHolder.removeAnnotation(decaF.getAnnotationType());
              AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
                  decaF.getSourceLocation(), itdIsActually.getSourceLocation(), true);
            } else {
              worthRetrying.add(decaF);
            }
          } else {

            LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
            if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors)) {
              continue; // skip this one...
            }
            annotationHolder.addAnnotation(decaF.getAnnotation());
            AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
                decaF.getSourceLocation(), itdIsActually.getSourceLocation(), false);
            isChanged = true;
            modificationOccured = true;
          }
        } else {
          if (!decaF.isStarredAnnotationPattern()) {
            worthRetrying.add(decaF); // an annotation is specified
            // that might be put on by a
            // subsequent decaf
          }
        }
      }

      while (!worthRetrying.isEmpty() && modificationOccured) {
        modificationOccured = false;
        List<DeclareAnnotation> forRemoval = new ArrayList<DeclareAnnotation>();
        for (Iterator<DeclareAnnotation> iter2 = worthRetrying.iterator(); iter2.hasNext();) {
          DeclareAnnotation decaF = iter2.next();
          if (decaF.matches(itdIsActually, world)) {
            if (decaF.isRemover()) {
              LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
              if (annotationHolder.hasAnnotation(decaF.getAnnotationType())) {
                isChanged = true;
                // something to remove
                annotationHolder.removeAnnotation(decaF.getAnnotationType());
                AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
                    decaF.getSourceLocation(), itdIsActually.getSourceLocation(), true);
                forRemoval.add(decaF);
              }
            } else {
              LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
              if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors)) {
                continue; // skip this one...
              }
              annotationHolder.addAnnotation(decaF.getAnnotation());
              AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
                  decaF.getSourceLocation(), itdIsActually.getSourceLocation(), false);
              isChanged = true;
              modificationOccured = true;
              forRemoval.add(decaF);
            }
          }
View Full Code Here

    boolean isChanged = false;
    AsmManager asmManager = world.getModelAsAsmManager();
    for (ConcreteTypeMunger methodctorMunger : itdsForMethodAndConstructor) {
      // for (Iterator iter = itdsForMethodAndConstructor.iterator(); iter.hasNext();) {
      // BcelTypeMunger methodctorMunger = (BcelTypeMunger) iter.next();
      ResolvedMember unMangledInterMethod = methodctorMunger.getSignature();
      List<DeclareAnnotation> worthRetrying = new ArrayList<DeclareAnnotation>();
      boolean modificationOccured = false;

      for (Iterator<DeclareAnnotation> iter2 = decaMCs.iterator(); iter2.hasNext();) {
        DeclareAnnotation decaMC = iter2.next();
        if (decaMC.matches(unMangledInterMethod, world)) {
          LazyMethodGen annotationHolder = locateAnnotationHolderForMethodCtorMunger(clazz, methodctorMunger);
          if (annotationHolder == null
              || doesAlreadyHaveAnnotation(annotationHolder, unMangledInterMethod, decaMC, reportedErrors)) {
            continue; // skip this one...
          }
          annotationHolder.addAnnotation(decaMC.getAnnotation());
          isChanged = true;
          AsmRelationshipProvider.addDeclareAnnotationRelationship(asmManager, decaMC.getSourceLocation(),
              unMangledInterMethod.getSourceLocation(), false);
          reportMethodCtorWeavingMessage(clazz, unMangledInterMethod, decaMC, -1);
          modificationOccured = true;
        } else {
          // If an annotation is specified, it might be added by one of the other declare annotation statements
          if (!decaMC.isStarredAnnotationPattern()) {
            worthRetrying.add(decaMC);
          }
        }
      }

      while (!worthRetrying.isEmpty() && modificationOccured) {
        modificationOccured = false;
        List<DeclareAnnotation> forRemoval = new ArrayList<DeclareAnnotation>();
        for (Iterator<DeclareAnnotation> iter2 = worthRetrying.iterator(); iter2.hasNext();) {
          DeclareAnnotation decaMC = iter2.next();
          if (decaMC.matches(unMangledInterMethod, world)) {
            LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, methodctorMunger);
            if (doesAlreadyHaveAnnotation(annotationHolder, unMangledInterMethod, decaMC, reportedErrors)) {
              continue; // skip this one...
            }
            annotationHolder.addAnnotation(decaMC.getAnnotation());
            unMangledInterMethod.addAnnotation(decaMC.getAnnotation());
            AsmRelationshipProvider.addDeclareAnnotationRelationship(asmManager, decaMC.getSourceLocation(),
                unMangledInterMethod.getSourceLocation(), false);
            isChanged = true;
            modificationOccured = true;
            forRemoval.add(decaMC);
          }
          worthRetrying.removeAll(forRemoval);
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.