Package org.aspectj.weaver

Examples of org.aspectj.weaver.ShadowMunger


  }

  private boolean checkLazyTjp() {
    // check for around advice
    for (Iterator i = mungers.iterator(); i.hasNext();) {
      ShadowMunger munger = (ShadowMunger) i.next();
      if (munger instanceof Advice) {
        if (((Advice) munger).getKind() == AdviceKind.Around) {
          if (munger.getSourceLocation() != null) { // do we know enough to bother reporting?
            if (world.getLint().canNotImplementLazyTjp.isEnabled()) {
              world.getLint().canNotImplementLazyTjp.signal(new String[] { toString() }, getSourceLocation(),
                  new ISourceLocation[] { munger.getSourceLocation() });
            }
          }
          return false;
        }
      }
View Full Code Here


        }
      }

      if (pointcutDec.isAbstract()) {
        // Thread.currentThread().dumpStack();
        ShadowMunger enclosingAdvice = bindings.getEnclosingAdvice();
        searchStart.getWorld().showMessage(IMessage.ERROR,
            WeaverMessages.format(WeaverMessages.ABSTRACT_POINTCUT, pointcutDec), getSourceLocation(),
            (null == enclosingAdvice) ? null : enclosingAdvice.getSourceLocation());
        return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
      }

      // System.err.println("start: " + searchStart);
      // ResolvedType[] parameterTypes = searchStart.getWorld().resolve(pointcutDec.getParameterTypes());
View Full Code Here

    // this code may need
    // a bit of alteration...

    Collections.sort(shadowMungerList, new Comparator() {
      public int compare(Object o1, Object o2) {
        ShadowMunger sm1 = (ShadowMunger) o1;
        ShadowMunger sm2 = (ShadowMunger) o2;
        if (sm1.getSourceLocation() == null) {
          return (sm2.getSourceLocation() == null ? 0 : 1);
        }
        if (sm2.getSourceLocation() == null) {
          return -1;
        }

        return (sm2.getSourceLocation().getOffset() - sm1.getSourceLocation().getOffset());
      }
    });

    if (inReweavableMode) {
      world.showMessage(IMessage.INFO, WeaverMessages.format(WeaverMessages.REWEAVABLE_MODE), null, null);
View Full Code Here

    // across the set of pointcuts....
    // Use a map from key based on pc equality, to value based on
    // pc identity.
    Map/* <Pointcut,Pointcut> */<Pointcut, Pointcut> pcMap = new HashMap<Pointcut, Pointcut>();
    for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
      ShadowMunger munger = (ShadowMunger) iter.next();
      Pointcut p = munger.getPointcut();
      Pointcut newP = shareEntriesFromMap(p, pcMap);
      newP.m_ignoreUnboundBindingForNames = p.m_ignoreUnboundBindingForNames;
      munger.setPointcut(newP);
    }
  }
View Full Code Here

    if (world.isInJava5Mode() && world.getLint().adviceDidNotMatch.isEnabled()) {
      List l = world.getCrosscuttingMembersSet().getShadowMungers();
      Set<AdviceLocation> alreadyWarnedLocations = new HashSet<AdviceLocation>();

      for (Iterator iter = l.iterator(); iter.hasNext();) {
        ShadowMunger element = (ShadowMunger) iter.next();
        // This will stop us incorrectly reporting deow checkers:
        if (element instanceof BcelAdvice) {
          BcelAdvice ba = (BcelAdvice) element;
          if (ba.getKind() == AdviceKind.CflowEntry || ba.getKind() == AdviceKind.CflowBelowEntry) {
            continue;
          }
          if (!ba.hasMatchedSomething()) {
            // Because we implement some features of AJ itself by
            // creating our own kind of mungers, you sometimes
            // find that ba.getSignature() is not a BcelMethod - for
            // example it might be a cflow entry munger.
            if (ba.getSignature() != null) {
              // check we haven't already warned on this advice and line
              // (cflow creates multiple mungers for the same advice)
              AdviceLocation loc = new AdviceLocation(ba);
              if (alreadyWarnedLocations.contains(loc)) {
                continue;
              } else {
                alreadyWarnedLocations.add(loc);
              }

              if (!(ba.getSignature() instanceof BcelMethod)
                  || !Utility.isSuppressing(ba.getSignature(), "adviceDidNotMatch")) {
                world.getLint().adviceDidNotMatch.signal(ba.getDeclaringAspect().toString(), new SourceLocation(
                    element.getSourceLocation().getSourceFile(), element.getSourceLocation().getLine()));
              }
            }
          }
        }
      }
View Full Code Here

      perKindShadowMungers = new List[Shadow.MAX_SHADOW_KIND + 1];
      for (int i = 0; i < perKindShadowMungers.length; i++) {
      perKindShadowMungers[i] = new ArrayList(0);
      }
      for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
      ShadowMunger munger = (ShadowMunger) iter.next();
      Set couldMatchKinds = munger.getPointcut().couldMatchKinds();
      for (Iterator kindIterator = couldMatchKinds.iterator();
           kindIterator.hasNext();) {
        Shadow.Kind aKind = (Shadow.Kind) kindIterator.next();
        perKindShadowMungers[aKind.getKey()].add(munger);
      }
View Full Code Here

    Set aspectsAffectingType = new HashSet();
    for (Iterator iter = mg.matchedShadows.iterator(); iter.hasNext();) {
      BcelShadow aShadow = (BcelShadow) iter.next()
      // Mungers in effect on that shadow
      for (Iterator iter2 = aShadow.getMungers().iterator();iter2.hasNext();) {
        ShadowMunger aMunger = (ShadowMunger) iter2.next();
        if (aMunger instanceof BcelAdvice) {
          BcelAdvice bAdvice = (BcelAdvice)aMunger;
          if(bAdvice.getConcreteAspect() != null){
            aspectsAffectingType.add(bAdvice.getConcreteAspect().getName());
          }
View Full Code Here

    private boolean match(BcelShadow shadow, List shadowAccumulator) {
      //System.err.println("match: " + shadow);
      ContextToken shadowMatchToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.MATCHING_SHADOW, shadow);
        boolean isMatched = false;
        for (Iterator i = shadowMungers.iterator(); i.hasNext(); ) {
            ShadowMunger munger = (ShadowMunger)i.next();
            ContextToken mungerMatchToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.MATCHING_POINTCUT, munger.getPointcut());
            if (munger.match(shadow, world)) {
             
        WeaverMetrics.recordMatchResult(true);// Could pass: munger
                shadow.addMunger(munger);
                isMatched = true;
          if (shadow.getKind() == Shadow.StaticInitialization) {
          clazz.warnOnAddedStaticInitializer(shadow,munger.getSourceLocation());
          }
       
            } else {
              WeaverMetrics.recordMatchResult(false); // Could pass: munger
          }
View Full Code Here

       
    Collections.sort(
      shadowMungerList,
      new Comparator() {
        public int compare(Object o1, Object o2) {
          ShadowMunger sm1 = (ShadowMunger)o1;
          ShadowMunger sm2 = (ShadowMunger)o2;
          if (sm1.getSourceLocation()==null) return (sm2.getSourceLocation()==null?0:1);
          if (sm2.getSourceLocation()==null) return -1;
         
          return (sm2.getSourceLocation().getOffset()-sm1.getSourceLocation().getOffset());
        }
      });
    }
View Full Code Here

     * be a side-effect of DNF rewriting).
     */
    private void rewritePointcuts(List/*ShadowMunger*/ shadowMungers) {
      PointcutRewriter rewriter = new PointcutRewriter();
      for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
      ShadowMunger munger = (ShadowMunger) iter.next();
      Pointcut p = munger.getPointcut();
      Pointcut newP = rewriter.rewrite(p);
      // validateBindings now whilst we still have around the pointcut
      // that resembles what the user actually wrote in their program
        // text.
      if (munger instanceof Advice) {
        Advice advice = (Advice) munger;
        if (advice.getSignature() != null) {
          final int numFormals;
                    final String names[];
                    //ATAJ for @AJ aspect, the formal have to be checked according to the argument number
                    // since xxxJoinPoint presence or not have side effects
                    if (advice.getConcreteAspect().isAnnotationStyleAspect()) {
                        numFormals = advice.getBaseParameterCount();
                        int numArgs = advice.getSignature().getParameterTypes().length;
                        if (numFormals > 0) {
                            names = advice.getSignature().getParameterNames(world);
                            validateBindings(newP,p,numArgs,names);
                        }
                    } else {
                        numFormals = advice.getBaseParameterCount();
                        if (numFormals > 0) {
                            names = advice.getBaseParameterNames(world);
                            validateBindings(newP,p,numFormals,names);
                        }
                    }
        }
      }
      munger.setPointcut(newP);
    }
      // now that we have optimized individual pointcuts, optimize
      // across the set of pointcuts....
      // Use a map from key based on pc equality, to value based on
      // pc identity.
      Map/*<Pointcut,Pointcut>*/ pcMap = new HashMap();
      for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
      ShadowMunger munger = (ShadowMunger) iter.next();
      Pointcut p = munger.getPointcut();
      munger.setPointcut(shareEntriesFromMap(p,pcMap));
    }     
    }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.ShadowMunger

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.