Package org.aspectj.weaver

Examples of org.aspectj.weaver.World


    }

    public void visit(HasAnnotation hasAnnotation) {
      ReflectionVar v = (ReflectionVar) hasAnnotation.getVar();
      Object value = v.getBindingAtJoinPoint(thisObject,targetObject, args);
      World world = v.getType().getWorld();
      ResolvedType actualVarType = world.resolve(value.getClass().getName());
      ResolvedType requiredAnnotationType = hasAnnotation.getAnnotationType().resolve(world);
      matches = actualVarType.hasAnnotation(requiredAnnotationType);
    }
View Full Code Here


        Options.WeaverOption weaverOption = Options.parse(allOptions.toString(), loader, getMessageHandler());

        // configure the weaver and world
        // AV - code duplicates AspectJBuilder.initWorldAndWeaver()
        World world = weaver.getWorld();
        setMessageHandler(weaverOption.messageHandler);
        world.setXlazyTjp(weaverOption.lazyTjp);
        world.setXHasMemberSupportEnabled(weaverOption.hasMember);
        world.setPinpointMode(weaverOption.pinpoint);
        weaver.setReweavableMode(weaverOption.notReWeavable);
        world.setXnoInline(weaverOption.noInline);
        // AMC - autodetect as per line below, needed for AtAjLTWTests.testLTWUnweavable
        world.setBehaveInJava5Way(LangUtil.is15VMOrGreater());

        /* First load defaults */
    bcelWorld.getLint().loadDefaultProperties();
   
    /* Second overlay LTW defaults */
    bcelWorld.getLint().adviceDidNotMatch.setKind(null);
       
        /* Third load user file using -Xlintfile so that -Xlint wins */
        if (weaverOption.lintFile != null) {
            InputStream resource = null;
            try {
                resource = loader.getResourceAsStream(weaverOption.lintFile);
                Exception failure = null;
                if (resource != null) {
                    try {
                        Properties properties = new Properties();
                        properties.load(resource);
                        world.getLint().setFromProperties(properties);
                    } catch (IOException e) {
                        failure = e;
                    }
                }
                if (failure != null || resource == null) {
View Full Code Here

    if (!shadow.getIWorld().getLint().unmatchedSuperTypeInCall.isEnabled()) return;
   
        // no warnings for declare error/warning
        if (munger instanceof Checker) return;
       
        World world = shadow.getIWorld();
       
    // warning never needed if the declaring type is any
    UnresolvedType exactDeclaringType = signature.getDeclaringType().getExactType();
       
    ResolvedType shadowDeclaringType =
      shadow.getSignature().getDeclaringType().resolve(world);
       
    if (signature.getDeclaringType().isStar()
      || ResolvedType.isMissing(exactDeclaringType)
      || exactDeclaringType.resolve(world).isMissing())
      return;

        // warning not needed if match type couldn't ever be the declaring type
    if (!shadowDeclaringType.isAssignableFrom(exactDeclaringType.resolve(world))) {
            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))) {
      // Covariance issue...
      // The reason we didn't match is that the type pattern for the pointcut (Car) doesn't match the
      // return type for the specific declaration at the shadow. (FastCar Sub.getCar())
      // XXX Put out another XLINT in this case?
      return;
    }
    // PR60015 - Don't report the warning if the declaring type is object and 'this' is an interface
    if (exactDeclaringType.resolve(world).isInterface() && shadowDeclaringType.equals(world.resolve("java.lang.Object"))) {
      return;
    }

    SignaturePattern nonConfusingPattern =
      new SignaturePattern(
View Full Code Here

    signature = signature.resolveBindings(scope, bindings);
   
   
    if (kind == Shadow.ConstructorExecution) {     // Bug fix 60936
      if (signature.getDeclaringType() != null) {
      World world = scope.getWorld();
      UnresolvedType exactType = signature.getDeclaringType().getExactType();
      if (signature.getKind() == Member.CONSTRUCTOR &&
        !ResolvedType.isMissing(exactType) &&
        exactType.resolve(world).isInterface() &&
        !signature.getDeclaringType().isIncludeSubtypes()) {
          world.getLint().noInterfaceCtorJoinpoint.signal(exactType.toString(), getSourceLocation());
        }
      }
    }
   
    // no parameterized types
View Full Code Here

   
    ret.inAspect = inAspect;
    if (inAspect.isAbstract()) return ret;
   
   
    World world = inAspect.getWorld();
   
    Pointcut concreteEntry = entry.concretize(inAspect, inAspect, 0, null);
    //concreteEntry = new AndPointcut(this, concreteEntry);
    //concreteEntry.state = Pointcut.CONCRETE;
    inAspect.crosscuttingMembers.addConcreteShadowMunger(
        Advice.makePerObjectEntry(world, concreteEntry, isThis, inAspect));

        // FIXME AV - don't use lateMunger here due to test "inheritance, around advice and abstract pointcuts"
        // see #75442 thread. Issue with weaving order.
    ResolvedTypeMunger munger =
      new PerObjectInterfaceTypeMunger(inAspect, concreteEntry);
    inAspect.crosscuttingMembers.addLateTypeMunger(world.concreteTypeMunger(munger, inAspect));

        //ATAJ: add a munger to add the aspectOf(..) to the @AJ aspects
        if (inAspect.isAnnotationStyleAspect() && !inAspect.isAbstract()) {
            inAspect.crosscuttingMembers.addLateTypeMunger(
                    inAspect.getWorld().makePerClauseAspect(inAspect, getKind())
View Full Code Here

    Pointcut pointcut) {
    return !bcelObjectType.isInterface();
  }
 
  private boolean mungeNewMethod(BcelClassWeaver weaver, NewMethodTypeMunger munger) {
    World w = weaver.getWorld();
    // Resolving it will sort out the tvars
    ResolvedMember unMangledInterMethod = munger.getSignature().resolve(w);
    // do matching on the unMangled one, but actually add them to the mangled method
    ResolvedMember interMethodBody = munger.getDeclaredInterMethodBody(aspectType,w);
    ResolvedMember interMethodDispatcher = munger.getDeclaredInterMethodDispatcher(aspectType,w);
View Full Code Here

        return true;
    }


    private ResolvedMember getRealMemberForITDFromAspect(ResolvedType aspectType,ResolvedMember lookingFor,boolean isCtorRelated) {
    World world = aspectType.getWorld();
    boolean debug = false;
    if (debug) {
      System.err.println("Searching for a member on type: "+aspectType);
      System.err.println("Member we are looking for: "+lookingFor);
    }
View Full Code Here

      } else {
        exposedState = new ExposedState(0);
        return//XXX this case is just here for supporting lazy test code
      }
     
      World world = shadow.getIWorld();
      suppressLintWarnings(world);
    pointcutTest = getPointcut().findResidue(shadow, exposedState);
    clearLintSuppressions(world,this.suppressedLintKinds);
   
    // these initializations won't be performed by findResidue, but need to be
    // so that the joinpoint is primed for weaving
    if (getKind() == AdviceKind.PerThisEntry) {
      shadow.getThisVar();
    } else if (getKind() == AdviceKind.PerTargetEntry) {
      shadow.getTargetVar();
    }
   
   
        // make sure thisJoinPoint parameters are initialized
        if ((getExtraParameterFlags() & ThisJoinPointStaticPart) != 0) {
          ((BcelShadow)shadow).getThisJoinPointStaticPartVar();
      ((BcelShadow)shadow).getEnclosingClass().warnOnAddedStaticInitializer(shadow,getSourceLocation());
        }

        if ((getExtraParameterFlags() & ThisJoinPoint) != 0) {
        boolean hasGuardTest = pointcutTest != Literal.TRUE && getKind() != AdviceKind.Around;
        boolean isAround = getKind() == AdviceKind.Around;
      ((BcelShadow)shadow).requireThisJoinPoint(hasGuardTest,isAround);
      ((BcelShadow)shadow).getEnclosingClass().warnOnAddedStaticInitializer(shadow,getSourceLocation());
      if (!hasGuardTest && world.getLint().multipleAdviceStoppingLazyTjp.isEnabled()) {
        // collect up the problematic advice
        ((BcelShadow)shadow).addAdvicePreventingLazyTjp(this);
      }
      if (!isAround && !hasGuardTest && world.getLint().noGuardForLazyTjp.isEnabled()) {
        // can't build tjp lazily, no suitable test...
        world.getLint().noGuardForLazyTjp.signal(
              new String[] {shadow.toString()},
              getSourceLocation(),
              new ISourceLocation[] { ((BcelShadow)shadow).getSourceLocation() }
          );       
      }
View Full Code Here

 
  private Collection collectCheckedExceptions(UnresolvedType[] excs) {
    if (excs == null || excs.length == 0) return Collections.EMPTY_LIST;
   
    Collection ret = new ArrayList();
    World world = concreteAspect.getWorld();
    ResolvedType runtimeException = world.getCoreType(UnresolvedType.RUNTIME_EXCEPTION);
    ResolvedType error = world.getCoreType(UnresolvedType.ERROR);
   
    for (int i=0, len=excs.length; i < len; i++) {
      ResolvedType t = world.resolve(excs[i],true);
            if (t.isMissing()) {
                world.getLint().cantFindType.signal(
                    WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_EXCEPTION_TYPE,excs[i].getName()),
                    getSourceLocation()
                    );
//                IMessage msg = new Message(
//                  WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_EXCEPTION_TYPE,excs[i].getName()),
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.EMPTY_LIST;
        } else {
          thrownExceptions = collectCheckedExceptions(m.getExceptions());
        }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.World

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.