Package org.aspectj.weaver

Examples of org.aspectj.weaver.WeaverStateInfo$Entry


  }

  @Override
  protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    Entry e = entry(req);
    S3Object remove = map.remove(e);
    if (remove == null) {
      resp.sendError(404, "Not found " + e);
    } else {
      resp.sendError(HttpURLConnection.HTTP_NO_CONTENT, "Deleted");
View Full Code Here


    }

  }

  private Entry entry(HttpServletRequest req) {
    return new Entry(key(uri(req)));
  }
View Full Code Here

        log("doGet " + uri);
    if ("/".equals(uri.getPath())) {
      list(req, resp);
    } else {
      String key = uri.getPath().substring(1);
      Entry e = new Entry(key);
      S3Object obj = map.get(e);
        if (debug)
          log("map.get(" + key + ") = " + obj);
      if (obj == null) {
        resp.sendError(404, "Not here: " + e);
View Full Code Here

    if (maxKeysStr != null)
      maxKeys = Integer.parseInt(maxKeysStr);
    Writer w = new Writer();
    SortedMap<Entry, S3Object> submap = new TreeMap<Entry, S3Object>(map);
    if (prefix != null)
      submap = submap.tailMap(new Entry(prefix));
    int keyCount = 0;
    boolean truncated = false;
    String nextMarker = null;
    for (Entry e : submap.keySet()) {
      if (++keyCount > maxKeys) {
View Full Code Here

    log("doPut " + uri);
    if ("/".equals(uri.getPath())) {
      log("create bucket");
      bucket = true;
    } else {
      Entry e = new Entry(key(uri));
      e.setLastModified(new Date());
      e.setSize(req.getContentLength());
      e.setOwner(new Owner("id", "name"));
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      ServletInputStream is = req.getInputStream();
      byte b[] = new byte[128];
      while (true) {
        int len = is.read(b);
View Full Code Here

    // we want to "touch" all aspects
    if (clazz.getType().isAspect()) {
      isChanged = true;
    }

    WeaverStateInfo typeWeaverState = (world.isOverWeaving() ? getLazyClassGen().getType().getWeaverState() : null);
    // start by munging all typeMungers
    for (ConcreteTypeMunger o : typeMungers) {
      if (!(o instanceof BcelTypeMunger)) {
        // ???System.err.println("surprising: " + o);
        continue;
      }
      BcelTypeMunger munger = (BcelTypeMunger) o;

      if (typeWeaverState != null && typeWeaverState.isAspectAlreadyApplied(munger.getAspectType())) {
        continue;
      }
      boolean typeMungerAffectedType = munger.munge(this);
      if (typeMungerAffectedType) {
        isChanged = true;
        if (inReweavableMode || clazz.getType().isAspect()) {
          aspectsAffectingType.add(munger.getAspectType().getSignature());
        }
      }
    }

    // Weave special half type/half shadow mungers...
    isChanged = weaveDeclareAtMethodCtor(clazz) || isChanged;
    isChanged = weaveDeclareAtField(clazz) || isChanged;

    // XXX do major sort of stuff
    // sort according to: Major: type hierarchy
    // within each list: dominates
    // don't forget to sort addedThisInitialiers according to dominates
    addedSuperInitializersAsList = new ArrayList<IfaceInitList>(addedSuperInitializers.values());
    addedSuperInitializersAsList = PartialOrder.sort(addedSuperInitializersAsList);
    if (addedSuperInitializersAsList == null) {
      throw new BCException("circularity in inter-types");
    }

    // this will create a static initializer if there isn't one
    // this is in just as bad taste as NOPs
    LazyMethodGen staticInit = clazz.getStaticInitializer();
    staticInit.getBody().insert(genInitInstructions(addedClassInitializers, true));

    // now go through each method, and match against each method. This
    // sets up each method's {@link LazyMethodGen#matchedShadows} field,
    // and it also possibly adds to {@link #initializationShadows}.
    List<LazyMethodGen> methodGens = new ArrayList<LazyMethodGen>(clazz.getMethodGens());
    for (LazyMethodGen member : methodGens) {
      if (!member.hasBody()) {
        continue;
      }
      if (world.isJoinpointSynchronizationEnabled() && world.areSynchronizationPointcutsInUse()
          && member.getMethod().isSynchronized()) {
        transformSynchronizedMethod(member);
      }
      boolean shadowMungerMatched = match(member);
      if (shadowMungerMatched) {
        // For matching mungers, add their declaring aspects to the list
        // that affected this type
        if (inReweavableMode || clazz.getType().isAspect()) {
          aspectsAffectingType.addAll(findAspectsForMungers(member));
        }
        isChanged = true;
      }
    }

    // now we weave all but the initialization shadows
    for (LazyMethodGen methodGen : methodGens) {
      if (!methodGen.hasBody()) {
        continue;
      }
      implement(methodGen);
    }

    // if we matched any initialization shadows, we inline and weave
    if (!initializationShadows.isEmpty()) {
      // Repeat next step until nothing left to inline...cant go on
      // infinetly as compiler will have detected and reported
      // "Recursive constructor invocation"
      while (inlineSelfConstructors(methodGens)) {
      }
      positionAndImplement(initializationShadows);
    }

    // now proceed with late type mungers
    if (lateTypeMungers != null) {
      for (Iterator<ConcreteTypeMunger> i = lateTypeMungers.iterator(); i.hasNext();) {
        BcelTypeMunger munger = (BcelTypeMunger) i.next();
        if (munger.matches(clazz.getType())) {
          boolean typeMungerAffectedType = munger.munge(this);
          if (typeMungerAffectedType) {
            isChanged = true;
            if (inReweavableMode || clazz.getType().isAspect()) {
              aspectsAffectingType.add(munger.getAspectType().getSignature());
            }
          }
        }
      }
    }

    // FIXME AV - see #75442, for now this is not enough to fix the bug,
    // comment that out until we really fix it
    // // flush to save some memory
    // PerObjectInterfaceTypeMunger.unregisterFromAsAdvisedBy(clazz.getType()
    // );

    // finally, if we changed, we add in the introduced methods.
    if (isChanged) {
      clazz.getOrCreateWeaverStateInfo(inReweavableMode);
      weaveInAddedMethods(); // FIXME asc are these potentially affected
      // by declare annotation?
    }

    if (inReweavableMode) {
      WeaverStateInfo wsi = clazz.getOrCreateWeaverStateInfo(true);
      wsi.addAspectsAffectingType(aspectsAffectingType);
      wsi.setUnwovenClassFileData(ty.getJavaClass().getBytes());
      wsi.setReweavable(true);
    } else {
      clazz.getOrCreateWeaverStateInfo(false).setReweavable(false);
    }

    // tidyup, reduce ongoing memory usage of BcelMethods that hang around
View Full Code Here

    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.MUNGING_WITH, this);
    boolean changed = false;
    boolean worthReporting = true;

    if (weaver.getWorld().isOverWeaving()) {
      WeaverStateInfo typeWeaverState = weaver.getLazyClassGen().getType().getWeaverState();
      if (typeWeaverState != null && typeWeaverState.isAspectAlreadyApplied(getAspectType())) {
        return false;
      }
    }

    if (munger.getKind() == ResolvedTypeMunger.Field) {
      changed = mungeNewField(weaver, (NewFieldTypeMunger) munger);
    } else if (munger.getKind() == ResolvedTypeMunger.Method) {
      changed = mungeNewMethod(weaver, (NewMethodTypeMunger) munger);
    } else if (munger.getKind() == ResolvedTypeMunger.InnerClass) {
      changed = mungeNewMemberType(weaver, (NewMemberClassTypeMunger) munger);
    } else if (munger.getKind() == ResolvedTypeMunger.MethodDelegate2) {
      changed = mungeMethodDelegate(weaver, (MethodDelegateTypeMunger) munger);
    } else if (munger.getKind() == ResolvedTypeMunger.FieldHost) {
      changed = mungeFieldHost(weaver, (MethodDelegateTypeMunger.FieldHostTypeMunger) munger);
    } else if (munger.getKind() == ResolvedTypeMunger.PerObjectInterface) {
      changed = mungePerObjectInterface(weaver, (PerObjectInterfaceTypeMunger) munger);
      worthReporting = false;
    } else if (munger.getKind() == ResolvedTypeMunger.PerTypeWithinInterface) {
      // PTWIMPL Transform the target type (add the aspect instance field)
      changed = mungePerTypeWithinTransformer(weaver);
      worthReporting = false;
    } else if (munger.getKind() == ResolvedTypeMunger.PrivilegedAccess) {
      changed = mungePrivilegedAccess(weaver, (PrivilegedAccessMunger) munger);
      worthReporting = false;
    } else if (munger.getKind() == ResolvedTypeMunger.Constructor) {
      changed = mungeNewConstructor(weaver, (NewConstructorTypeMunger) munger);
    } else if (munger.getKind() == ResolvedTypeMunger.Parent) {
      changed = mungeNewParent(weaver, (NewParentTypeMunger) munger);
    } else if (munger.getKind() == ResolvedTypeMunger.AnnotationOnType) {
      changed = mungeNewAnnotationOnType(weaver, (AnnotationOnTypeMunger) munger);
      worthReporting = false;
    } else {
      throw new RuntimeException("unimplemented");
    }

    if (changed && munger.changesPublicSignature()) {
      WeaverStateInfo info = weaver.getLazyClassGen().getOrCreateWeaverStateInfo(weaver.getReweavableMode());
      info.addConcreteMunger(this);
    }

    if (changed && worthReporting) {
      ResolvedType declaringAspect = null;
      AsmManager model = ((BcelWorld) getWorld()).getModelAsAsmManager();
View Full Code Here

    // AMC we shouldn't need this when generic sigs are fixed??
    if (onType.isRawType()) {
      onType = onType.getGenericType();
    }

    WeaverStateInfo info = onType.getWeaverState();

    if (mode < 2) {
      // this test isnt quite right - there will be a case where we fail to
      // flag a problem
      // with a 'dangerous interface' because the type is reweavable when we
      // should have
      // because the type wasn't going to be rewoven... if that happens, we
      // should perhaps
      // move this test and dangerous interface processing to the end of this
      // method and
      // make it conditional on whether any of the typeMungers passed into
      // here actually
      // matched this type.
      if (info != null && !info.isOldStyle() && !info.isReweavable()) {
        processTypeMungersFromExistingWeaverState(sourceType, onType);
        CompilationAndWeavingContext.leavingPhase(tok);
        return;
      }

      // Check if the type we are looking at is the topMostImplementor of a
      // dangerous interface -
      // report a problem if it is.
      for (Iterator i = dangerousInterfaces.entrySet().iterator(); i.hasNext();) {
        Map.Entry entry = (Map.Entry) i.next();
        ResolvedType interfaceType = (ResolvedType) entry.getKey();
        if (onType.isTopmostImplementor(interfaceType)) {
          factory.showMessage(IMessage.ERROR, onType + ": " + entry.getValue(), onType.getSourceLocation(), null);
        }
      }

      boolean needOldStyleWarning = (info != null && info.isOldStyle());

      onType.clearInterTypeMungers();
      onType.ensureConsistent();

      // FIXME asc perf Could optimize here, after processing the expected set
View Full Code Here

    // if is java 6 class file
    if (myGen.getMajor() >= Constants.MAJOR_1_6 && world.shouldGenerateStackMaps() && AsmDetector.isAsmAround) {
      wovenClassFileData = StackMapAdder.addStackMaps(world, wovenClassFileData);
    }

    WeaverStateInfo wsi = myType.getWeaverState();// getOrCreateWeaverStateInfo
    // ();
    if (wsi != null && wsi.isReweavable()) { // && !reweavableDataInserted
      // reweavableDataInserted = true;
      return wsi.replaceKeyWithDiff(wovenClassFileData);
    } else {
      return wovenClassFileData;
    }
  }
View Full Code Here

    }
    return myType.getWeaverState().getAspectsAffectingType();
  }

  public WeaverStateInfo getOrCreateWeaverStateInfo(boolean inReweavableMode) {
    WeaverStateInfo ret = myType.getWeaverState();
    if (ret != null) {
      return ret;
    }
    ret = new WeaverStateInfo(inReweavableMode);
    myType.setWeaverState(ret);
    return ret;
  }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.WeaverStateInfo$Entry

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.