Package org.aspectj.weaver

Examples of org.aspectj.weaver.ResolvedMember


          if (isOverweaving && mg.getName().startsWith(NameMangler.PREFIX)) {
            return false;
          }
          enclosingShadow = BcelShadow.makeMethodExecution(world, mg, !canMatchBodyShadows);
        } else if (effective.isWeaveBody()) {
          ResolvedMember rm = effective.getEffectiveSignature();

          // Annotations for things with effective signatures are
          // never stored in the effective
          // signature itself - we have to hunt for them. Storing them
          // in the effective signature
View Full Code Here


    InstructionList ret = new InstructionList();

    for (ConcreteTypeMunger cmunger : list) {
      NewFieldTypeMunger munger = (NewFieldTypeMunger) cmunger.getMunger();
      ResolvedMember initMethod = munger.getInitMethod(cmunger.getAspectType());
      if (!isStatic) {
        ret.append(InstructionConstants.ALOAD_0);
      }
      ret.append(Utility.createInvoke(fact, world, initMethod));
    }
View Full Code Here

        // 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
            // not a join point according to 1.0.6 and 1.1.
          } else {
            if (canMatch(Shadow.FieldSet)) {
View Full Code Here

    // 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())) {
      // it's the set of a final constant, so it's
      // not a join point according to 1.0.6 and 1.1.
      return;
    } else if (resolvedField.isSynthetic()) {
      // sets of synthetics aren't join points in 1.1
      return;
    } else {
      // Fix for bug 172107 (similar the "get" fix for bug 109728)
      BcelShadow bs = BcelShadow.makeFieldSet(world, resolvedField, mg, ih, enclosingShadow);
      String cname = fi.getClassName(cpg);
      if (!resolvedField.getDeclaringType().getName().equals(cname)) {
        bs.setActualTargetType(cname);
      }
      match(bs, shadowAccumulator);
    }
  }
View Full Code Here

    // 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
      return;
    } else {
      BcelShadow bs = BcelShadow.makeFieldGet(world, resolvedField, mg, ih, enclosingShadow);
      String cname = fi.getClassName(cpg);
      if (!resolvedField.getDeclaringType().getName().equals(cname)) {
        bs.setActualTargetType(cname);
      }
      match(bs, shadowAccumulator);
    }
  }
View Full Code Here

   * believe there is only one member with that name in the type as it returns the first one it finds.
   */
  private ResolvedMember findResolvedMemberNamed(ResolvedType type, String methodName) {
    ResolvedMember[] allMethods = type.getDeclaredMethods();
    for (int i = 0; i < allMethods.length; i++) {
      ResolvedMember member = allMethods[i];
      if (member.getName().equals(methodName)) {
        return member;
      }
    }
    return null;
  }
View Full Code Here

              ResolvedType memberType = m_aspectGen.getWorld().resolve(resolvedMember.getDeclaringType());
              if (!aspectType.equals(memberType) && memberType.isAssignableFrom(aspectType)) {
                // old test was...
                // if (aspectType.getSuperclass() != null
                // && aspectType.getSuperclass().getName().equals(resolvedMember.getDeclaringType().getName())) {
                ResolvedMember accessor = createOrGetInlineAccessorForSuperDispatch(resolvedMember);
                InvokeInstruction newInst = factory.createInvoke(aspectType.getName(), accessor.getName(),
                    BcelWorld.makeBcelType(accessor.getReturnType()),
                    BcelWorld.makeBcelTypes(accessor.getParameterTypes()), Constants.INVOKEVIRTUAL);
                curr.setInstruction(newInst);
              } else {
                ResolvedMember accessor = createOrGetInlineAccessorForMethod(resolvedMember);
                InvokeInstruction newInst = factory.createInvoke(aspectType.getName(), accessor.getName(),
                    BcelWorld.makeBcelType(accessor.getReturnType()),
                    BcelWorld.makeBcelTypes(accessor.getParameterTypes()), Constants.INVOKESTATIC);
                curr.setInstruction(newInst);
              }
            }

            break;// ok we found a matching callee member and swapped the instruction with the accessor
          }
        }
      } else if (inst instanceof FieldInstruction) {
        FieldInstruction invoke = (FieldInstruction) inst;
        ResolvedType callee = m_aspectGen.getWorld().resolve(UnresolvedType.forName(invoke.getClassName(cpg)));
        for (int i = 0; i < callee.getDeclaredJavaFields().length; i++) {
          ResolvedMember resolvedMember = callee.getDeclaredJavaFields()[i];
          if (invoke.getName(cpg).equals(resolvedMember.getName())
              && invoke.getSignature(cpg).equals(resolvedMember.getSignature()) && !resolvedMember.isPublic()) {
            final ResolvedMember accessor;
            if ((inst.opcode == Constants.GETFIELD) || (inst.opcode == Constants.GETSTATIC)) {
              accessor = createOrGetInlineAccessorForFieldGet(resolvedMember);
            } else {
              accessor = createOrGetInlineAccessorForFieldSet(resolvedMember);
            }
            InvokeInstruction newInst = factory.createInvoke(aspectType.getName(), accessor.getName(),
                BcelWorld.makeBcelType(accessor.getReturnType()),
                BcelWorld.makeBcelTypes(accessor.getParameterTypes()), Constants.INVOKESTATIC);
            curr.setInstruction(newInst);

            break;// ok we found a matching callee member and swapped the instruction with the accessor
          }
        }
View Full Code Here

   * @return
   */
  private ResolvedMember createOrGetInlineAccessorForMethod(ResolvedMember resolvedMember) {
    String accessor = NameMangler.inlineAccessMethodForMethod(resolvedMember.getName(), resolvedMember.getDeclaringType(),
        aspectType);
    ResolvedMember inlineAccessor = m_inlineAccessorBcelMethods.get(accessor);
    if (inlineAccessor == null) {
      // add static method to aspect
      inlineAccessor = AjcMemberMaker.inlineAccessMethodForMethod(aspectType, resolvedMember);

      // add new accessor method to aspect bytecode
      InstructionFactory factory = m_aspectGen.getFactory();
      LazyMethodGen method = makeMethodGen(m_aspectGen, inlineAccessor);
      // flag it synthetic, AjSynthetic
      method.makeSynthetic();
      List<AjAttribute> methodAttributes = new ArrayList<AjAttribute>();
      methodAttributes.add(new AjAttribute.AjSynthetic());
      methodAttributes.add(new AjAttribute.EffectiveSignatureAttribute(resolvedMember, Shadow.MethodCall, false));
      method.addAttribute(Utility.bcelAttribute(methodAttributes.get(0), m_aspectGen.getConstantPool()));
      // flag the effective signature, so that we can deobfuscate the signature to apply method call pointcut
      method.addAttribute(Utility.bcelAttribute(methodAttributes.get(1), m_aspectGen.getConstantPool()));

      inlineAccessorMethodGens.add(method);

      InstructionList il = method.getBody();
      int register = 0;
      for (int i = 0; i < inlineAccessor.getParameterTypes().length; i++) {
        UnresolvedType typeX = inlineAccessor.getParameterTypes()[i];
        Type type = BcelWorld.makeBcelType(typeX);
        il.append(InstructionFactory.createLoad(type, register));
        register += type.getSize();
      }
      il.append(Utility.createInvoke(factory, Modifier.isStatic(resolvedMember.getModifiers()) ? Constants.INVOKESTATIC
          : Constants.INVOKEVIRTUAL, resolvedMember));
      il.append(InstructionFactory.createReturn(BcelWorld.makeBcelType(inlineAccessor.getReturnType())));

      m_inlineAccessorBcelMethods.put(accessor, new BcelMethod(m_aspectGen.getBcelObjectType(), method.getMethod(),
          methodAttributes));
    }
    return inlineAccessor;
View Full Code Here

   * @param resolvedMember
   * @return
   */
  private ResolvedMember createOrGetInlineAccessorForSuperDispatch(ResolvedMember resolvedMember) {
    String accessor = NameMangler.superDispatchMethod(aspectType, resolvedMember.getName());
    ResolvedMember inlineAccessor = m_inlineAccessorBcelMethods.get(accessor);
    if (inlineAccessor == null) {
      // add super accessor method to class:
      inlineAccessor = AjcMemberMaker.superAccessMethod(aspectType, resolvedMember);

      // add new accessor method to aspect bytecode
      InstructionFactory factory = m_aspectGen.getFactory();
      LazyMethodGen method = makeMethodGen(m_aspectGen, inlineAccessor);
      // flag it synthetic, AjSynthetic
      method.makeSynthetic();
      List<AjAttribute> methodAttributes = new ArrayList<AjAttribute>();
      methodAttributes.add(new AjAttribute.AjSynthetic());
      methodAttributes.add(new AjAttribute.EffectiveSignatureAttribute(resolvedMember, Shadow.MethodCall, false));
      method.addAttribute(Utility.bcelAttribute(methodAttributes.get(0), m_aspectGen.getConstantPool()));
      // flag the effective signature, so that we can deobfuscate the signature to apply method call pointcut
      method.addAttribute(Utility.bcelAttribute(methodAttributes.get(1), m_aspectGen.getConstantPool()));

      inlineAccessorMethodGens.add(method);

      InstructionList il = method.getBody();
      il.append(InstructionConstants.ALOAD_0);
      int register = 1;
      for (int i = 0; i < inlineAccessor.getParameterTypes().length; i++) {
        UnresolvedType typeX = inlineAccessor.getParameterTypes()[i];
        Type type = BcelWorld.makeBcelType(typeX);
        il.append(InstructionFactory.createLoad(type, register));
        register += type.getSize();
      }
      il.append(Utility.createInvoke(factory, Constants.INVOKESPECIAL, resolvedMember));
      il.append(InstructionFactory.createReturn(BcelWorld.makeBcelType(inlineAccessor.getReturnType())));

      m_inlineAccessorBcelMethods.put(accessor, new BcelMethod(m_aspectGen.getBcelObjectType(), method.getMethod(),
          methodAttributes));
    }
    return inlineAccessor;
View Full Code Here

   * @return
   */
  private ResolvedMember createOrGetInlineAccessorForFieldGet(ResolvedMember resolvedMember) {
    String accessor = NameMangler.inlineAccessMethodForFieldGet(resolvedMember.getName(), resolvedMember.getDeclaringType(),
        aspectType);
    ResolvedMember inlineAccessor = m_inlineAccessorBcelMethods.get(accessor);
    if (inlineAccessor == null) {
      // add static method to aspect
      inlineAccessor = AjcMemberMaker.inlineAccessMethodForFieldGet(aspectType, resolvedMember);

      // add new accessor method to aspect bytecode
      InstructionFactory factory = m_aspectGen.getFactory();
      LazyMethodGen method = makeMethodGen(m_aspectGen, inlineAccessor);
      // flag it synthetic, AjSynthetic
      method.makeSynthetic();
      List<AjAttribute> methodAttributes = new ArrayList<AjAttribute>();
      methodAttributes.add(new AjAttribute.AjSynthetic());
      methodAttributes.add(new AjAttribute.EffectiveSignatureAttribute(resolvedMember, Shadow.FieldGet, false));
      // flag the effective signature, so that we can deobfuscate the signature to apply method call pointcut
      method.addAttribute(Utility.bcelAttribute(methodAttributes.get(0), m_aspectGen.getConstantPool()));
      method.addAttribute(Utility.bcelAttribute(methodAttributes.get(1), m_aspectGen.getConstantPool()));

      inlineAccessorMethodGens.add(method);

      InstructionList il = method.getBody();
      if (Modifier.isStatic(resolvedMember.getModifiers())) {
        // field accessed is static so no "this" as accessor sole parameter
      } else {
        il.append(InstructionConstants.ALOAD_0);
      }
      il.append(Utility.createGet(factory, resolvedMember));
      il.append(InstructionFactory.createReturn(BcelWorld.makeBcelType(inlineAccessor.getReturnType())));

      m_inlineAccessorBcelMethods.put(accessor, new BcelMethod(m_aspectGen.getBcelObjectType(), method.getMethod(),
          methodAttributes));
    }
    return inlineAccessor;
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.ResolvedMember

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.