Package org.aspectj.weaver

Examples of org.aspectj.weaver.Member


    BcelVar bvar = (BcelVar) var;
    bvar.insertLoad(instructions, fact);
  }

  public void visit(FieldGet fieldGet) {
    Member field = fieldGet.getField();
    // assert field.isStatic()
    instructions.insert(Utility.createGet(fact, field));
  }
View Full Code Here


    // assert field.isStatic()
    instructions.insert(Utility.createGet(fact, field));
  }

  public void visit(CallExpr call) {
    Member method = call.getMethod();
    // assert method.isStatic()
    Expr[] args = call.getArgs();
    InstructionList callIl = renderExprs(fact, world, args);
    callIl.append(Utility.createInvoke(fact, world, method));
    instructions.insert(callIl);
View Full Code Here

   *
   * @see org.aspectj.weaver.patterns.Pointcut#match(org.aspectj.weaver.Shadow)
   */
  protected FuzzyBoolean matchInternal(Shadow shadow) {
    AnnotatedElement toMatchAgainst = null;
    Member member = shadow.getSignature();
    ResolvedMember rMember = member.resolve(shadow.getIWorld());

    if (rMember == null) {
      if (member.getName().startsWith(NameMangler.PREFIX)) {
        return FuzzyBoolean.NO;
      }
      shadow.getIWorld().getLint().unresolvableMember.signal(member.toString(), getSourceLocation());
      return FuzzyBoolean.NO;
    }

    Shadow.Kind kind = shadow.getKind();
    if (kind == Shadow.StaticInitialization) {
View Full Code Here

    boolean fastSJP = false;
    // avoid fast SJP if it is for an enclosing joinpoint
    boolean isFastSJPAvailable = shadow.getWorld().isTargettingRuntime1_6_10()
        && !enclosingStaticTjpType.equals(field.getType());

    Member sig = shadow.getSignature();

    // load the factory
    list.append(InstructionFactory.createLoad(factoryType, 0));

    // load the kind
    list.append(InstructionFactory.PUSH(getConstantPool(), shadow.getKind().getName()));

    // create the signature
    if (world.isTargettingAspectJRuntime12() || !isFastSJPAvailable || !sig.getKind().equals(Member.METHOD)) {
      list.append(InstructionFactory.createLoad(factoryType, 0));
    }

    String signatureMakerName = SignatureUtils.getSignatureMakerName(sig);
    ObjectType signatureType = new ObjectType(SignatureUtils.getSignatureType(sig));
    UnresolvedType[] exceptionTypes = null;
    if (world.isTargettingAspectJRuntime12()) { // TAG:SUPPORTING12: We
      // didn't have optimized
      // factory methods in 1.2
      list.append(InstructionFactory.PUSH(cp, SignatureUtils.getSignatureString(sig, shadow.getWorld())));
      list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, Type.STRINGARRAY1,
          Constants.INVOKEVIRTUAL));
    } else if (sig.getKind().equals(Member.METHOD)) {
      BcelWorld w = shadow.getWorld();

      // For methods, push the parts of the signature on.
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getModifiers(w))));
      list.append(InstructionFactory.PUSH(cp, sig.getName()));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getDeclaringType())));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getParameterTypes())));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getParameterNames(w))));
      exceptionTypes = sig.getExceptions(w);
      if (isFastSJPAvailable && exceptionTypes.length == 0) {
        fastSJP = true;
      } else {
        list.append(InstructionFactory.PUSH(cp, makeString(exceptionTypes)));
      }
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getReturnType())));
      // And generate a call to the variant of makeMethodSig() that takes the strings
      if (isFastSJPAvailable) {
        fastSJP = true;
      } else {
        list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, Type.STRINGARRAY7,
            Constants.INVOKEVIRTUAL));
      }

    } else if (sig.getKind().equals(Member.MONITORENTER)) {
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getDeclaringType())));
      list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, Type.STRINGARRAY1,
          Constants.INVOKEVIRTUAL));
    } else if (sig.getKind().equals(Member.MONITOREXIT)) {
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getDeclaringType())));
      list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, Type.STRINGARRAY1,
          Constants.INVOKEVIRTUAL));
    } else if (sig.getKind().equals(Member.HANDLER)) {
      BcelWorld w = shadow.getWorld();
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getDeclaringType())));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getParameterTypes())));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getParameterNames(w))));
      list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, Type.STRINGARRAY3,
          Constants.INVOKEVIRTUAL));
    } else if (sig.getKind().equals(Member.CONSTRUCTOR)) {
      BcelWorld w = shadow.getWorld();
      if (w.isJoinpointArrayConstructionEnabled() && sig.getDeclaringType().isArray()) {
        // its the magical new jp
        list.append(InstructionFactory.PUSH(cp, makeString(Modifier.PUBLIC)));
        list.append(InstructionFactory.PUSH(cp, makeString(sig.getDeclaringType())));
        list.append(InstructionFactory.PUSH(cp, makeString(sig.getParameterTypes())));
        list.append(InstructionFactory.PUSH(cp, "")); // sig.getParameterNames?
        list.append(InstructionFactory.PUSH(cp, ""));// sig.getExceptions?
        list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, Type.STRINGARRAY5,
            Constants.INVOKEVIRTUAL));
      } else {
        list.append(InstructionFactory.PUSH(cp, makeString(sig.getModifiers(w))));
        list.append(InstructionFactory.PUSH(cp, makeString(sig.getDeclaringType())));
        list.append(InstructionFactory.PUSH(cp, makeString(sig.getParameterTypes())));
        list.append(InstructionFactory.PUSH(cp, makeString(sig.getParameterNames(w))));
        list.append(InstructionFactory.PUSH(cp, makeString(sig.getExceptions(w))));
        list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, Type.STRINGARRAY5,
            Constants.INVOKEVIRTUAL));
      }
    } else if (sig.getKind().equals(Member.FIELD)) {
      BcelWorld w = shadow.getWorld();
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getModifiers(w))));
      list.append(InstructionFactory.PUSH(cp, sig.getName()));
      // see pr227401
      UnresolvedType dType = sig.getDeclaringType();
      if (dType.getTypekind() == TypeKind.PARAMETERIZED || dType.getTypekind() == TypeKind.GENERIC) {
        dType = sig.getDeclaringType().resolve(world).getGenericType();
      }
      list.append(InstructionFactory.PUSH(cp, makeString(dType)));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getReturnType())));
      list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, Type.STRINGARRAY4,
          Constants.INVOKEVIRTUAL));
    } else if (sig.getKind().equals(Member.ADVICE)) {
      BcelWorld w = shadow.getWorld();
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getModifiers(w))));
      list.append(InstructionFactory.PUSH(cp, sig.getName()));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getDeclaringType())));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getParameterTypes())));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getParameterNames(w))));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getExceptions(w))));
      list.append(InstructionFactory.PUSH(cp, makeString((sig.getReturnType()))));
      list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, new Type[] { Type.STRING,
          Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING }, Constants.INVOKEVIRTUAL));
    } else if (sig.getKind().equals(Member.STATIC_INITIALIZATION)) {
      BcelWorld w = shadow.getWorld();
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getModifiers(w))));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getDeclaringType())));
      list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, Type.STRINGARRAY2,
          Constants.INVOKEVIRTUAL));
    } else {
      list.append(InstructionFactory.PUSH(cp, SignatureUtils.getSignatureString(sig, shadow.getWorld())));
      list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, Type.STRINGARRAY1,
View Full Code Here

    EclipseFactory factory = ((AjLookupEnvironment) declaration.scope.environment()).factory;
    World world = factory.getWorld();
    UnresolvedType onType = rp.onType;
    if (onType == null) {
      if (declaration.binding != null) {
        Member member = factory.makeResolvedMember(declaration.binding);
        onType = member.getDeclaringType();
      } else {
        return null;
      }
    }
    ResolvedMember[] members = onType.resolve(world).getDeclaredPointcuts();
View Full Code Here

  // }
  protected void genBytecodeInfo(MethodDeclaration methodDeclaration, IProgramElement peNode) {
    if (methodDeclaration.binding != null) {
      try {
        EclipseFactory factory = ((AjLookupEnvironment) methodDeclaration.scope.environment()).factory;
        Member member = factory.makeResolvedMember(methodDeclaration.binding);
        peNode.setBytecodeName(member.getName());
        peNode.setBytecodeSignature(member.getSignature());
      } catch (BCException bce) { // bad type name
        bce.printStackTrace();
      } catch (NullPointerException npe) {
        npe.printStackTrace();
      }
View Full Code Here

    if (constructorDeclaration.binding != null) {
      String memberName = "";
      String memberBytecodeSignature = "";
      try {
        EclipseFactory factory = ((AjLookupEnvironment) constructorDeclaration.scope.environment()).factory;
        Member member = factory.makeResolvedMember(constructorDeclaration.binding);
        memberName = member.getName();
        memberBytecodeSignature = member.getSignature();
      } catch (BCException bce) { // bad type name
        memberName = "<undefined>";
      } catch (NullPointerException npe) {
        memberName = "<undefined>";
      }
View Full Code Here

  private boolean hasField(ResolvedType type) {
    // TODO what about ITDs
    World world = type.getWorld();
    for (Iterator iter = type.getFields(); iter.hasNext();) {
      Member field = (Member) iter.next();
      if (field.getName().startsWith(declareAtPrefix)) {
        continue;
      }
      if (signaturePattern.matches(field, type.getWorld(), false)) {
        if (field.getDeclaringType().resolve(world) != type) {
          if (Modifier.isPrivate(field.getModifiers())) {
            continue;
          }
        }
        return true;
      }
View Full Code Here

  private boolean hasMethod(ResolvedType type) {
    // TODO what about ITDs
    World world = type.getWorld();
    for (Iterator iter = type.getMethods(true, true); iter.hasNext();) {
      Member method = (Member) iter.next();
      if (method.getName().startsWith(declareAtPrefix)) {
        continue;
      }
      if (signaturePattern.matches(method, type.getWorld(), false)) {
        if (method.getDeclaringType().resolve(world) != type) {
          if (Modifier.isPrivate(method.getModifiers())) {
            continue;
          }
        }
        return true;
      }
    }
    // try itds before we give up
    List<ConcreteTypeMunger> mungers = type.getInterTypeMungersIncludingSupers();
    for (Iterator<ConcreteTypeMunger> iter = mungers.iterator(); iter.hasNext();) {
      ConcreteTypeMunger munger = iter.next();
      Member member = munger.getSignature();
      if (signaturePattern.matches(member, type.getWorld(), false)) {
        if (!Modifier.isPublic(member.getModifiers())) {
          continue;
        }
        return true;
      }
    }
View Full Code Here

   * (non-Javadoc)
   *
   * @see org.aspectj.weaver.patterns.Pointcut#match(org.aspectj.weaver.Shadow)
   */
  protected FuzzyBoolean matchInternal(Shadow shadow) {
    Member member = shadow.getEnclosingCodeSignature();
    ResolvedMember rMember = member.resolve(shadow.getIWorld());

    if (rMember == null) {
      if (member.getName().startsWith(NameMangler.PREFIX)) {
        return FuzzyBoolean.NO;
      }
      shadow.getIWorld().getLint().unresolvableMember.signal(member.toString(), getSourceLocation());
      return FuzzyBoolean.NO;
    }

    annotationTypePattern.resolve(shadow.getIWorld());
    return annotationTypePattern.matches(rMember);
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.