/** * Applies a transformation to all loaded arguments of the method being loaded to be casted to the corresponding parameter of * the provided method. This way, the parameters can be used for invoking a bridge target method. * * @param bridgeTarget The method that is the target of the bridge method for which the parameters are being loaded. * @return A stack manipulation that loads all parameters casted to the types of the supplied bridge target. */ public MethodLoading asBridgeOf(MethodDescription bridgeTarget) { return new MethodLoading(methodDescription, new TypeCastingHandler.ForBridgeTarget(bridgeTarget)); }
/** * Creates a stack assignment for writing to a given offset of the local variable array. * * @param offset The offset of the variable where {@code double} and {@code long} types count two slots. * @return A stack manipulation representing the variable write. */ public StackManipulation storeAt(int offset) { return new OffsetWriting(offset); }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { return new ByteCodeAppender.Simple( MethodVariableAccess.allArgumentsOf(instrumentedMethod).prependThisReference(), MethodInvocation.invoke(bridgeTarget).special(bridgeType), MethodReturn.of(instrumentedMethod.getReturnType()) ).apply(methodVisitor, implementationContext, instrumentedMethod); }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Context implementationContext, MethodDescription instrumentedMethod) { StackManipulation.Size stackSize = new StackManipulation.Compound( MethodVariableAccess.allArgumentsOf(instrumentedMethod).prependThisReference(), FieldAccess.forField(fieldDescription).write(), MethodReturn.VOID ).apply(methodVisitor, implementationContext); return new Size(stackSize.getMaximalSize(), instrumentedMethod.getStackSize()); } }
/** * {@inheritDoc} */ public StackManipulation invoke(MethodDescription methodDescription) { return MethodInvocation.invoke(methodDescription); } }
/** * Returns a stack manipulation where the represented value is stored in the given field. * * @param fieldDescription A static field in which the value is to be stored. * @return A byte code appender that represents this storage. */ protected ByteCodeAppender storeIn(FieldDescription fieldDescription) { return new ByteCodeAppender.Simple(this, FieldAccess.forField(fieldDescription).write()); }
/** * Loads a reference to the {@code this} reference what is only meaningful for a non-static method. * * @return A stack manipulation loading the {@code this} reference. */ public static StackManipulation loadThis() { return MethodVariableAccess.REFERENCE.loadFrom(0); }
/** * {@inheritDoc} */ public StackManipulation onHandle(HandleType type) { return new HandleInvocation(methodDescription, type); } }
/** * Loads all arguments of the provided method onto the operand stack. * * @param methodDescription The method for which all parameters are to be loaded onto the operand stack. * @return A stack manipulation that loads all parameters of the provided method onto the operand stack. */ public static MethodLoading allArgumentsOf(MethodDescription methodDescription) { return new MethodLoading(methodDescription, MethodLoading.TypeCastingHandler.NoOp.INSTANCE); }
/** * {@inheritDoc} */ public boolean isValid() { return invocation.isValid(); }
/** * {@inheritDoc} */ public StackManipulation write() { return new FieldPutInstruction(); }
/** * Creates a stack assignment for a reading given offset of the local variable array. * * @param offset The offset of the variable where {@code double} and {@code long} types count two slots. * @return A stack manipulation representing the variable read. */ public StackManipulation loadFrom(int offset) { return new OffsetLoading(offset); }
/** * {@inheritDoc} */ public StackManipulation dynamic(String methodName, TypeDescription returnType, List<? extends TypeDescription> methodType, List<?> arguments) { return invocation.dynamic(methodName, returnType, methodType, arguments); }
/** * {@inheritDoc} */ public StackManipulation write() { return defined.write(); } }
/** * {@inheritDoc} */ public StackManipulation read() { return new FieldGetInstruction(); }