Package org.aspectj.weaver

Examples of org.aspectj.weaver.Member


    // remove any unnecessary exceptions if the compiler option is set to
    // error or warning and if this piece of advice throws exceptions
    // (bug 129282). This may be expanded to include other compiler warnings
    // at the moment it only deals with 'declared exception is not thrown'
    if (!shadow.getWorld().isIgnoringUnusedDeclaredThrownException() && !getThrownExceptions().isEmpty()) {
      Member member = shadow.getSignature();
      if (member instanceof BcelMethod) {
        removeUnnecessaryProblems((BcelMethod) member, ((BcelMethod) member).getDeclarationLineNumber());
      } else {
        // 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());
          }
        }
      }
    }

    if (shadow.getIWorld().isJoinpointSynchronizationEnabled() && shadow.getKind() == Shadow.MethodExecution
        && (s.getSignature().getModifiers() & Modifier.SYNCHRONIZED) != 0) {
      shadow.getIWorld().getLint().advisingSynchronizedMethods.signal(new String[] { shadow.toString() },
          shadow.getSourceLocation(), new ISourceLocation[] { getSourceLocation() });
    }

    // FIXME AV - see #75442, this logic is not enough so for now comment it out until we fix the bug
    // // callback for perObject AJC MightHaveAspect postMunge (#75442)
    // if (getConcreteAspect() != null
    // && getConcreteAspect().getPerClause() != null
    // && PerClause.PEROBJECT.equals(getConcreteAspect().getPerClause().getKind())) {
    // final PerObject clause;
    // if (getConcreteAspect().getPerClause() instanceof PerFromSuper) {
    // clause = (PerObject)((PerFromSuper) getConcreteAspect().getPerClause()).lookupConcretePerClause(getConcreteAspect());
    // } else {
    // clause = (PerObject) getConcreteAspect().getPerClause();
    // }
    // if (clause.isThis()) {
    // PerObjectInterfaceTypeMunger.registerAsAdvisedBy(s.getThisVar().getType(), getConcreteAspect());
    // } else {
    // PerObjectInterfaceTypeMunger.registerAsAdvisedBy(s.getTargetVar().getType(), getConcreteAspect());
    // }
    // }
    if (runtimeTest == Literal.FALSE) { // not usually allowed, except in one case (260384)
      Member sig = shadow.getSignature();
      if (sig.getArity() == 0 && shadow.getKind() == Shadow.MethodCall && sig.getName().charAt(0) == 'c'
          && sig.getReturnType().equals(ResolvedType.OBJECT) && sig.getName().equals("clone")) {
        return false;
      }
    }

    if (getKind() == AdviceKind.Before) {
View Full Code Here


    return new InstructionList(Utility.createInvoke(shadow.getFactory(), shadow.getWorld(), getOriginalSignature()));
  }

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

    if (!isThisCall(superOrThisCall)) {
      InstructionHandle curr = enclosingShadow.getRange().getStart();
      for (Iterator<IfaceInitList> i = addedSuperInitializersAsList.iterator(); i.hasNext();) {
        IfaceInitList l = i.next();

        Member ifaceInitSig = AjcMemberMaker.interfaceConstructor(l.onType);

        BcelShadow initShadow = BcelShadow.makeIfaceInitialization(world, mg, ifaceInitSig);

        // insert code in place
        InstructionList inits = genInitInstructions(l.list, false);
View Full Code Here

        // if it's final. If it is final, then we don't generate a
        // shadow.
        InstructionHandle prevHandle = ih.getPrev();
        Instruction prevI = prevHandle.getInstruction();
        if (Utility.isConstantPushInstruction(prevI)) {
          Member field = BcelWorld.makeFieldJoinPointSignature(clazz, (FieldInstruction) i);
          ResolvedMember resolvedField = field.resolve(world);
          if (resolvedField == null) {
            // we can't find the field, so it's not a join point.
          } else if (Modifier.isFinal(resolvedField.getModifiers())) {
            // it's final, so it's the set of a final constant, so
            // it's
View Full Code Here

  }

  private void matchSetInstruction(LazyMethodGen mg, InstructionHandle ih, BcelShadow enclosingShadow,
      List<BcelShadow> shadowAccumulator) {
    FieldInstruction fi = (FieldInstruction) ih.getInstruction();
    Member field = BcelWorld.makeFieldJoinPointSignature(clazz, fi);

    // synthetic fields are never join points
    if (field.getName().startsWith(NameMangler.PREFIX)) {
      return;
    }

    ResolvedMember resolvedField = field.resolve(world);
    if (resolvedField == null) {
      // we can't find the field, so it's not a join point.
      return;
    } else if (Modifier.isFinal(resolvedField.getModifiers())
        && Utility.isConstantPushInstruction(ih.getPrev().getInstruction())) {
View Full Code Here

  }

  private void matchGetInstruction(LazyMethodGen mg, InstructionHandle ih, BcelShadow enclosingShadow,
      List<BcelShadow> shadowAccumulator) {
    FieldInstruction fi = (FieldInstruction) ih.getInstruction();
    Member field = BcelWorld.makeFieldJoinPointSignature(clazz, fi);

    // synthetic fields are never join points
    if (field.getName().startsWith(NameMangler.PREFIX)) {
      return;
    }

    ResolvedMember resolvedField = field.resolve(world);
    if (resolvedField == null) {
      // we can't find the field, so it's not a join point.
      return;
    } else if (resolvedField.isSynthetic()) {
      // sets of synthetics aren't join points in 1.1
View Full Code Here

  private void matchInvokeInstruction(LazyMethodGen mg, InstructionHandle ih, InvokeInstruction invoke,
      BcelShadow enclosingShadow, List<BcelShadow> shadowAccumulator) {
    String methodName = invoke.getName(cpg);
    if (methodName.startsWith(NameMangler.PREFIX)) {
      Member jpSig = world.makeJoinPointSignatureForMethodInvocation(clazz, invoke);
      ResolvedMember declaredSig = jpSig.resolve(world);
      // System.err.println(method + ", declaredSig: " +declaredSig);
      if (declaredSig == null) {
        return;
      }

      if (declaredSig.getKind() == Member.FIELD) {
        Shadow.Kind kind;
        if (jpSig.getReturnType().equals(ResolvedType.VOID)) {
          kind = Shadow.FieldSet;
        } else {
          kind = Shadow.FieldGet;
        }
View Full Code Here

    il.append(InstructionFactory.createBranchInstruction(Constants.IFNULL, fk));

    // Load up the var again
    il.append(((BcelVar) hasAnnotation.getVar()).createLoad(fact));

    Member getClass = MemberImpl.method(UnresolvedType.OBJECT, 0, UnresolvedType.JL_CLASS, "getClass",
        UnresolvedType.NONE);
    il.append(Utility.createInvoke(fact, world, getClass));
    // aload annotationClass
    il.append(fact.createConstant(new ObjectType(hasAnnotation.getAnnotationType().getName())));
    // int annClassIndex = fact.getConstantPool().addClass(hasAnnotation.getAnnotationType().getSignature());
    // il.append(new LDC_W(annClassIndex));
    Member isAnnotationPresent = MemberImpl.method(UnresolvedType.JL_CLASS, 0, ResolvedType.BOOLEAN,
        "isAnnotationPresent", new UnresolvedType[] { UnresolvedType.JL_CLASS });
    il.append(Utility.createInvoke(fact, world, isAnnotationPresent));
    il.append(createJumpBasedOnBooleanOnStack());
    instructions.insert(il);
    hasAnnotation.getVar().accept(this);
View Full Code Here

      throw new BCException("visiting a false expression");
    }
  }

  public void visit(Call call) {
    Member method = call.getMethod();
    // assert method.isStatic()
    Expr[] args = call.getArgs();
    // System.out.println("args: " + Arrays.asList(args));
    InstructionList callIl = new InstructionList();
    for (int i = 0, len = args.length; i < len; i++) {
      // XXX only correct for static method calls
      Type desiredType = BcelWorld.makeBcelType(method.getParameterTypes()[i]);
      Expr arg = args[i];
      // if arg is null it is because we couldn't bind it properly, for example see 162135
      if (arg == null) {
        InstructionList iList = new InstructionList();
        iList.append(InstructionFactory.createNull(desiredType));
View Full Code Here

    callIl.append(createJumpBasedOnBooleanOnStack());
    instructions.insert(callIl);
  }

  public void visit(FieldGetCall fieldGetCall) {
    Member field = fieldGetCall.getField();
    Member method = fieldGetCall.getMethod();
    InstructionList il = new InstructionList();
    il.append(Utility.createGet(fact, field));
    // assert !method.isStatic()
    Expr[] args = fieldGetCall.getArgs();
    // System.out.println("args: " + Arrays.asList(args));
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.Member

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.