Reflections { public static <T> T implement(final Class<T> clasz, final Object target) { Method[] methods = clasz.getMethods(); final Map<Method, Method> map = new HashMap<>(methods.length); Class<? extends Object> aClass = target.getClass(); for (Method from : methods) { Method to = getCompatibleMethodCached(aClass, from.getName(), getParameterTypes(from)); if (to == null) { throw new IllegalArgumentException("Cannot map from " + clasz + " to " + target); } map.put(from, to); } return (T) Proxy.newProxyInstance(clasz.getClassLoader(), new Class[]{clasz}, (final Object proxy, final Method method, final Object[] args) -> map.get(method).invoke(target, args)); } private  Reflections(); static Class<?>[] getParameterTypes(final Method m); static Class<?>[] getParameterTypes(final Constructor<?> m); static Class<?> primitiveToWrapper(final Class<?> clasz); @Nonnull static Type primitiveToWrapper(final Type type); static Class<?> wrapperToPrimitive(final Class<?> clasz); static boolean isWrappableOrWrapper(final Class clasz); static Object getAnnotationAttribute(@Nonnull final Annotation annot, @Nonnull final String attributeName); @Nullable @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "comparing interned strings") static Method getDeclaredMethod(final Class<?> c,
          final String methodName,
          final Class<?>... paramTypes); @Nullable @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "comparing interned strings") static Method getMethod(final Class<?> c,
          final String methodName,
          final Class<?>... paramTypes); @Nullable static Constructor<?> getConstructor(final Class<?> c, final Class<?>... paramTypes); @Nullable static Method getCompatibleMethod(final Class<?> c,
          final String methodName,
          final Class<?>... paramTypes); @Nullable static MethodHandle getCompatibleMethodHandle(final Class<?> c,
          final String methodName,
          final Class<?>... paramTypes); static Object invoke(final Method m, final Object object, final Object[] parameters); static boolean canAssign(final Class<?> to, final Class<?> from); @Nullable static Method getCompatibleMethodCached(final Class<?> c,
          final String methodName,
          final Class<?>... paramTypes); static MethodHandle getCompatibleMethodHandleCached(final Class<?> c,
          final String methodName,
          final Class<?>... paramTypes); @Nullable @SuppressFBWarnings({ "NP_LOAD_OF_KNOWN_NULL_VALUE", "URLCONNECTION_SSRF_FD" }) static Manifest getManifest(@Nonnull final URL jarUrl); static T implementStatic(final Class<T> clasz, final Class<?> target); static T implement(final Class<T> clasz, final Object target); @Nullable static Class<?> getLoadedClass(final ClassLoader cl, final String className); static Class<?> forName(final String name); static Class<?> forName(final String name, final ClassLoader loader); static List<Type> getImplementedGenericInterfaces(final Class<?> clasz); @Nullable static A getInheritedAnnotation(
          final Class<A> annotationClass, final AnnotatedElement element);  }
@Test public void testImplement() { Printing prt = Reflections.implementStatic(Printing.class, ReflectionsTest.class); String result = prt.print("a", 3); Assert.assertEquals("[a, 3]", result); }