Package org.aspectj.apache.bcel.generic

Examples of org.aspectj.apache.bcel.generic.FieldInstruction


            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);
View Full Code Here


        }
      }
    }

    if ((i instanceof FieldInstruction) && (canMatch(Shadow.FieldGet) || canMatch(Shadow.FieldSet))) {
      FieldInstruction fi = (FieldInstruction) i;

      if (fi.opcode == Constants.PUTFIELD || fi.opcode == Constants.PUTSTATIC) {
        // check for sets of constant fields. We first check the
        // previous
        // instruction. If the previous instruction is a LD_WHATEVER
View Full Code Here

    return false;
  }

  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())) {
      // 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

    }
  }

  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
      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

  {
    Instruction i = ih.getInstruction();
    if ((i instanceof FieldInstruction) &&
      (canMatch(Shadow.FieldGet) || canMatch(Shadow.FieldSet))
    ) {
      FieldInstruction fi = (FieldInstruction) i;
           
      if (fi instanceof PUTFIELD || fi instanceof PUTSTATIC) {
        // check for sets of constant fields.  We first check the previous
        // instruction.  If the previous instruction is a LD_WHATEVER (push
        // constant on the stack) then we must resolve the field to determine
View Full Code Here

  private void matchSetInstruction(
    LazyMethodGen mg,
    InstructionHandle ih,
    BcelShadow enclosingShadow,
    List 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;
   
View Full Code Here

        shadowAccumulator);
    }
  }

  private void matchGetInstruction(LazyMethodGen mg, InstructionHandle ih, BcelShadow enclosingShadow, List 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
      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

              LocalVariableTag lvt = LazyMethodGen.getLocalVariableTag(searchPtr,li.getIndex());
              return lvt.getType();
            }
            // A field access instruction may tell us the real type of what the clone() call is on
            if (searchPtr.getInstruction() instanceof FieldInstruction) {
              FieldInstruction si = (FieldInstruction)searchPtr.getInstruction();
              Type t = si.getFieldType(getEnclosingClass().getConstantPoolGen());
              return BcelWorld.fromBcel(t);
            }
            // A new array instruction obviously tells us it is an array type !
            if (searchPtr.getInstruction() instanceof ANEWARRAY) {
              //ANEWARRAY ana = (ANEWARRAY)searchPoint.getInstruction();
View Full Code Here

                        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 instanceof GETFIELD) || (inst instanceof GETSTATIC)) {
                            accessor = createOrGetInlineAccessorForFieldGet(resolvedMember);
                        } else {
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.generic.FieldInstruction

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.