/** * {@inheritDoc} */ public StackManipulation resolveRead() { return new StackManipulation.Compound(DefaultValue.of(typeDefinition), readAssignment); }
/** * {@inheritDoc} */ protected StackManipulation resolve(Void initialized, FieldDescription fieldDescription, TypeDescription instrumentedType, MethodDescription instrumentedMethod) { return DefaultValue.of(fieldDescription.getType()); }
/** * {@inheritDoc} */ public MethodDelegationBinder.ParameterBinding<?> bind(AnnotationDescription.Loadable<Empty> annotation, MethodDescription source, ParameterDescription target, Implementation.Target implementationTarget, Assigner assigner, Assigner.Typing typing) { return new MethodDelegationBinder.ParameterBinding.Anonymous(DefaultValue.of(target.getType().asErasure())); } }
/** * {@inheritDoc} */ public StackManipulation resolve(TypeDescription targetType, ByteCodeElement target, TypeList.Generic parameters, TypeDescription.Generic result) { List<StackManipulation> stackManipulations = new ArrayList<StackManipulation>(parameters.size()); for (int index = parameters.size() - 1; index >= 0; index--) { stackManipulations.add(Removal.of(parameters.get(index))); } return new StackManipulation.Compound(CompoundList.of(stackManipulations, DefaultValue.of(result.asErasure()))); } }
/** * {@inheritDoc} */ public OffsetMapping make(ParameterDescription.InDefinedShape target, AnnotationDescription.Loadable<T> annotation, AdviceType adviceType) { return new ForStackManipulation(DefaultValue.of(target.getType()), target.getType(), target.getType(), Assigner.Typing.STATIC); } }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Context implementationContext, MethodDescription instrumentedMethod) { StackManipulation.Size stackSize = new StackManipulation.Compound( DefaultValue.of(instrumentedMethod.getReturnType()), MethodReturn.of(instrumentedMethod.getReturnType()) ).apply(methodVisitor, implementationContext); return new Size(stackSize.getMaximalSize(), instrumentedMethod.getStackSize()); } }
/** * {@inheritDoc} */ public StackManipulation assign(TypeDescription.Generic source, TypeDescription.Generic target, Typing typing) { if (source.represents(void.class) && target.represents(void.class)) { return StackManipulation.Trivial.INSTANCE; } else if (source.represents(void.class) /* && target != void.class */) { return typing.isDynamic() ? DefaultValue.of(target) : StackManipulation.Illegal.INSTANCE; } else if (/* source != void.class && */ target.represents(void.class)) { return Removal.of(source); } else /* source != void.class && target != void.class */ { return chained.assign(source, target, typing); } } }
/** * {@inheritDoc} */ public Record prepend(ByteCodeAppender byteCodeAppender) { return new ForDefinedMethod.WithBody(methodDescription, new ByteCodeAppender.Compound(byteCodeAppender, new ByteCodeAppender.Simple(DefaultValue.of(methodDescription.getReturnType()), MethodReturn.of(methodDescription.getReturnType())))); } }
/** * {@inheritDoc} */ public MethodDelegationBinder.ParameterBinding<?> bind(AnnotationDescription.Loadable<StubValue> annotation, MethodDescription source, ParameterDescription target, Implementation.Target implementationTarget, Assigner assigner, Assigner.Typing typing) { if (!target.getType().represents(Object.class)) { throw new IllegalStateException(target + " uses StubValue annotation on non-Object type"); } return new MethodDelegationBinder.ParameterBinding.Anonymous(source.getReturnType().represents(void.class) ? NullConstant.INSTANCE : new StackManipulation.Compound(DefaultValue.of(source.getReturnType().asErasure()), assigner.assign(source.getReturnType(), TypeDescription.Generic.OBJECT, typing))); } }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { TypeDescription proxyType = implementationContext .register(new TypeProxy(proxiedType, implementationTarget, InvocationFactory.Default.SUPER_METHOD, ignoreFinalizer, serializableProxy)); StackManipulation[] constructorValue = new StackManipulation[constructorParameters.size()]; int index = 0; for (TypeDescription parameterType : constructorParameters) { constructorValue[index++] = DefaultValue.of(parameterType); } return new Compound( TypeCreation.of(proxyType), Duplication.SINGLE, new Compound(constructorValue), MethodInvocation.invoke(proxyType.getDeclaredMethods().filter(isConstructor().and(takesArguments(constructorParameters))).getOnly()), Duplication.SINGLE, MethodVariableAccess.loadThis(), FieldAccess.forField(proxyType.getDeclaredFields().filter((named(INSTANCE_FIELD))).getOnly()).write() ).apply(methodVisitor, implementationContext); } }
Object value = bind(annotation, source, target); if (value == null) { return new ParameterBinding.Anonymous(DefaultValue.of(target.getType()));