Examples of FieldInstruction


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

    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

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

    }
  }

  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

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

        }
      }
    }

    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

Examples of org.freud.analysed.classbytecode.method.instruction.FieldInstruction

    public void visitFieldInsn(
            final int opcode,
            final String owner,
            final String name,
            final String desc) {
        final Instruction instruction = new FieldInstruction(instructionList.size(), OPCODES_ARRAY[opcode], currentLineNumber, owner, name, desc);
        updateCurrentState(instruction);
    }
View Full Code Here

Examples of serp.bytecode.FieldInstruction

                return null;

            // if the middle instruction was a getfield, then it's the
            // field that's being accessed
            if (!findAccessed && prevIns instanceof GetFieldInstruction) {
                final FieldInstruction fPrevIns = (FieldInstruction) prevIns;
                cur = (BCField) AccessController.doPrivileged(
                    J2DoPrivHelper.getFieldInstructionFieldAction(fPrevIns));
                // if the middle instruction was an xload_1, then the
                // matched instruction is the field that's being set.
            } else if (findAccessed && prevIns instanceof LoadInstruction
                && ((LoadInstruction) prevIns).getParam() == 0) {
                final FieldInstruction fTemplateIns =
                    (FieldInstruction) templateIns;
                cur = (BCField) AccessController.doPrivileged(J2DoPrivHelper
                    .getFieldInstructionFieldAction(fTemplateIns));
            } else
                return null;
View Full Code Here

Examples of serp.bytecode.FieldInstruction

     */
    private void replaceAndValidateFieldAccess(Code code, Instruction ins,
        boolean get, Instruction stat) throws NoSuchMethodException {
        code.beforeFirst();

        FieldInstruction fi;
        MethodInstruction mi;
        ClassMetaData owner;
        String name, typeName, methodName;
        while (code.searchForward(ins)) {
            // back up to the matched instruction
            fi = (FieldInstruction) code.previous();
            name = fi.getFieldName();
            typeName = fi.getFieldTypeName();
            owner = getPersistenceCapableOwner(name, fi.getFieldDeclarerType());

            if (owner != null
                && owner.getAccessType() == ClassMetaData.ACCESS_PROPERTY) {
                // if we're directly accessing a field in another class
                // hierarchy that uses property access, something is wrong
                if (owner != _meta && owner.getDeclaredField(name) != null &&
                    _meta != null && !owner.getDescribedType()
                        .isAssignableFrom(_meta.getDescribedType()))
                    throw new UserException(_loc.get("property-field-access",
                        new Object[]{ _meta, owner, name,
                            code.getMethod().getName() }));

                // if we're directly accessing a property-backing field outside
                // the property in our own class, notify user
                if (isBackingFieldOfAnotherProperty(name, code))
                    addViolation("property-field-access", new Object[]{ _meta,
                        owner, name, code.getMethod().getName() }, false);
            }

            if (owner == null ||
                owner.getDeclaredField(fromBackingFieldName(name)) == null) {
                // not persistent field?
                code.next();
                continue;
            } else if (!getRedefine() && !getCreateSubclass()
                && owner.getAccessType() == ClassMetaData.ACCESS_FIELD) {
                // replace the instruction with a call to the generated access
                // method
                mi = (MethodInstruction) code.set(stat);

                // invoke the proper access method, whether getter or setter
                String prefix = (get) ? PRE + "Get" : PRE + "Set";
                methodName = prefix + name;
                if (get) {
                    mi.setMethod(getType(owner).getName(),
                        methodName, typeName, new String[]
                        { getType(owner).getName() });
                } else {
                    mi.setMethod(getType(owner).getName(),
                        methodName, "void", new String[]
                        { getType(owner).getName(), typeName });
                }
                code.next();
            } else if (getRedefine()) {
                name = fromBackingFieldName(name);
                if (get) {
                    addNotifyAccess(code, owner.getField(name));
                    code.next();
                } else {
                    // insert the set operations after the field mutation, but
                    // first load the old value for use in the
                    // StateManager.settingXXX method.
                    loadManagedInstance(code, false);
                    final FieldInstruction fFi = fi;
                    code.getfield().setField(
                        (BCField) AccessController.doPrivileged(J2DoPrivHelper
                            .getFieldInstructionFieldAction(fFi)));
                    int val = code.getNextLocalsIndex();
                    code.xstore().setLocal(val).setType(fi.getFieldType());
View Full Code Here

Examples of serp.bytecode.FieldInstruction

                return null;

            // if the middle instruction was a getfield, then it's the
            // field that's being accessed
            if (!findAccessed && prevIns instanceof GetFieldInstruction) {
                final FieldInstruction fPrevIns = (FieldInstruction) prevIns;
                cur = AccessController.doPrivileged(
                    J2DoPrivHelper.getFieldInstructionFieldAction(fPrevIns));
                // if the middle instruction was an xload_1, then the
                // matched instruction is the field that's being set.
            } else if (findAccessed && prevIns instanceof LoadInstruction
                && ((LoadInstruction) prevIns).getParam() == 0) {
                final FieldInstruction fTemplateIns =
                    (FieldInstruction) templateIns;
                cur = AccessController.doPrivileged(J2DoPrivHelper
                    .getFieldInstructionFieldAction(fTemplateIns));
            } else
                return null;
View Full Code Here

Examples of serp.bytecode.FieldInstruction

     */
    private void replaceAndValidateFieldAccess(Code code, Instruction ins,
        boolean get, Instruction stat) throws NoSuchMethodException {
        code.beforeFirst();

        FieldInstruction fi;
        MethodInstruction mi;
        ClassMetaData owner;
        String name, typeName, methodName;
        while (code.searchForward(ins)) {
            // back up to the matched instruction
            fi = (FieldInstruction) code.previous();
            name = fi.getFieldName();
            typeName = fi.getFieldTypeName();
            owner = getPersistenceCapableOwner(name, fi.getFieldDeclarerType());
            FieldMetaData fmd = owner == null ? null : owner.getField(name);
            if (isPropertyAccess(fmd)) {
                // if we're directly accessing a field in another class
                // hierarchy that uses property access, something is wrong
                if (owner != _meta && owner.getDeclaredField(name) != null &&
                    _meta != null && !owner.getDescribedType()
                        .isAssignableFrom(_meta.getDescribedType()))
                    throw new UserException(_loc.get("property-field-access",
                        new Object[]{ _meta, owner, name,
                            code.getMethod().getName() }));

                // if we're directly accessing a property-backing field outside
                // the property in our own class, notify user
                if (isBackingFieldOfAnotherProperty(name, code))
                    addViolation("property-field-access", new Object[]{ _meta,
                        owner, name, code.getMethod().getName() }, false);
            }

            if (owner == null ||
                owner.getDeclaredField(fromBackingFieldName(name)) == null) {
                // not persistent field?
                code.next();
                continue;
            } else if (!getRedefine() && !getCreateSubclass()
                && isFieldAccess(fmd)) {
                // replace the instruction with a call to the generated access
                // method
                mi = (MethodInstruction) code.set(stat);

                // invoke the proper access method, whether getter or setter
                String prefix = (get) ? PRE + "Get" : PRE + "Set";
                methodName = prefix + name;
                if (get) {
                    mi.setMethod(getType(owner).getName(),
                        methodName, typeName, new String[]
                        { getType(owner).getName() });
                } else {
                    mi.setMethod(getType(owner).getName(),
                        methodName, "void", new String[]
                        { getType(owner).getName(), typeName });
                }
                code.next();
            } else if (getRedefine()) {
                name = fromBackingFieldName(name);
                if (get) {
                    addNotifyAccess(code, owner.getField(name));
                    code.next();
                } else {
                    // insert the set operations after the field mutation, but
                    // first load the old value for use in the
                    // StateManager.settingXXX method.
                    loadManagedInstance(code, false);
                    final FieldInstruction fFi = fi;
                    code.getfield().setField(
                        AccessController.doPrivileged(J2DoPrivHelper
                            .getFieldInstructionFieldAction(fFi)));
                    int val = code.getNextLocalsIndex();
                    code.xstore().setLocal(val).setType(fi.getFieldType());
View Full Code Here

Examples of serp.bytecode.FieldInstruction

                return null;

            // if the middle instruction was a getfield, then it's the
            // field that's being accessed
            if (!findAccessed && prevIns instanceof GetFieldInstruction) {
                final FieldInstruction fPrevIns = (FieldInstruction) prevIns;
                cur = AccessController.doPrivileged(
                    J2DoPrivHelper.getFieldInstructionFieldAction(fPrevIns));
                // if the middle instruction was an xload_1, then the
                // matched instruction is the field that's being set.
            } else if (findAccessed && prevIns instanceof LoadInstruction
                && ((LoadInstruction) prevIns).getParam() == 0) {
                final FieldInstruction fTemplateIns =
                    (FieldInstruction) templateIns;
                cur = AccessController.doPrivileged(J2DoPrivHelper
                    .getFieldInstructionFieldAction(fTemplateIns));
            } else
                return null;
View Full Code Here

Examples of serp.bytecode.FieldInstruction

     */
    private void replaceAndValidateFieldAccess(Code code, Instruction ins,
        boolean get, Instruction stat) throws NoSuchMethodException {
        code.beforeFirst();

        FieldInstruction fi;
        MethodInstruction mi;
        ClassMetaData owner;
        String name, typeName, methodName;
        while (code.searchForward(ins)) {
            // back up to the matched instruction
            fi = (FieldInstruction) code.previous();
            name = fi.getFieldName();
            typeName = fi.getFieldTypeName();
            owner = getPersistenceCapableOwner(name, fi.getFieldDeclarerType());
            FieldMetaData fmd = owner == null ? null : owner.getField(name);
            if (isPropertyAccess(fmd)) {
                // if we're directly accessing a field in another class
                // hierarchy that uses property access, something is wrong
                if (owner != _meta && owner.getDeclaredField(name) != null &&
                    _meta != null && !owner.getDescribedType()
                        .isAssignableFrom(_meta.getDescribedType()))
                    throw new UserException(_loc.get("property-field-access",
                        new Object[]{ _meta, owner, name,
                            code.getMethod().getName() }));

                // if we're directly accessing a property-backing field outside
                // the property in our own class, notify user
                if (isBackingFieldOfAnotherProperty(name, code))
                    addViolation("property-field-access", new Object[]{ _meta,
                        owner, name, code.getMethod().getName() }, false);
            }

            if (owner == null ||
                owner.getDeclaredField(fromBackingFieldName(name)) == null) {
                // not persistent field?
                code.next();
                continue;
            } else if (!getRedefine() && !getCreateSubclass()
                && isFieldAccess(fmd)) {
                // replace the instruction with a call to the generated access
                // method
                mi = (MethodInstruction) code.set(stat);

                // invoke the proper access method, whether getter or setter
                String prefix = (get) ? PRE + "Get" : PRE + "Set";
                methodName = prefix + name;
                if (get) {
                    mi.setMethod(getType(owner).getName(),
                        methodName, typeName, new String[]
                        { getType(owner).getName() });
                } else {
                    mi.setMethod(getType(owner).getName(),
                        methodName, "void", new String[]
                        { getType(owner).getName(), typeName });
                }
                code.next();
            } else if (getRedefine()) {
                name = fromBackingFieldName(name);
                if (get) {
                    addNotifyAccess(code, owner.getField(name));
                    code.next();
                } else {
                    // insert the set operations after the field mutation, but
                    // first load the old value for use in the
                    // StateManager.settingXXX method.
                    loadManagedInstance(code, false);
                    final FieldInstruction fFi = fi;
                    code.getfield().setField(
                        AccessController.doPrivileged(J2DoPrivHelper
                            .getFieldInstructionFieldAction(fFi)));
                    int val = code.getNextLocalsIndex();
                    code.xstore().setLocal(val).setType(fi.getFieldType());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.