Package org.aspectj.bridge.context

Examples of org.aspectj.bridge.context.ContextToken


  public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
    if (methodDeclaration.hasErrors()) {
      return false;
    }
    ContextToken tok = CompilationAndWeavingContext.enteringPhase(
        CompilationAndWeavingContext.VALIDATING_AT_ASPECTJ_ANNOTATIONS, methodDeclaration.selector);
    ajAnnotations = new AspectJAnnotations(methodDeclaration.annotations);
    if (!methodDeclaration.getClass().equals(AjMethodDeclaration.class)) {
      // simply test for innapropriate use of annotations on code-style
      // members
View Full Code Here


        }

        this.traverse(new MakeDeclsPublicVisitor(), (ClassScope) null);

        AccessForInlineVisitor v = new AccessForInlineVisitor((AspectDeclaration) upperScope.referenceContext, handler);
        ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.ACCESS_FOR_INLINE,
            selector);
        this.traverse(v, (ClassScope) null);
        CompilationAndWeavingContext.leavingPhase(tok);

        // ??? if we found a construct that we can't inline, set
View Full Code Here

  private static boolean captureLowLevelContext = false;

  private boolean match(BcelShadow shadow, List<BcelShadow> shadowAccumulator) {
    // Duplicate blocks - one with context one without, seems faster than multiple 'ifs'
    if (captureLowLevelContext) {
      ContextToken shadowMatchToken = CompilationAndWeavingContext.enteringPhase(
          CompilationAndWeavingContext.MATCHING_SHADOW, shadow);
      boolean isMatched = false;

      Shadow.Kind shadowKind = shadow.getKind();
      List<ShadowMunger> candidateMungers = indexedShadowMungers[shadowKind.getKey()];

      // System.out.println("Candidates " + candidateMungers);
      if (candidateMungers != null) {
        for (ShadowMunger munger : candidateMungers) {

          ContextToken mungerMatchToken = CompilationAndWeavingContext.enteringPhase(
              CompilationAndWeavingContext.MATCHING_POINTCUT, munger.getPointcut());
          if (munger.match(shadow, world)) {
            shadow.addMunger(munger);
            isMatched = true;
            if (shadow.getKind() == Shadow.StaticInitialization) {
View Full Code Here

    // the list than outer shadows. That's fine. This order is preserved if:

    // A preceeds B iff B.getStart() is LATER THAN A.getStart().

    for (BcelShadow shadow : shadows) {
      ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.IMPLEMENTING_ON_SHADOW,
          shadow);
      shadow.implement();
      CompilationAndWeavingContext.leavingPhase(tok);
    }
    // int ii =
View Full Code Here

  public boolean shouldOverwrite() {
    return false;
  }

  public boolean munge(BcelClassWeaver weaver) {
    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.MUNGING_WITH, this);
    boolean changed = false;
    boolean worthReporting = true;

    if (weaver.getWorld().isOverWeaving()) {
      WeaverStateInfo typeWeaverState = weaver.getLazyClassGen().getType().getWeaverState();
View Full Code Here

  // variation of "weave" that sources class files from an external source.
  public Collection<String> weave(IClassFileProvider input) throws IOException {
    if (trace.isTraceEnabled()) {
      trace.enter("weave", this, input);
    }
    ContextToken weaveToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING, "");
    Collection<String> wovenClassNames = new ArrayList<String>();
    IWeaveRequestor requestor = input.getRequestor();

    if (world.getModel() != null && world.isMinimalModel()) {
      candidatesForRemoval = new HashSet<IProgramElement>();
    }
    if (world.getModel() != null && !isBatchWeave) {
      AsmManager manager = world.getModelAsAsmManager();
      for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
        UnwovenClassFile classFile = i.next();
        // remove all relationships where this file being woven is
        // the target of the relationship
        manager.removeRelationshipsTargettingThisType(classFile.getClassName());
      }
    }

    // Go through the types and ensure any 'damaged' during compile time are
    // repaired prior to weaving
    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      ResolvedType theType = world.resolve(className);
      if (theType != null) {
        theType.ensureConsistent();
      }
    }

    // special case for AtAspectJMungerOnly - see #113587
    if (input.isApplyAtAspectJMungersOnly()) {
      ContextToken atAspectJMungersOnly = CompilationAndWeavingContext.enteringPhase(
          CompilationAndWeavingContext.PROCESSING_ATASPECTJTYPE_MUNGERS_ONLY, "");
      requestor.weavingAspects();
      // ContextToken aspectToken =
      CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_ASPECTS, "");
      for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
        UnwovenClassFile classFile = i.next();
        String className = classFile.getClassName();
        ResolvedType theType = world.resolve(className);
        if (theType.isAnnotationStyleAspect()) {
          BcelObjectType classType = BcelWorld.getBcelObjectType(theType);
          if (classType == null) {
            throw new BCException("Can't find bcel delegate for " + className + " type=" + theType.getClass());
          }
          LazyClassGen clazz = classType.getLazyClassGen();
          BcelPerClauseAspectAdder selfMunger = new BcelPerClauseAspectAdder(theType, theType.getPerClause().getKind());
          selfMunger.forceMunge(clazz, true);
          classType.finishedWith();
          UnwovenClassFile[] newClasses = getClassFilesFor(clazz);
          for (int news = 0; news < newClasses.length; news++) {
            requestor.acceptResult(newClasses[news]);
          }
          wovenClassNames.add(classFile.getClassName());
        }
      }
      requestor.weaveCompleted();
      CompilationAndWeavingContext.leavingPhase(atAspectJMungersOnly);
      return wovenClassNames;
    }

    requestor.processingReweavableState();
    ContextToken reweaveToken = CompilationAndWeavingContext.enteringPhase(
        CompilationAndWeavingContext.PROCESSING_REWEAVABLE_STATE, "");
    prepareToProcessReweavableState();
    // clear all state from files we'll be reweaving
    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      BcelObjectType classType = getClassType(className);

      // null return from getClassType() means the delegate is an eclipse
      // source type - so
      // there *cant* be any reweavable state... (he bravely claimed...)
      if (classType != null) {
        ContextToken tok = CompilationAndWeavingContext.enteringPhase(
            CompilationAndWeavingContext.PROCESSING_REWEAVABLE_STATE, className);
        processReweavableStateIfPresent(className, classType);
        CompilationAndWeavingContext.leavingPhase(tok);
      }
    }

    CompilationAndWeavingContext.leavingPhase(reweaveToken);

    ContextToken typeMungingToken = CompilationAndWeavingContext.enteringPhase(
        CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS, "");
    requestor.addingTypeMungers();

    // We process type mungers in two groups, first mungers that change the
    // type
    // hierarchy, then 'normal' ITD type mungers.

    // Process the types in a predictable order (rather than the order
    // encountered).
    // For class A, the order is superclasses of A then superinterfaces of A
    // (and this mechanism is applied recursively)
    List<String> typesToProcess = new ArrayList<String>();
    for (Iterator<UnwovenClassFile> iter = input.getClassFileIterator(); iter.hasNext();) {
      UnwovenClassFile clf = iter.next();
      typesToProcess.add(clf.getClassName());
    }
    while (typesToProcess.size() > 0) {
      weaveParentsFor(typesToProcess, typesToProcess.get(0), null);
    }

    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      addNormalTypeMungers(className);
    }

    CompilationAndWeavingContext.leavingPhase(typeMungingToken);

    requestor.weavingAspects();
    ContextToken aspectToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_ASPECTS, "");
    // first weave into aspects
    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      ResolvedType theType = world.resolve(className);
      if (theType.isAspect()) {
        BcelObjectType classType = BcelWorld.getBcelObjectType(theType);
        if (classType == null) {

          // Sometimes.. if the Bcel Delegate couldn't be found then a
          // problem occurred at compile time - on
          // a previous compiler run. In this case I assert the
          // delegate will still be an EclipseSourceType
          // and we can ignore the problem here (the original compile
          // error will be reported again from
          // the eclipse source type) - pr113531
          ReferenceTypeDelegate theDelegate = ((ReferenceType) theType).getDelegate();
          if (theDelegate.getClass().getName().endsWith("EclipseSourceType")) {
            continue;
          }

          throw new BCException("Can't find bcel delegate for " + className + " type=" + theType.getClass());
        }
        weaveAndNotify(classFile, classType, requestor);
        wovenClassNames.add(className);
      }
    }

    CompilationAndWeavingContext.leavingPhase(aspectToken);

    requestor.weavingClasses();
    ContextToken classToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_CLASSES, "");
    // then weave into non-aspects
    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      ResolvedType theType = world.resolve(className);
View Full Code Here

        if (resolvedSuperInterface.isExposedToWeaver()) { // typesForWeaving.contains(interfaceTypename)) {
          weaveParentsFor(typesForWeaving, interfaceTypename, resolvedSuperInterface);
        }
      }
    }
    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_DECLARE_PARENTS,
        resolvedTypeToWeave.getName());
    weaveParentTypeMungers(resolvedTypeToWeave);
    CompilationAndWeavingContext.leavingPhase(tok);
    typesForWeaving.remove(typeToWeave);
    resolvedTypeToWeave.tagAsTypeHierarchyComplete();
View Full Code Here

  }

  private void weaveAndNotify(UnwovenClassFile classFile, BcelObjectType classType, IWeaveRequestor requestor) throws IOException {
    trace.enter("weaveAndNotify", this, new Object[] { classFile, classType, requestor });

    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_TYPE, classType
        .getResolvedTypeX().getName());
    LazyClassGen clazz = weaveWithoutDump(classFile, classType);
    classType.finishedWith();
    // clazz is null if the classfile was unchanged by weaving...
    if (clazz != null) {
View Full Code Here

    }
    return didSomething;
  }

  public void weaveNormalTypeMungers(ResolvedType onType) {
    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS,
        onType.getName());
    if (onType.isRawType() || onType.isParameterizedType()) {
      onType = onType.getGenericType();
    }
    for (ConcreteTypeMunger m : typeMungerList) {
View Full Code Here

  // variation of "weave" that sources class files from an external source.
  public Collection<String> weave(IClassFileProvider input) throws IOException {
    if (trace.isTraceEnabled()) {
      trace.enter("weave", this, input);
    }
    ContextToken weaveToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING, "");
    Collection<String> wovenClassNames = new ArrayList<String>();
    IWeaveRequestor requestor = input.getRequestor();

    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      if (world.getModel() != null /* AsmManager.isCreatingModel() */&& !isBatchWeave) {
        // remove all relationships where this file being woven is the target of the relationship
        world.getModelAsAsmManager().removeRelationshipsTargettingThisType(classFile.getClassName());
      }
    }

    // Go through the types and ensure any 'damaged' during compile time are
    // repaired prior to weaving
    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      ResolvedType theType = world.resolve(className);
      if (theType != null) {
        theType.ensureConsistent();
      }
    }

    // special case for AtAspectJMungerOnly - see #113587
    if (input.isApplyAtAspectJMungersOnly()) {
      ContextToken atAspectJMungersOnly = CompilationAndWeavingContext.enteringPhase(
          CompilationAndWeavingContext.PROCESSING_ATASPECTJTYPE_MUNGERS_ONLY, "");
      requestor.weavingAspects();
      // ContextToken aspectToken =
      CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_ASPECTS, "");
      for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
        UnwovenClassFile classFile = i.next();
        String className = classFile.getClassName();
        ResolvedType theType = world.resolve(className);
        if (theType.isAnnotationStyleAspect()) {
          BcelObjectType classType = BcelWorld.getBcelObjectType(theType);
          if (classType == null) {
            throw new BCException("Can't find bcel delegate for " + className + " type=" + theType.getClass());
          }
          LazyClassGen clazz = classType.getLazyClassGen();
          BcelPerClauseAspectAdder selfMunger = new BcelPerClauseAspectAdder(theType, theType.getPerClause().getKind());
          selfMunger.forceMunge(clazz, true);
          classType.finishedWith();
          UnwovenClassFile[] newClasses = getClassFilesFor(clazz);
          for (int news = 0; news < newClasses.length; news++) {
            requestor.acceptResult(newClasses[news]);
          }
          wovenClassNames.add(classFile.getClassName());
        }
      }
      requestor.weaveCompleted();
      CompilationAndWeavingContext.leavingPhase(atAspectJMungersOnly);
      return wovenClassNames;
    }

    requestor.processingReweavableState();
    ContextToken reweaveToken = CompilationAndWeavingContext.enteringPhase(
        CompilationAndWeavingContext.PROCESSING_REWEAVABLE_STATE, "");
    prepareToProcessReweavableState();
    // clear all state from files we'll be reweaving
    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      BcelObjectType classType = getClassType(className);

      // null return from getClassType() means the delegate is an eclipse
      // source type - so
      // there *cant* be any reweavable state... (he bravely claimed...)
      if (classType != null) {
        ContextToken tok = CompilationAndWeavingContext.enteringPhase(
            CompilationAndWeavingContext.PROCESSING_REWEAVABLE_STATE, className);
        processReweavableStateIfPresent(className, classType);
        CompilationAndWeavingContext.leavingPhase(tok);
      }
    }

    CompilationAndWeavingContext.leavingPhase(reweaveToken);

    ContextToken typeMungingToken = CompilationAndWeavingContext.enteringPhase(
        CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS, "");
    requestor.addingTypeMungers();

    // We process type mungers in two groups, first mungers that change the
    // type
    // hierarchy, then 'normal' ITD type mungers.

    // Process the types in a predictable order (rather than the order
    // encountered).
    // For class A, the order is superclasses of A then superinterfaces of A
    // (and this mechanism is applied recursively)
    List<String> typesToProcess = new ArrayList<String>();
    for (Iterator<UnwovenClassFile> iter = input.getClassFileIterator(); iter.hasNext();) {
      UnwovenClassFile clf = iter.next();
      typesToProcess.add(clf.getClassName());
    }
    while (typesToProcess.size() > 0) {
      weaveParentsFor(typesToProcess, typesToProcess.get(0), null);
    }

    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      addNormalTypeMungers(className);
    }

    CompilationAndWeavingContext.leavingPhase(typeMungingToken);

    requestor.weavingAspects();
    ContextToken aspectToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_ASPECTS, "");
    // first weave into aspects
    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      ResolvedType theType = world.resolve(className);
      if (theType.isAspect()) {
        BcelObjectType classType = BcelWorld.getBcelObjectType(theType);
        if (classType == null) {

          // Sometimes.. if the Bcel Delegate couldn't be found then a
          // problem occurred at compile time - on
          // a previous compiler run. In this case I assert the
          // delegate will still be an EclipseSourceType
          // and we can ignore the problem here (the original compile
          // error will be reported again from
          // the eclipse source type) - pr113531
          ReferenceTypeDelegate theDelegate = ((ReferenceType) theType).getDelegate();
          if (theDelegate.getClass().getName().endsWith("EclipseSourceType")) {
            continue;
          }

          throw new BCException("Can't find bcel delegate for " + className + " type=" + theType.getClass());
        }
        weaveAndNotify(classFile, classType, requestor);
        wovenClassNames.add(className);
      }
    }

    CompilationAndWeavingContext.leavingPhase(aspectToken);

    requestor.weavingClasses();
    ContextToken classToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_CLASSES, "");
    // then weave into non-aspects
    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      ResolvedType theType = world.resolve(className);
View Full Code Here

TOP

Related Classes of org.aspectj.bridge.context.ContextToken

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.