@Test @SuppressWarnings("unchecked") public void testStaticMethodBinding() throws Exception { DynamicType.Loaded<T> loaded = new ByteBuddy() .subclass(sourceType) .method(isDeclaredBy(sourceType)) .intercept(MethodDelegation.to(targetType)) .make() .load(sourceType.getClassLoader(), ClassLoadingStrategy.Default.WRAPPER); assertThat(loaded.getLoadedAuxiliaryTypes().size(), is(0)); assertThat(loaded.getLoaded().getDeclaredMethods().length, is(1)); assertThat(loaded.getLoaded().getDeclaredFields().length, is(0)); T instance = loaded.getLoaded().getDeclaredConstructor().newInstance(); assertThat(instance.getClass(), not(CoreMatchers.<Class<?>>is(sourceType))); assertThat(instance, instanceOf(sourceType)); assertThat(loaded.getLoaded().getDeclaredMethod(FOO, parameterTypes).invoke(instance, arguments), (Matcher) matcher); instance.assertZeroCalls(); }
public static MethodDelegation to(Class<?> type) { return withDefaultConfiguration().to(type); }
MethodDelegation implements Implementation.Composable { public static MethodDelegation to(Class<?> type) { return withDefaultConfiguration().to(type); } }
MethodDelegation implements Implementation.Composable { public static MethodDelegation to(Class<?> type) { return withDefaultConfiguration().to(type); } protected  MethodDelegation(ImplementationDelegate implementationDelegate,
                               List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders,
                               MethodDelegationBinder.AmbiguityResolver ambiguityResolver,
                               MethodDelegationBinder.BindingResolver bindingResolver); private  MethodDelegation(ImplementationDelegate implementationDelegate,
                             List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders,
                             MethodDelegationBinder.AmbiguityResolver ambiguityResolver,
                             TargetMethodAnnotationDrivenBinder.TerminationHandler terminationHandler,
                             MethodDelegationBinder.BindingResolver bindingResolver,
                             Assigner assigner); }
MethodDelegation implements Implementation.Composable { public static MethodDelegation to(Class<?> type) { return withDefaultConfiguration().to(type); } protected  MethodDelegation(ImplementationDelegate implementationDelegate,
                               List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders,
                               MethodDelegationBinder.AmbiguityResolver ambiguityResolver,
                               MethodDelegationBinder.BindingResolver bindingResolver); private  MethodDelegation(ImplementationDelegate implementationDelegate,
                             List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders,
                             MethodDelegationBinder.AmbiguityResolver ambiguityResolver,
                             TargetMethodAnnotationDrivenBinder.TerminationHandler terminationHandler,
                             MethodDelegationBinder.BindingResolver bindingResolver,
                             Assigner assigner); static MethodDelegation to(Class<?> type); static MethodDelegation to(TypeDescription typeDescription); static MethodDelegation to(Object target); static MethodDelegation to(Object target, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation to(Object target, String fieldName); static MethodDelegation to(Object target, String fieldName, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation to(Object target, Type type); static MethodDelegation to(Object target, Type type, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation to(Object target, Type type, String fieldName); static MethodDelegation to(Object target, Type type, String fieldName, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation to(Object target, TypeDefinition typeDefinition); static MethodDelegation to(Object target, TypeDefinition typeDefinition, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation to(Object target, TypeDefinition typeDefinition, String fieldName); static MethodDelegation to(Object target, TypeDefinition typeDefinition, String fieldName, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation toConstructor(Class<?> type); static MethodDelegation toConstructor(TypeDescription typeDescription); static MethodDelegation toField(String name); static MethodDelegation toField(String name, FieldLocator.Factory fieldLocatorFactory); static MethodDelegation toField(String name, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation toField(String name, FieldLocator.Factory fieldLocatorFactory, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation toMethodReturnOf(String name); static MethodDelegation toMethodReturnOf(String name, MethodGraph.Compiler methodGraphCompiler); static WithCustomProperties withDefaultConfiguration(); static WithCustomProperties withEmptyConfiguration(); Implementation.Composable withAssigner(Assigner assigner); Implementation andThen(Implementation implementation); Composable andThen(Composable implementation); InstrumentedType prepare(InstrumentedType instrumentedType); ByteCodeAppender appender(Target implementationTarget); }
MethodDelegation implements Implementation.Composable { public static MethodDelegation to(Class<?> type) { return withDefaultConfiguration().to(type); } protected  MethodDelegation(ImplementationDelegate implementationDelegate,
                               List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders,
                               MethodDelegationBinder.AmbiguityResolver ambiguityResolver,
                               MethodDelegationBinder.BindingResolver bindingResolver); private  MethodDelegation(ImplementationDelegate implementationDelegate,
                             List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders,
                             MethodDelegationBinder.AmbiguityResolver ambiguityResolver,
                             TargetMethodAnnotationDrivenBinder.TerminationHandler terminationHandler,
                             MethodDelegationBinder.BindingResolver bindingResolver,
                             Assigner assigner); static MethodDelegation to(Class<?> type); static MethodDelegation to(TypeDescription typeDescription); static MethodDelegation to(Object target); static MethodDelegation to(Object target, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation to(Object target, String fieldName); static MethodDelegation to(Object target, String fieldName, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation to(Object target, Type type); static MethodDelegation to(Object target, Type type, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation to(Object target, Type type, String fieldName); static MethodDelegation to(Object target, Type type, String fieldName, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation to(Object target, TypeDefinition typeDefinition); static MethodDelegation to(Object target, TypeDefinition typeDefinition, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation to(Object target, TypeDefinition typeDefinition, String fieldName); static MethodDelegation to(Object target, TypeDefinition typeDefinition, String fieldName, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation toConstructor(Class<?> type); static MethodDelegation toConstructor(TypeDescription typeDescription); static MethodDelegation toField(String name); static MethodDelegation toField(String name, FieldLocator.Factory fieldLocatorFactory); static MethodDelegation toField(String name, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation toField(String name, FieldLocator.Factory fieldLocatorFactory, MethodGraph.Compiler methodGraphCompiler); static MethodDelegation toMethodReturnOf(String name); static MethodDelegation toMethodReturnOf(String name, MethodGraph.Compiler methodGraphCompiler); static WithCustomProperties withDefaultConfiguration(); static WithCustomProperties withEmptyConfiguration(); Implementation.Composable withAssigner(Assigner assigner); Implementation andThen(Implementation implementation); Composable andThen(Composable implementation); InstrumentedType prepare(InstrumentedType instrumentedType); ByteCodeAppender appender(Target implementationTarget);  }