Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.FieldInsnNode


    private void verifyAccess(InstructionGraphNode node) {
        switch (node.getInstruction().getOpcode()) {
            case GETFIELD:
            case GETSTATIC:
                FieldInsnNode field = (FieldInsnNode) node.getInstruction();
                Checks.ensure(!isPrivateField(field.owner, field.name),
                        "Rule method '%s' contains an illegal access to private field '%s'.\n" +
                                "Mark the field protected or package-private if you want to prevent public access!",
                        method.name, field.name);
                break;
View Full Code Here


        "java/lang/Object"));
  }

  @Test
  public void testFieldInsn() {
    testInstructionBetweenFrames(new FieldInsnNode(Opcodes.GETFIELD, "Foo",
        "f", "I"));
  }
View Full Code Here

            case IF_ACMPNE:
                expected1 = BasicValue.REFERENCE_VALUE;
                expected2 = BasicValue.REFERENCE_VALUE;
                break;
            case PUTFIELD:
                FieldInsnNode fin = (FieldInsnNode) insn;
                expected1 = newValue(Type.getObjectType(fin.owner));
                expected2 = newValue(Type.getType(fin.desc));
                break;
            default:
                throw new Error("Internal error.");
View Full Code Here

            case IF_ACMPNE:
                expected1 = BasicValue.REFERENCE_VALUE;
                expected2 = BasicValue.REFERENCE_VALUE;
                break;
            case PUTFIELD:
                FieldInsnNode fin = (FieldInsnNode) insn;
                expected1 = newValue(Type.getObjectType(fin.owner));
                expected2 = newValue(Type.getType(fin.desc));
                break;
            default:
                throw new Error("Internal error.");
View Full Code Here

        }
        case JSR:
            throw new UnsupportedOperationException(
                    "Do not support instruction types JSR - Deprecated in Java 6");
        case GETSTATIC: {
            final FieldInsnNode f = (FieldInsnNode) insn;
            return new StaticField(f.owner, f.name, f.desc);
        }
        case NEW: {
            final TypeInsnNode type = (TypeInsnNode) insn;
            return new ObjectRef(Type.getObjectType(type.desc));
View Full Code Here

        case DRETURN:
        case ARETURN:
        case PUTSTATIC:
            return null;
        case GETFIELD: {
            final FieldInsnNode f = (FieldInsnNode) insn;
            return new ObjectField(f.owner, f.name, f.desc, value);
        }
        case NEWARRAY: {
            final IntInsnNode iinsn = (IntInsnNode) insn;
            switch (iinsn.operand) {
View Full Code Here

        case Opcodes.RETURN:
        case Opcodes.GETSTATIC:
            super.execute(insn, interpreter);
            break;
        case Opcodes.PUTSTATIC: {
            final FieldInsnNode f = (FieldInsnNode) insn;
            variable = new StaticField(f.owner, f.name, f.desc);
            defs = Collections.singleton(variable);
            uses = pop().getVariables();
            break;
        }
        case Opcodes.GETFIELD:
            super.execute(insn, interpreter);
            break;
        case Opcodes.PUTFIELD: {
            final FieldInsnNode f = (FieldInsnNode) insn;
            value2 = pop();
            value1 = pop();
            variable = new ObjectField(f.owner, f.name, f.desc, value1);
            defs = Collections.singleton(variable);
            uses = new LinkedHashSet<Variable>();
View Full Code Here

      case RETURN_VOID:
        break;
       
      /** pushes some static field variable to the stack */
      case GETSTATIC: {
        final FieldInsnNode f = (FieldInsnNode) instruction.getInstruction();
        final StaticField field = new StaticField(f.owner, f.name, f.desc);
        stack.push(field);
        fields.add(field);
        break;
      }
     
      /** pops one operand (..., value) and store to a static field variable.
        * this is a definition of that variable */
      case PUTSTATIC: {
        final FieldInsnNode f = (FieldInsnNode) instruction.getInstruction();
        final ValueRef value = stack.pop();
       
        /* new frame to indicate definition of static variable
         * and use of the value in top of the stack */
        final StaticField definition = new StaticField(f.owner, f.name, f.desc);
        frame = new DefUseFrame(definition, value);
       
        if (value instanceof ArrayRef) {
         
          final BytecodeInstruction arraydef =
              new BytecodeInstruction(new InsnNode(Opcodes.NOP));
         
          final List<VariableRef> uses = Collections.emptyList();
          arraydef.frame = new DefUseFrame(new ArrayComponent(definition), uses);
         
          node.instructions.add(idx + 1, arraydef);
        }
       
        break;
      }
     
      /** pops one operand (..., object reference) and
        * pushes a object field variable to the stack */
      case GETFIELD: {
        final FieldInsnNode f = (FieldInsnNode) instruction.getInstruction();
        final ValueRef objectref = stack.pop();
        final ObjectField field = new ObjectField(f.owner, f.name, f.desc, objectref);
        stack.push(field);
       
        ValueRef root = objectref;
        while (root instanceof ObjectField) {
          root = ObjectField.class.cast(root).objectref;
        }
       
        if (root instanceof Local || root instanceof StaticField) {
          fields.add(field);
        }
        break;
      }
     
      /** pops two operands (..., object reference, value) and
        * store value to a object field variable.
        * this is a definition of that variable */
      case PUTFIELD: {
        final FieldInsnNode f = (FieldInsnNode) instruction.getInstruction();
        final ValueRef value = stack.pop();
        final ValueRef objectref = stack.pop();
       
        ValueRef root = objectref;
        while (root instanceof ObjectField) {
View Full Code Here

            case IF_ACMPNE:
                expected1 = BasicValue.REFERENCE_VALUE;
                expected2 = BasicValue.REFERENCE_VALUE;
                break;
            case PUTFIELD:
                FieldInsnNode fin = (FieldInsnNode) insn;
                expected1 = newValue(Type.getObjectType(fin.owner));
                expected2 = newValue(Type.getType(fin.desc));
                break;
            default:
                throw new Error("Internal error.");
View Full Code Here

        assertEquals("([[LB1;LC1;LD1;)LC1;", cn.outerMethodDesc);
       
        MethodNode mn0 = (MethodNode) cn.methods.get(0);
        Iterator it = mn0.instructions.iterator();
       
        FieldInsnNode n0 = (FieldInsnNode) it.next();
        assertEquals("D1", n0.owner);
        assertEquals("LB1;", n0.desc);
       
        assertEquals(Type.getType("LB1;"), ((LdcInsnNode) it.next()).cst);
        assertEquals(Type.getType("[LD1;"), ((LdcInsnNode) it.next()).cst);
View Full Code Here

TOP

Related Classes of org.objectweb.asm.tree.FieldInsnNode

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.