List of usage examples for org.objectweb.asm Opcodes GETSTATIC
int GETSTATIC
To view the source code for org.objectweb.asm Opcodes GETSTATIC.
Click Source Link
From source file:de.unisb.cs.st.javalanche.mutation.bytecodeMutations.BytecodeTasks.java
License:Open Source License
/** * Inserts bytecode that prints the given message. * /*from w w w . j a va2s . co m*/ * @param mv * The MethodVisitor for which the code is added. * @param message * The text to be printed to System.out . */ public static void insertPrintStatements(MethodVisitor mv, String message) { mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/System", "err", "Ljava/io/PrintStream;"); mv.visitLdcInsn("[MUTATION] " + message); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V"); }
From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.FieldInstruction.java
License:Open Source License
@Override public String toString() { String type;/* w w w. j av a 2 s . c om*/ switch (getOpcode()) { case Opcodes.PUTSTATIC: type = "PUTSTATIC"; break; case Opcodes.GETSTATIC: type = "GETSTATIC"; break; case Opcodes.GETFIELD: type = "GETFIELD"; break; case Opcodes.PUTFIELD: type = "PUTFIELD"; break; default: assert false; type = "--ERROR--"; break; } StringBuilder sb = new StringBuilder(type.length() + this.ownerInternalClassName.length() + this.fieldName.length() + this.fieldDesc.length() + 3); sb.append(type).append(' ').append(this.ownerInternalClassName).append('.').append(this.fieldName) .append(' ').append(this.fieldDesc); return sb.toString(); }
From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.FieldInstruction2.java
License:Open Source License
@Override public String toString() { String type;/*from w w w . ja va 2s . c om*/ switch (getOpcode()) { case Opcodes.PUTSTATIC: type = "PUTSTATIC"; break; case Opcodes.GETSTATIC: type = "GETSTATIC"; break; case Opcodes.GETFIELD: type = "GETFIELD"; break; case Opcodes.PUTFIELD: type = "PUTFIELD"; break; default: assert false; type = "--ERROR--"; break; } StringBuilder sb = new StringBuilder(type.length() + this.ownerInternalClassName.length() + this.fieldName.length() + this.fieldDesc.length() + 3); sb.append(type).append(' ').append(this.ownerInternalClassName).append(".&&").append(this.fieldName) .append(' ').append(this.fieldDesc); return sb.toString(); }
From source file:de.zib.sfs.instrument.AbstractSfsAdapter.java
License:BSD License
protected static void println(MethodVisitor mv, String string) { // System.err.println(<string>); mv.visitFieldInsn(Opcodes.GETSTATIC, Type.getInternalName(System.class), "err", Type.getDescriptor(PrintStream.class)); mv.visitLdcInsn(string);//from w w w.ja v a 2 s . co m mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(PrintStream.class), "println", Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(String.class)), false); }
From source file:dyco4j.instrumentation.internals.InitTracingMethodVisitor.java
License:BSD License
@Override public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) { this.mv.visitFieldInsn(opcode, owner, name, desc); final char _c = desc.charAt(0); final boolean _longOrDouble = _c == 'J' || _c == 'D'; switch (opcode) { case Opcodes.GETSTATIC: // add 1 or 2 this.stackFrame.push(OTHER); if (_longOrDouble) this.stackFrame.push(OTHER); break;/* w w w . j a v a 2 s . c o m*/ case Opcodes.PUTSTATIC: // remove 1 or 2 this.stackFrame.pop(); if (_longOrDouble) this.stackFrame.pop(); break; case Opcodes.PUTFIELD: // remove 2 or 3 this.stackFrame.pop(); this.stackFrame.pop(); if (_longOrDouble) this.stackFrame.pop(); break; case Opcodes.GETFIELD: // remove 1 add 1 or 2 if (_longOrDouble) this.stackFrame.push(OTHER); } }
From source file:dyco4j.instrumentation.internals.TracingMethodVisitor.java
License:BSD License
@Override public final void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) { if (this.cv.cmdLineOptions.traceFieldAccess) { final Type _fieldType = Type.getType(desc); final String _fieldId = this.cv.getFieldId(name, owner, desc); final boolean _isFieldStatic = opcode == Opcodes.GETSTATIC || opcode == Opcodes.PUTSTATIC; if (opcode == Opcodes.GETSTATIC || opcode == Opcodes.GETFIELD) { if (_isFieldStatic) super.visitInsn(Opcodes.ACONST_NULL); else if (this.thisInitialized) super.visitInsn(Opcodes.DUP); else { super.visitLdcInsn(LoggingHelper.UNINITIALIZED_THIS); super.visitInsn(Opcodes.SWAP); }//from w w w . j av a 2 s . co m super.visitFieldInsn(opcode, owner, name, desc); LoggingHelper.emitLogField(this.mv, _fieldId, _fieldType, Logger.FieldAction.GETF); } else if (opcode == Opcodes.PUTSTATIC || opcode == Opcodes.PUTFIELD) { if (_isFieldStatic) { super.visitInsn(Opcodes.ACONST_NULL); } else if (this.thisInitialized) { LoggingHelper.emitSwapTwoWordsAndOneWord(this.mv, _fieldType); final int _fieldSort = _fieldType.getSort(); if (_fieldSort == Type.LONG || _fieldSort == Type.DOUBLE) super.visitInsn(Opcodes.DUP_X2); else super.visitInsn(Opcodes.DUP_X1); } else { super.visitLdcInsn(LoggingHelper.UNINITIALIZED_THIS); } LoggingHelper.emitSwapOneWordAndTwoWords(this.mv, _fieldType); LoggingHelper.emitLogField(this.mv, _fieldId, _fieldType, Logger.FieldAction.PUTF); super.visitFieldInsn(opcode, owner, name, desc); } } else super.visitFieldInsn(opcode, owner, name, desc); }
From source file:dyco4j.instrumentation.LoggingHelper.java
License:BSD License
public static void emitLogArray(final MethodVisitor mv, final Logger.ArrayAction action) { final Type _a = Type.getType(Logger.ArrayAction.class); final String _name = action.toString(); mv.visitFieldInsn(Opcodes.GETSTATIC, _a.getInternalName(), _name, _a.getDescriptor()); emitInvokeLog(mv, LOG_ARRAY);/*from w ww.j ava 2 s . c om*/ }
From source file:dyco4j.instrumentation.LoggingHelper.java
License:BSD License
public static void emitLogField(final MethodVisitor mv, final String fieldName, final Type fieldType, final Logger.FieldAction action) { final int _fieldSort = fieldType.getSort(); if (_fieldSort == Type.LONG || _fieldSort == Type.DOUBLE) { mv.visitInsn(Opcodes.DUP2_X1);//from w ww. ja v a2 s . c om } else { mv.visitInsn(Opcodes.DUP_X1); } emitConvertToString(mv, fieldType); mv.visitLdcInsn(fieldName); final Type _a = Type.getType(Logger.FieldAction.class); final String _name = action.toString(); mv.visitFieldInsn(Opcodes.GETSTATIC, _a.getInternalName(), _name, _a.getDescriptor()); emitInvokeLog(mv, LOG_FIELD); }
From source file:edu.mit.streamjit.util.bytecode.MethodResolver.java
License:Open Source License
private void interpret(FieldInsnNode insn, FrameState frame, BBInfo block) { Klass k = getKlassByInternalName(insn.owner); Field f = k.getField(insn.name); switch (insn.getOpcode()) { case Opcodes.GETSTATIC: LoadInst li = new LoadInst(f); block.block.instructions().add(li); frame.stack.push(li);/*from w w w.ja va2s. co m*/ break; case Opcodes.GETFIELD: LoadInst li2 = new LoadInst(f, frame.stack.pop()); block.block.instructions().add(li2); frame.stack.push(li2); break; case Opcodes.PUTSTATIC: StoreInst si = new StoreInst(f, frame.stack.pop()); block.block.instructions().add(si); break; case Opcodes.PUTFIELD: StoreInst si2 = new StoreInst(f, frame.stack.pop(), frame.stack.pop()); block.block.instructions().add(si2); break; default: throw new UnsupportedOperationException("" + insn.getOpcode()); } }
From source file:edu.mit.streamjit.util.bytecode.MethodUnresolver.java
License:Open Source License
private void emit(LoadInst i, InsnList insns) { Value location = i.getLocation();/*www. ja v a 2 s .c o m*/ if (location instanceof LocalVariable) { load(location, insns); store(i, insns); } else { Field f = (Field) location; if (!f.isStatic()) load(i.getInstance(), insns); insns.add(new FieldInsnNode(f.isStatic() ? Opcodes.GETSTATIC : Opcodes.GETFIELD, internalName(f.getParent()), f.getName(), f.getType().getFieldType().getDescriptor())); store(i, insns); } }