/** * {@inheritDoc} */ public ByteCodeAppender appender(Target implementationTarget) { if (!redirectedMethod.isAccessibleTo(implementationTarget.getInstrumentedType())) { throw new IllegalStateException("Cannot invoke " + redirectedMethod + " from outside of class via @Pipe proxy"); } return new Appender(implementationTarget.getInstrumentedType()); }
if (!invokedMethod.isAccessibleTo(implementationTarget.getInstrumentedType())) { throw new IllegalStateException("Cannot access " + invokedMethod + " from " + implementationTarget.getInstrumentedType());
/** * {@inheritDoc} */ public MethodBinding bind(Implementation.Target implementationTarget, MethodDescription source, MethodDelegationBinder.TerminationHandler terminationHandler, MethodInvoker methodInvoker, Assigner assigner) { if (!candidate.isAccessibleTo(implementationTarget.getInstrumentedType())) { return MethodBinding.Illegal.INSTANCE; } StackManipulation methodTermination = terminationHandler.resolve(assigner, typing, source, candidate); if (!methodTermination.isValid()) { return MethodBinding.Illegal.INSTANCE; } MethodBinding.Builder methodDelegationBindingBuilder = new MethodBinding.Builder(methodInvoker, candidate); for (DelegationProcessor.Handler handler : handlers) { ParameterBinding<?> parameterBinding = handler.bind(source, implementationTarget, assigner); if (!parameterBinding.isValid() || !methodDelegationBindingBuilder.append(parameterBinding)) { return MethodBinding.Illegal.INSTANCE; } } return methodDelegationBindingBuilder.build(methodTermination); }
/** * {@inheritDoc} */ public StackManipulation resolve(TypeDescription targetType, ByteCodeElement target, TypeList.Generic parameters, TypeDescription.Generic result) { MethodDescription methodDescription = methodResolver.resolve(targetType, target, parameters, result); if (!methodDescription.isAccessibleTo(instrumentedType)) { throw new IllegalStateException(instrumentedType + " cannot access " + methodDescription); } TypeList.Generic mapped = methodDescription.isStatic() ? methodDescription.getParameters().asTypeList() : new TypeList.Generic.Explicit(CompoundList.of(methodDescription.getDeclaringType(), methodDescription.getParameters().asTypeList())); if (!methodDescription.getReturnType().asErasure().isAssignableTo(result.asErasure())) { throw new IllegalStateException("Cannot assign return value of " + methodDescription + " to " + result); } else if (mapped.size() != parameters.size()) { throw new IllegalStateException("Cannot invoke " + methodDescription + " on " + parameters); } for (int index = 0; index < mapped.size(); index++) { if (!mapped.get(index).asErasure().isAssignableTo(parameters.get(index).asErasure())) { throw new IllegalStateException("Cannot invoke " + methodDescription + " on " + parameters); } } return methodDescription.isVirtual() ? MethodInvocation.invoke(methodDescription).virtual(mapped.get(THIS_REFERENCE).asErasure()) : MethodInvocation.invoke(methodDescription); }