Refine search
mv.visitInsn(DUP); if (hasThis) { mv.visitVarInsn(ALOAD, 0); start = 1; } else { mv.visitInsn(ACONST_NULL); start = 0; mv.visitInsn(ACONST_NULL); } else { mv.visitLdcInsn(args.length); mv.visitInsn(DUP); mv.visitLdcInsn(i); mv.visitVarInsn(args[i].getOpcode(ILOAD), i + start); box(args[i], mv); mv.visitInsn(AASTORE); mv.visitInsn(ret.getOpcode(IRETURN)); mv.visitMaxs(-1, -1); mv.visitEnd();
for (Class<?> parameterType : parameterTypes) { int localIndexOfParameter = locals.newLocal(parameterType); int loadOpCode = Type.getType(parameterType).getOpcode(Opcodes.ILOAD); methodVisitor.visitVarInsn(loadOpCode, localIndexOfParameter); methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, Type.getInternalName(returnType)); int returnOpcode = Type.getType(returnType).getOpcode(Opcodes.IRETURN); methodVisitor.visitInsn(returnOpcode);
mv.visitVarInsn(ILOAD, 3); mv.visitFieldInsn(PUTFIELD, typeName, "idx", "I"); mv.visitInsn(RETURN); mv.visitMaxs(-1, -1); mv.visitEnd(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, typeName, "args", "[Ljava/lang/Object;"); mv.visitInsn(ARETURN); mv.visitMaxs(-1, -1); mv.visitEnd(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, typeName, "thiz", "Ljava/lang/Object;"); mv.visitInsn(ARETURN); mv.visitMaxs(-1, -1); mv.visitEnd(); mv.visitInsn(ret.getOpcode(IRETURN));
@RequiresNonNull("type") private void addShim(ShimType shimType) { for (java.lang.reflect.Method reflectMethod : shimType.shimMethods()) { Method method = Method.getMethod(reflectMethod); Shim shim = reflectMethod.getAnnotation(Shim.class); checkNotNull(shim); if (shim.value().length != 1) { throw new IllegalStateException( "@Shim annotation must have exactly one value when used on methods"); } Method targetMethod = Method.getMethod(shim.value()[0]); MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, method.getName(), method.getDescriptor(), null, null); mv.visitCode(); int i = 0; mv.visitVarInsn(ALOAD, i++); for (Type argumentType : method.getArgumentTypes()) { mv.visitVarInsn(argumentType.getOpcode(ILOAD), i++); } mv.visitMethodInsn(INVOKEVIRTUAL, type.getInternalName(), targetMethod.getName(), targetMethod.getDescriptor(), false); mv.visitInsn(method.getReturnType().getOpcode(IRETURN)); mv.visitMaxs(0, 0); mv.visitEnd(); } }
/** * Generates the instruction to do the specified mathematical or logical operation. * * @param op a mathematical or logical operation. Must be one of ADD, SUB, MUL, DIV, REM, NEG, * SHL, SHR, USHR, AND, OR, XOR. * @param type the type of the operand(s) for this operation. */ public void math(final int op, final Type type) { mv.visitInsn(type.getOpcode(op)); }
/** * Generates the instruction to do the specified mathematical or logical operation. * * @param op a mathematical or logical operation. Must be one of ADD, SUB, MUL, DIV, REM, NEG, * SHL, SHR, USHR, AND, OR, XOR. * @param type the type of the operand(s) for this operation. */ public void math(final int op, final Type type) { mv.visitInsn(type.getOpcode(op)); }