@SuppressWarnings("PMD.CompareObjectsWithEquals")
    private static Object createProxy(InvocationHandler naiveHandler, Class<?> extensionType, Class<?>... extraTypes) {
        InvocationHandler handler = (proxy, method, args) -> {
            if (EQUALS_METHOD.equals(method)) {
                return proxy == args[0];
            }

            if (HASHCODE_METHOD.equals(method)) {
                return System.identityHashCode(proxy);
            }

            if (TOSTRING_METHOD.equals(method)) {
                return "JdbiJta on demand proxy for " + extensionType.getName() + "@" + Integer.toHexString(System.identityHashCode(proxy));
            }

            return naiveHandler.invoke(proxy, method, args);

        };

        Class<?>[] types = Stream.of(
                    Stream.of(extensionType),
                    Arrays.stream(extensionType.getInterfaces()),
                    Arrays.stream(extraTypes))
                .flatMap(Function.identity())
                .distinct()
                .toArray(Class[]::new);
        return Proxy.newProxyInstance(extensionType.getClassLoader(), types, handler);
    }
Proxies the extension object to bind it to the jta framework. Creates and closes the handle if needed.
spring5/src/main/java/org/jdbi/v3/spring5/JdbiJtaBinder.java