List of usage examples for org.objectweb.asm Opcodes ACONST_NULL
int ACONST_NULL
To view the source code for org.objectweb.asm Opcodes ACONST_NULL.
Click Source Link
From source file:org.elasticsearch.plan.a.Writer.java
License:Apache License
@Override public Void visitDeclvar(final DeclvarContext ctx) { final ExpressionMetadata declvaremd = metadata.getExpressionMetadata(ctx); final org.objectweb.asm.Type type = declvaremd.to.type; final Sort sort = declvaremd.to.sort; final int slot = (int) declvaremd.postConst; final ExpressionContext exprctx = ctx.expression(); final boolean initialize = exprctx == null; if (!initialize) { visit(exprctx);/* ww w . j a v a 2 s.c om*/ } switch (sort) { case VOID: throw new IllegalStateException(error(ctx) + "Unexpected writer state."); case BOOL: case BYTE: case SHORT: case CHAR: case INT: if (initialize) execute.push(0); break; case LONG: if (initialize) execute.push(0L); break; case FLOAT: if (initialize) execute.push(0.0F); break; case DOUBLE: if (initialize) execute.push(0.0); break; default: if (initialize) execute.visitInsn(Opcodes.ACONST_NULL); } execute.visitVarInsn(type.getOpcode(Opcodes.ISTORE), slot); return null; }
From source file:org.elasticsearch.plan.a.Writer.java
License:Apache License
@Override public Void visitNull(final NullContext ctx) { final ExpressionMetadata nullemd = metadata.getExpressionMetadata(ctx); execute.visitInsn(Opcodes.ACONST_NULL); checkWriteCast(nullemd);/*from w w w . jav a 2s. c o m*/ checkWriteBranch(ctx); return null; }
From source file:org.evosuite.instrumentation.coverage.DefUseInstrumentation.java
License:Open Source License
private void addCallingObjectInstrumentation(boolean staticContext, InsnList instrumentation) { // the object on which the DU is covered is passed by the // instrumentation. // If we are in a static context, null is passed instead if (staticContext) { instrumentation.add(new InsnNode(Opcodes.ACONST_NULL)); } else {/*from www . java2s . c o m*/ instrumentation.add(new VarInsnNode(Opcodes.ALOAD, 0)); // "this" } }
From source file:org.evosuite.instrumentation.coverage.DefUseInstrumentation.java
License:Open Source License
private void addObjectInstrumentation(BytecodeInstruction instruction, InsnList instrumentation, MethodNode mn) {/*ww w . jav a 2 s. co m*/ if (instruction.isLocalVariableDefinition()) { if (instruction.getASMNode().getOpcode() == Opcodes.ALOAD) { instrumentation.add(new InsnNode(Opcodes.DUP)); } else { instrumentation.add(new InsnNode(Opcodes.ACONST_NULL)); } } else if (instruction.isLocalVariableUse()) { if (instruction.getASMNode().getOpcode() == Opcodes.ASTORE) { instrumentation.add(new InsnNode(Opcodes.DUP)); } else { instrumentation.add(new InsnNode(Opcodes.ACONST_NULL)); } } else if (instruction.isArrayStoreInstruction()) { // Object, index, value instrumentation.add(new InsnNode(Opcodes.DUP)); // } else if(instruction.isArrayLoadInstruction()) { // instrumentation.add(new InsnNode(Opcodes.DUP)); } else if (instruction.isFieldNodeDU()) { // TODO: FieldNodeDU takes care of ArrayStore - why? Type type = Type.getType(instruction.getFieldType()); if (type.getSort() == Type.OBJECT) { instrumentation.add(new InsnNode(Opcodes.DUP)); } else { instrumentation.add(new InsnNode(Opcodes.ACONST_NULL)); } } else if (instruction.isMethodCall()) { Type type = Type.getReturnType(instruction.getMethodCallDescriptor()); if (type.getSort() == Type.OBJECT) { instrumentation.add(new InsnNode(Opcodes.DUP)); } else { instrumentation.add(new InsnNode(Opcodes.ACONST_NULL)); } } }
From source file:org.evosuite.instrumentation.CreateClassResetClassAdapter.java
License:Open Source License
private void createEmptyStaticReset() { logger.info("Creating brand-new static initializer in class {}", className); MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, ClassResetter.STATIC_RESET, "()V", null, null); mv.visitCode();//from w w w .j a v a 2s . com for (StaticField staticField : static_fields) { if (!finalFields.contains(staticField.name)) { logger.info("Adding bytecode for initializing field {}", staticField.name); if (staticField.value != null) { mv.visitLdcInsn(staticField.value); } else { Type type = Type.getType(staticField.desc); switch (type.getSort()) { case Type.BOOLEAN: case Type.BYTE: case Type.CHAR: case Type.SHORT: case Type.INT: mv.visitInsn(Opcodes.ICONST_0); break; case Type.FLOAT: mv.visitInsn(Opcodes.FCONST_0); break; case Type.LONG: mv.visitInsn(Opcodes.LCONST_0); break; case Type.DOUBLE: mv.visitInsn(Opcodes.DCONST_0); break; case Type.ARRAY: case Type.OBJECT: mv.visitInsn(Opcodes.ACONST_NULL); break; } } mv.visitFieldInsn(Opcodes.PUTSTATIC, className, staticField.name, staticField.desc); } } mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); }
From source file:org.evosuite.instrumentation.MethodEntryAdapter.java
License:Open Source License
/** {@inheritDoc} */ @Override// w ww .j a va 2 s .co m public void onMethodEnter() { if (methodName.equals("<clinit>")) return; // FIXXME: Should we call super.onMethodEnter() here? mv.visitLdcInsn(className); mv.visitLdcInsn(fullMethodName); if ((access & Opcodes.ACC_STATIC) > 0) { mv.visitInsn(Opcodes.ACONST_NULL); } else { mv.visitVarInsn(Opcodes.ALOAD, 0); } mv.visitMethodInsn(Opcodes.INVOKESTATIC, PackageInfo.getNameWithSlash(ExecutionTracer.class), "enteredMethod", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V", false); super.onMethodEnter(); }
From source file:org.evosuite.instrumentation.mutation.DeleteField.java
License:Open Source License
private static AbstractInsnNode getDefault(Type type) { if (type.equals(Type.BOOLEAN_TYPE)) { return new LdcInsnNode(0); } else if (type.equals(Type.INT_TYPE)) { return new LdcInsnNode(0); } else if (type.equals(Type.BYTE_TYPE)) { return new LdcInsnNode(0); } else if (type.equals(Type.CHAR_TYPE)) { return new LdcInsnNode(0); } else if (type.equals(Type.DOUBLE_TYPE)) { return new LdcInsnNode(0.0); } else if (type.equals(Type.FLOAT_TYPE)) { return new LdcInsnNode(0.0F); } else if (type.equals(Type.INT_TYPE)) { return new LdcInsnNode(0); } else if (type.equals(Type.LONG_TYPE)) { return new LdcInsnNode(0L); } else if (type.equals(Type.SHORT_TYPE)) { return new LdcInsnNode(0); } else if (type.equals(Type.VOID_TYPE)) { return new LabelNode(); } else {/* w ww. j a v a 2 s .c o m*/ return new InsnNode(Opcodes.ACONST_NULL); } }
From source file:org.evosuite.runtime.instrumentation.CreateClassResetClassAdapter.java
License:Open Source License
/** * Creates an empty __STATIC_RESET method where no <clinit> was found. *///from ww w. j a v a 2s.c om private void createEmptyStaticReset() { logger.info("Creating brand-new static initializer in class " + className); MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC, ClassResetter.STATIC_RESET, "()V", null, null); mv.visitCode(); for (StaticField staticField : static_fields) { if (!finalFields.contains(staticField.name) && !staticField.name.startsWith("__cobertura") && !staticField.name.startsWith("$jacoco") && !staticField.name.startsWith("$VRc") // Old // Emma ) { logger.info("Adding bytecode for initializing field " + staticField.name); if (staticField.value != null) { mv.visitLdcInsn(staticField.value); } else { Type type = Type.getType(staticField.desc); switch (type.getSort()) { case Type.BOOLEAN: case Type.BYTE: case Type.CHAR: case Type.SHORT: case Type.INT: mv.visitInsn(Opcodes.ICONST_0); break; case Type.FLOAT: mv.visitInsn(Opcodes.FCONST_0); break; case Type.LONG: mv.visitInsn(Opcodes.LCONST_0); break; case Type.DOUBLE: mv.visitInsn(Opcodes.DCONST_0); break; case Type.ARRAY: case Type.OBJECT: mv.visitInsn(Opcodes.ACONST_NULL); break; } } mv.visitFieldInsn(Opcodes.PUTSTATIC, className, staticField.name, staticField.desc); } } mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); }
From source file:org.evosuite.runtime.instrumentation.CreateClassResetMethodAdapter.java
License:Open Source License
@Override public void visitCode() { super.visitCode(); for (StaticField staticField : staticFields) { if (!finalFields.contains(staticField.name) && !staticField.name.startsWith("__cobertura") && !staticField.name.startsWith("$jacoco") && !staticField.name.startsWith("$VRc") // Old Emma ) {/* ww w . j av a 2 s. c om*/ if (staticField.value != null) { mv.visitLdcInsn(staticField.value); } else { Type type = Type.getType(staticField.desc); switch (type.getSort()) { case Type.BOOLEAN: case Type.BYTE: case Type.CHAR: case Type.SHORT: case Type.INT: mv.visitInsn(Opcodes.ICONST_0); break; case Type.FLOAT: mv.visitInsn(Opcodes.FCONST_0); break; case Type.LONG: mv.visitInsn(Opcodes.LCONST_0); break; case Type.DOUBLE: mv.visitInsn(Opcodes.DCONST_0); break; case Type.ARRAY: case Type.OBJECT: mv.visitInsn(Opcodes.ACONST_NULL); break; } } mv.visitFieldInsn(Opcodes.PUTSTATIC, className, staticField.name, staticField.desc); } } }
From source file:org.evosuite.testcarver.instrument.Instrumenter.java
License:Open Source License
private void instrumentGETXXXFieldAccesses(final ClassNode cn, final String internalClassName, final MethodNode methodNode) { final InsnList instructions = methodNode.instructions; AbstractInsnNode ins = null;/*w w w.j av a2s . c o m*/ FieldInsnNode fieldIns = null; for (int i = 0; i < instructions.size(); i++) { ins = instructions.get(i); if (ins instanceof FieldInsnNode) { fieldIns = (FieldInsnNode) ins; /* * Is field referencing outermost instance? if yes, ignore it * http://tns-www.lcs.mit.edu/manuals/java-1.1.1/guide/innerclasses/spec/innerclasses.doc10.html */ if (fieldIns.name.endsWith("$0")) { continue; } final int opcode = ins.getOpcode(); if (opcode == Opcodes.GETFIELD || opcode == Opcodes.GETSTATIC) { final InsnList il = new InsnList(); if (opcode == Opcodes.GETFIELD) { Type fieldType = Type.getType(fieldIns.desc); if (fieldType.getSize() == 1) { instructions.insertBefore(fieldIns, new InsnNode(Opcodes.DUP)); il.add(new InsnNode(Opcodes.SWAP)); } else if (fieldType.getSize() == 2) { instructions.insertBefore(fieldIns, new InsnNode(Opcodes.DUP)); // v // GETFIELD // v, w il.add(new InsnNode(Opcodes.DUP2_X1)); // w, v, w il.add(new InsnNode(Opcodes.POP2)); // w, v // -> Call // w } } else il.add(new InsnNode(Opcodes.ACONST_NULL)); il.add(new LdcInsnNode(this.captureId)); il.add(new LdcInsnNode(fieldIns.owner)); il.add(new LdcInsnNode(fieldIns.name)); il.add(new LdcInsnNode(fieldIns.desc)); il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, PackageInfo.getNameWithSlash(org.evosuite.testcarver.capture.FieldRegistry.class), "notifyReadAccess", "(Ljava/lang/Object;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V")); i += il.size(); instructions.insert(fieldIns, il); this.captureId++; } } } }