Package org.aspectj.weaver

Examples of org.aspectj.weaver.Member$Kind


    ret.inAspect = inAspect;
    if (inAspect.isAbstract()) {
      return ret;
    }

    Member cflowStackField = new ResolvedMemberImpl(Member.FIELD, inAspect, Modifier.STATIC | Modifier.PUBLIC | Modifier.FINAL,
        UnresolvedType.forName(NameMangler.CFLOW_STACK_TYPE), NameMangler.PERCFLOW_FIELD_NAME, UnresolvedType.NONE);

    World world = inAspect.getWorld();

    CrosscuttingMembers xcut = inAspect.crosscuttingMembers;
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

    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(UnresolvedType.VOID)) {
          kind = Shadow.FieldSet;
        } else {
          kind = Shadow.FieldGet;
        }
View Full Code Here

        (fi.opcode == Constants.GETSTATIC || fi.opcode == Constants.PUTSTATIC) ? Modifier.STATIC : 0, fi.getName(cpg),
        fi.getSignature(cpg));
  }

  public Member makeJoinPointSignatureFromMethod(LazyMethodGen mg, MemberKind kind) {
    Member ret = mg.getMemberView();
    if (ret == null) {
      int mods = mg.getAccessFlags();
      if (mg.getEnclosingClass().isInterface()) {
        mods |= Modifier.INTERFACE;
      }
View Full Code Here

  }

  public Member makeJoinPointSignatureForArrayConstruction(LazyClassGen cg, InstructionHandle handle) {
    Instruction i = handle.getInstruction();
    ConstantPool cpg = cg.getConstantPool();
    Member retval = null;

    if (i.opcode == Constants.ANEWARRAY) {
      // ANEWARRAY arrayInstruction = (ANEWARRAY)i;
      Type ot = i.getType(cpg);
      UnresolvedType ut = fromBcel(ot);
View Full Code Here

    if (annoAccessor.getKind() != Shadow.MethodExecution) {
      return;
    }
    String annotationOfInterestSignature = annoAccessor.getType().getSignature();
    // So we have an entity that has an annotation on and within it is the value we want
    Member holder = annoAccessor.getMember();
    AnnotationAJ[] annos = holder.getAnnotations();
    for (AnnotationAJ anno : annos) {
      AnnotationGen annotation = ((BcelAnnotation) anno).getBcelAnnotation();
      boolean foundValueInAnnotationUsage = false;
      if (annotation.getTypeSignature().equals(annotationOfInterestSignature)) {
        ResolvedMember[] annotationFields = toType.getWorld()
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.Member$Kind

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.