本文整理匯總了Java中org.objectweb.asm.Opcodes.PUTFIELD屬性的典型用法代碼示例。如果您正苦於以下問題:Java Opcodes.PUTFIELD屬性的具體用法?Java Opcodes.PUTFIELD怎麽用?Java Opcodes.PUTFIELD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.objectweb.asm.Opcodes
的用法示例。
在下文中一共展示了Opcodes.PUTFIELD屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitFieldInsn
@Override
public void visitFieldInsn(final int opcode, final String owner,
final String name, final String desc) {
switch (opcode) {
case Opcodes.GETSTATIC:
getstatic(owner, name, desc);
break;
case Opcodes.PUTSTATIC:
putstatic(owner, name, desc);
break;
case Opcodes.GETFIELD:
getfield(owner, name, desc);
break;
case Opcodes.PUTFIELD:
putfield(owner, name, desc);
break;
default:
throw new IllegalArgumentException();
}
}
示例2: visitFieldInsn
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
DexField field = application.getField(owner, name, desc);
switch (opcode) {
case Opcodes.GETFIELD:
registry.registerInstanceFieldRead(field);
break;
case Opcodes.PUTFIELD:
registry.registerInstanceFieldWrite(field);
break;
case Opcodes.GETSTATIC:
registry.registerStaticFieldRead(field);
break;
case Opcodes.PUTSTATIC:
registry.registerStaticFieldWrite(field);
break;
default:
throw new Unreachable("Unexpected opcode " + opcode);
}
}
示例3: updateState
private void updateState(FieldInsnNode insn) {
Type type = Type.getType(insn.desc);
switch (insn.getOpcode()) {
case Opcodes.GETSTATIC:
state.push(type);
break;
case Opcodes.PUTSTATIC:
state.pop();
break;
case Opcodes.GETFIELD: {
state.pop(JarState.OBJECT_TYPE);
state.push(type);
break;
}
case Opcodes.PUTFIELD: {
state.pop();
state.pop(JarState.OBJECT_TYPE);
break;
}
default:
throw new Unreachable("Unexpected FieldInsn opcode: " + insn.getOpcode());
}
}
示例4: visitFieldInsn
/**
* Imports field instructions (put and get), both for static and instance
* fields.
*
* @param opcode Opcode.
* @param owner Class containing the field.
* @param name Name of field.
* @param desc Type descriptor of field.
*/
@Override
public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) {
Field f = ClassNode.getClass(owner).getField(name, desc);
if(((opcode == Opcodes.GETSTATIC) || (opcode == Opcodes.PUTSTATIC)) !=
f.getModifiers().contains(Modifier.STATIC)) {
throw new RuntimeException("Field staticness conflicts with instruction");
}
switch(opcode) {
// Loads
case Opcodes.GETSTATIC:
case Opcodes.GETFIELD: createFieldRead(f); break;
// Stores
case Opcodes.PUTSTATIC:
case Opcodes.PUTFIELD: createFieldWrite(f); break;
}
}
示例5: binaryOperation
@Override
public BasicValue binaryOperation(final AbstractInsnNode insn,
final BasicValue value1, final BasicValue value2) throws AnalyzerException {
/*
* We're looking for the assignment of a local holder objectref to a member variable.
* If we spot that, then the local holder can't be replaced, since we don't (yet)
* have the mechanics to replace the member variable with the holder's members or
* to assign all of them when this happens.
*/
if (insn.getOpcode() == Opcodes.PUTFIELD) {
if (value2.isReference() && (value1 instanceof ReplacingBasicValue)) {
final ReplacingBasicValue possibleThis = (ReplacingBasicValue) value1;
if (possibleThis.isThis() && (value2 instanceof ReplacingBasicValue)) {
// if this is a reference for a holder class, we can't replace it
if (HOLDERS.get(value2.getType().getDescriptor()) != null) {
final ReplacingBasicValue localRef = (ReplacingBasicValue) value2;
localRef.setAssignedToMember();
}
}
}
}
return super.binaryOperation(insn, value1, value2);
}
示例6: visitFieldInsn
/** {@inheritDoc} */
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
if (opcode == Opcodes.PUTFIELD && className.equals(owner)) {
if (lastInstructionIsInitConstant && possibleFields.contains(name)) {
positiveFields.add(name);
}
possibleFields.remove(name);
lastInstructionIsInitConstant = false;
}
}
示例7: patchNodes
private boolean patchNodes(MethodNode method) {
InsnList list = method.instructions;
boolean patched = false;
boolean foundUrl = false;
for(int i = 0; i < list.size(); i++) {
AbstractInsnNode node = list.get(i);
if(node instanceof LdcInsnNode) {
LdcInsnNode ldc = (LdcInsnNode)node;
if(ldc.cst instanceof String && isUrl((String)ldc.cst)) {
foundUrl = true;
}
} else if(foundUrl && (node.getOpcode() == Opcodes.PUTFIELD || node.getOpcode() == Opcodes.ASTORE)) {
list.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC,
"guichaguri/skinfixer/SkinWorker", "getURL", "(Ljava/lang/String;)Ljava/lang/String;", false));
foundUrl = false;
patched = true;
}
}
return patched;
}
示例8: addInsn
public void addInsn(String name, InstructionModifier mv, int opcode) {
switch (opcode) {
case Opcodes.GETFIELD:
addKnownInsn(name, mv, Opcodes.ILOAD);
return;
case Opcodes.PUTFIELD:
addKnownInsn(name, mv, Opcodes.ISTORE);
}
}
示例9: visitFieldInsn
public void visitFieldInsn(int opcode, String owner, String fieldName,
String desc) {
if (firstInstruction)
addInc();
if (logPointerChange && opcode == Opcodes.PUTFIELD
&& desc.charAt(0) == 'L') {
if (constructor && !doneSuperConstructor && name.equals(owner)
&& finalFields.contains(fieldName))
delayedFieldPointer.put(fieldName, desc);
else {
// instrument reference changes from
// putfield ...,obj,v' => ...
// to
// dup2 ...,obj,v' => ...,obj,v',obj,v'
// swap ...,obj,v',obj,v' => ...,obj,v',v',obj
// dup ...,obj,v',v',obj => ...,obj,v',v',obj,obj
// getfield ...,obj,v',v',obj,obj => ...,obj,v',v',obj,v
// invokespecial
// pointerchangelog(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
// ...,obj,v',v',obj,v => ...,obj,v'
// putfield ...,obj,v' =>
super.visitInsn(Opcodes.DUP2);
super.visitInsn(Opcodes.SWAP);
super.visitInsn(Opcodes.DUP);
super.visitFieldInsn(Opcodes.GETFIELD, owner, fieldName,
desc);
super.visitMethodInsn(Opcodes.INVOKESTATIC, name,
LOG_INTERNAL_POINTER_CHANGE,
POINTER_CHANGE_SIGNATURE);
}
} else if (logPointerChange && opcode == Opcodes.PUTSTATIC
&& desc.charAt(0) == 'L') {
// if (finalFields.contains(fieldName)) {
// // assume field is initially null
// super.visitInsn(Opcodes.DUP);
// } else {
// instrument reference changes from
// putstatic ...,v' => ...
// to
// dup ...,v' => ...,v',v'
// ldc owner.class ...,v',v' => ...,v',v',k
// getstatic ...,v',v',k => ...,v',v',k,v
// invokespecial
// staticpointerchangelog(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/Object;)V
// ...,v',v',k,v => ...,v'
super.visitInsn(Opcodes.DUP);
super.visitLdcInsn(Type.getObjectType(owner));
super.visitFieldInsn(Opcodes.GETSTATIC, owner, fieldName, desc);
super.visitMethodInsn(Opcodes.INVOKESTATIC, name,
LOG_INTERNAL_STATIC_POINTER_CHANGE,
STATIC_POINTER_CHANGE_SIGNATURE);
// }
}
super.visitFieldInsn(opcode, owner, fieldName, desc);
}
示例10: visitFieldInsn
public void visitFieldInsn(int opcode, String owner, String name,
String desc) {
if (opcode == Opcodes.PUTFIELD && LineNumberReader.this.name.equals(owner)
&& !lines.containsKey(name) && line != -1) {
lines.put(name, line);
}
}
示例11: canThrow
private boolean canThrow(AbstractInsnNode insn) {
switch (insn.getOpcode()) {
case Opcodes.AALOAD:
case Opcodes.AASTORE:
case Opcodes.ANEWARRAY:
// ARETURN does not throw in its dex image.
case Opcodes.ARRAYLENGTH:
case Opcodes.ATHROW:
case Opcodes.BALOAD:
case Opcodes.BASTORE:
case Opcodes.CALOAD:
case Opcodes.CASTORE:
case Opcodes.CHECKCAST:
case Opcodes.DALOAD:
case Opcodes.DASTORE:
// DRETURN does not throw in its dex image.
case Opcodes.FALOAD:
case Opcodes.FASTORE:
// FRETURN does not throw in its dex image.
case Opcodes.GETFIELD:
case Opcodes.GETSTATIC:
case Opcodes.IALOAD:
case Opcodes.IASTORE:
case Opcodes.IDIV:
case Opcodes.INSTANCEOF:
case Opcodes.INVOKEDYNAMIC:
case Opcodes.INVOKEINTERFACE:
case Opcodes.INVOKESPECIAL:
case Opcodes.INVOKESTATIC:
case Opcodes.INVOKEVIRTUAL:
case Opcodes.IREM:
// IRETURN does not throw in its dex image.
case Opcodes.LALOAD:
case Opcodes.LASTORE:
case Opcodes.LDIV:
case Opcodes.LREM:
// LRETURN does not throw in its dex image.
case Opcodes.MONITORENTER:
case Opcodes.MONITOREXIT:
case Opcodes.MULTIANEWARRAY:
case Opcodes.NEW:
case Opcodes.NEWARRAY:
case Opcodes.PUTFIELD:
case Opcodes.PUTSTATIC:
// RETURN does not throw in its dex image.
case Opcodes.SALOAD:
case Opcodes.SASTORE:
return true;
case Opcodes.LDC: {
// const-class and const-string* may throw in dex.
LdcInsnNode ldc = (LdcInsnNode) insn;
return ldc.cst instanceof String || ldc.cst instanceof Type;
}
default:
return false;
}
}