org.objectweb.asm.tree.FieldInsnNode.getOpcode()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中org.objectweb.asm.tree.FieldInsnNode.getOpcode()方法的一些代码示例,展示了FieldInsnNode.getOpcode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FieldInsnNode.getOpcode()方法的具体详情如下:
包路径:org.objectweb.asm.tree.FieldInsnNode
类名称:FieldInsnNode
方法名:getOpcode

FieldInsnNode.getOpcode介绍

暂无

代码示例

代码示例来源:origin: Sable/soot

private void convertFieldInsn(FieldInsnNode insn) {
 int op = insn.getOpcode();
 if (op == GETSTATIC || op == GETFIELD) {
  convertGetFieldInsn(insn);
 } else {
  convertPutFieldInsn(insn);
 }
}

代码示例来源:origin: jooby-project/jooby

if (finsn.getOpcode() == GETSTATIC) {
 java.lang.reflect.Type possibleEnum = loadType(loader, finsn.owner);
 if (MoreTypes.getRawType(possibleEnum).isEnum()) {

代码示例来源:origin: Sable/soot

Value val;
SootFieldRef ref;
if (insn.getOpcode() == GETSTATIC) {
 ref = Scene.v().makeFieldRef(declClass, insn.name, type, true);
 val = Jimple.v().newStaticFieldRef(ref);
opr = out[0];
type = opr.<FieldRef>value().getFieldRef().type();
if (insn.getOpcode() == GETFIELD) {
 frame.mergeIn(pop());

代码示例来源:origin: Sable/soot

private void convertPutFieldInsn(FieldInsnNode insn) {
 boolean instance = insn.getOpcode() == PUTFIELD;
 StackFrame frame = getFrame(insn);
 Operand[] out = frame.out();

代码示例来源:origin: org.lwjgl.lwjgl/lwjgl_util

private static InsnList generateAddressInstructions(final FieldInsnNode fieldInsn) {
  if ( !"J".equals(fieldInsn.desc) )
    throw new IllegalStateException();
  if ( fieldInsn.getOpcode() == GETFIELD ) // do not change a thing
    return null;
  if ( fieldInsn.getOpcode() == PUTFIELD )
    throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name);
  throw new InternalError();
}

代码示例来源:origin: stackoverflow.com

private boolean methodMutatesField(List<MethodNode> methods, FieldNode field, ClassNode fieldOwner) {

  for(MethodNode methodNode : methods) {
    Iterator<AbstractInsnNode> instructionIterator = methodNode.instructions.iterator();

    while (instructionIterator.hasNext()) {
      AbstractInsnNode abstractInsNode = instructionIterator.next();

      if(abstractInsNode.getType() != AbstractInsnNode.FIELD_INSN) {  
        continue;
      } 

      FieldInsnNode fieldInsnNode = (FieldInsnNode) abstractInsNode;

      if(fieldInsnNode.getOpcode() != Opcodes.PUTFIELD) {
        continue;
      }

      if(fieldInsnNode.name.equals(field.name) && fieldInsnNode.owner.equals(fieldOwner.name)) {
        return true;
      }
    }
  }

  return false;
}

代码示例来源:origin: org.lwjgl.lwjgl/lwjgl_util

private static InsnList generateSIZEOFInstructions(final FieldInsnNode fieldInsn, final MappedSubtypeInfo mappedSubtype) {
  if ( !"I".equals(fieldInsn.desc) )
    throw new InternalError();
  final InsnList list = new InsnList();
  if ( fieldInsn.getOpcode() == GETSTATIC ) {
    list.add(getIntNode(mappedSubtype.sizeof));
    return list;
  }
  if ( fieldInsn.getOpcode() == PUTSTATIC )
    throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name);
  throw new InternalError();
}

代码示例来源:origin: EvoSuite/evosuite

@Override
protected AbstractInsnNode transformFieldInsnNode(MethodNode mn,
    FieldInsnNode fieldNode) {
  // This handles the else branch for field assignments
  if (DescriptorMapping.getInstance().isTransformedOrBooleanField(this.booleanTestabilityTransformation.className,
                                  fieldNode.name,
                                  fieldNode.desc)) {
    if (fieldNode.getNext() instanceof FieldInsnNode) {
      FieldInsnNode other = (FieldInsnNode) fieldNode.getNext();
      if (fieldNode.owner.equals(other.owner)
          && fieldNode.name.equals(other.name)
          && fieldNode.desc.equals(other.desc)) {
        if (fieldNode.getOpcode() == Opcodes.GETFIELD
            && other.getOpcode() == Opcodes.PUTFIELD) {
          this.booleanTestabilityTransformation.insertGetBefore(other, mn.instructions);
        } else if (fieldNode.getOpcode() == Opcodes.GETSTATIC
            && other.getOpcode() == Opcodes.PUTSTATIC) {
          this.booleanTestabilityTransformation.insertGetBefore(other, mn.instructions);
        }
      }
    }
  }
  return fieldNode;
}

代码示例来源:origin: EvoSuite/evosuite

/**
 * <p>
 * getInfectionDistance
 * </p>
 * 
 * @param original
 *            a {@link org.objectweb.asm.tree.FieldInsnNode} object.
 * @param mutant
 *            a {@link org.objectweb.asm.tree.InsnList} object.
 * @return a {@link org.objectweb.asm.tree.InsnList} object.
 */
public InsnList getInfectionDistance(FieldInsnNode original, InsnList mutant) {
  InsnList distance = new InsnList();
  if (original.getOpcode() == Opcodes.GETFIELD)
    distance.add(new InsnNode(Opcodes.DUP)); //make sure to re-load this for GETFIELD
  distance.add(new FieldInsnNode(original.getOpcode(), original.owner,
      original.name, original.desc));
  Type type = Type.getType(original.desc);
  if (type.getDescriptor().startsWith("L") || type.getDescriptor().startsWith("[")) {
    ReplaceVariable.addReferenceDistanceCheck(distance, type, mutant);
  } else {
    ReplaceVariable.addPrimitiveDistanceCheck(distance, type, mutant);
  }
  return distance;
}

代码示例来源:origin: org.lwjgl.lwjgl/lwjgl_util

private static InsnList generateSetViewInstructions(final FieldInsnNode fieldInsn) {
  if ( fieldInsn.getOpcode() == GETFIELD )
    throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name);
  if ( fieldInsn.getOpcode() != PUTFIELD )
    throw new InternalError();
  final InsnList list = new InsnList();
  // stack: index, this
  if ( MAPPED_SET2_JVM.equals(fieldInsn.owner) )
    list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "put_views", "(L" + MAPPED_SET2_JVM + ";I)V"));
  else if ( MAPPED_SET3_JVM.equals(fieldInsn.owner) )
    list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "put_views", "(L" + MAPPED_SET3_JVM + ";I)V"));
  else if ( MAPPED_SET4_JVM.equals(fieldInsn.owner) )
    list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "put_views", "(L" + MAPPED_SET4_JVM + ";I)V"));
  else
    throw new InternalError();
  // stack: -
  return list;
}

代码示例来源:origin: EvoSuite/evosuite

if (insn instanceof FieldInsnNode) {
  FieldInsnNode fieldInsn = (FieldInsnNode) insn;
  if (fieldInsn.getOpcode() != Opcodes.PUTSTATIC) {
    continue;

代码示例来源:origin: com.android.tools.lint/lint-checks

private void checkInstructionInternal(ClassContext context, ClassNode classNode,
    AbstractInsnNode instruction) {
  FieldInsnNode node = (FieldInsnNode) instruction;
  if (node.getOpcode() == Opcodes.PUTSTATIC
      && node.owner.equals(FQN_CORDOVA_DEVICE)
      && node.name.equals(FIELD_NAME_CORDOVA_VERSION)) {
    AbstractInsnNode prevInstruction = LintUtils.getPrevInstruction(node);
    if (prevInstruction == null || prevInstruction.getOpcode() != Opcodes.LDC) {
      return;
    }
    LdcInsnNode ldcInsnNode = (LdcInsnNode) prevInstruction;
    if (ldcInsnNode.cst instanceof String) {
      mCordovaVersion = createVersion((String) ldcInsnNode.cst);
      if (mCordovaVersion != null) {
        validateCordovaVersion(context, mCordovaVersion,
            context.getLocation(classNode));
      }
    }
  }
}

代码示例来源:origin: EvoSuite/evosuite

/**
 * Descend into a static field read
 * 
 */
private static void handleFieldInsnNode(GetStaticGraph staticUsageTree,
    ClassNode cn, MethodNode mn, FieldInsnNode insn, int depth) {
  // Skip field instructions that are not reads to static fields
  if (insn.getOpcode() != Opcodes.GETSTATIC) {
    return;
  }
  // Only collect relations for instrumentable classes
  String calleeClassName = insn.owner.replaceAll("/", ".");
  if (BytecodeInstrumentation.checkIfCanInstrument(calleeClassName)) {
    logger.debug("Handling field read: " + insn.name);
    if (!staticUsageTree.hasStaticFieldRead(cn.name, mn.name + mn.desc,
        insn.owner, insn.name)) {
      handleClassInitializer(staticUsageTree, cn, mn, insn.owner,
          depth);
      // Add static read from mn to insn to static usage graph
      staticUsageTree.addStaticFieldRead(cn.name, mn.name + mn.desc,
          insn.owner, insn.name);
      handle(staticUsageTree, insn.owner, insn.name + insn.desc,
          depth);
    }
  }
}

代码示例来源:origin: EvoSuite/evosuite

/** {@inheritDoc} */
@Override
public List<Mutation> apply(MethodNode mn, String className, String methodName,
    BytecodeInstruction instruction, Frame frame) {
  List<Mutation> mutations = new LinkedList<Mutation>();
  FieldInsnNode node = (FieldInsnNode) instruction.getASMNode();
  Type fieldType = Type.getType(node.desc);
  // insert mutation into bytecode with conditional
  InsnList mutation = new InsnList();
  logger.debug("Mutation deletefield for statement " + node.name + node.desc);
  if (node.getOpcode() == Opcodes.GETFIELD) {
    logger.debug("Deleting source of type " + node.owner);
    mutation.add(new InsnNode(Opcodes.POP));
  }
  mutation.add(getDefault(fieldType));
  // insert mutation into pool
  Mutation mutationObject = MutationPool.addMutation(className,
                            methodName,
                            NAME + " " + node.name
                                + node.desc,
                            instruction,
                            mutation,
                            getInfectionDistance(node,
                                      mutation));
  mutations.add(mutationObject);
  return mutations;
}

代码示例来源:origin: EvoSuite/evosuite

if (fieldNode.getOpcode() == Opcodes.PUTFIELD
    || fieldNode.getOpcode() == Opcodes.PUTSTATIC) {
  MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC,
      Type.getInternalName(BooleanHelper.class), "intToBoolean",

代码示例来源:origin: EvoSuite/evosuite

distance.add(new FieldInsnNode(node.getOpcode(), node.owner, node.name,
    node.desc));
if (type.getDescriptor().startsWith("L")

代码示例来源:origin: org.lwjgl.lwjgl/lwjgl_util

private static InsnList generateFieldInstructions(final FieldInsnNode fieldInsn, final FieldInfo field) {
  final InsnList list = new InsnList();
  if ( fieldInsn.getOpcode() == PUTFIELD ) {
    // stack: value, ref
    list.add(getIntNode((int)field.offset));
    // stack: fieldOffset, value, ref
    list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "put", "(L" + MAPPED_OBJECT_JVM + ";" + fieldInsn.desc + "I)V"));
    // stack -
    return list;
  }
  if ( fieldInsn.getOpcode() == GETFIELD ) {
    // stack: ref
    list.add(getIntNode((int)field.offset));
    // stack: fieldOffset, ref
    list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "get", "(L" + MAPPED_OBJECT_JVM + ";I)" + fieldInsn.desc));
    // stack: -
    return list;
  }
  throw new InternalError();
}

代码示例来源:origin: org.lwjgl.lwjgl/lwjgl_util

private static InsnList generateByteBufferInstructions(final FieldInsnNode fieldInsn, final MappedSubtypeInfo mappedSubtype, final long fieldOffset) {
  if ( fieldInsn.getOpcode() == PUTFIELD )
    throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name);
  if ( fieldInsn.getOpcode() == GETFIELD ) {
    final InsnList list = new InsnList();
    // stack: ref
    list.add(new FieldInsnNode(GETFIELD, mappedSubtype.className, "viewAddress", "J"));
    // stack: long
    list.add(new LdcInsnNode(fieldOffset));
    // stack: long, long
    list.add(new InsnNode(LADD));
    // stack: long
    list.add(new LdcInsnNode(mappedSubtype.fields.get(fieldInsn.name).length));
    // stack: long, long
    list.add(new InsnNode(L2I));
    // stack: int, long
    list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "newBuffer", "(JI)L" + jvmClassName(ByteBuffer.class) + ";"));
    // stack: buffer
    return list;
  }
  throw new InternalError();
}

代码示例来源:origin: EvoSuite/evosuite

} else if (node instanceof FieldInsnNode) {
  FieldInsnNode fn = (FieldInsnNode) node;
  copy.add(new FieldInsnNode(fn.getOpcode(), fn.owner, fn.name, fn.desc));
} else if (node instanceof InsnNode) {
  if (node.getOpcode() != Opcodes.POP)

代码示例来源:origin: org.lwjgl.lwjgl/lwjgl_util

if ( fieldInsn.getOpcode() == GETFIELD ) {
  if ( mappedSubtype.sizeof_shift != 0 ) {
if ( fieldInsn.getOpcode() == PUTFIELD ) {
  if ( mappedSubtype.sizeof_shift != 0 ) {

相关文章

微信公众号

最新文章

更多