diff --git a/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java b/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java index f3da77d7..7a42ef9b 100644 --- a/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java +++ b/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java @@ -23,6 +23,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -35,8 +36,6 @@ import javassist.LoaderClassPath; import javassist.Modifier; import javassist.NotFoundException; -import com.zaxxer.hikari.util.ClassLoaderUtils; - /** * This class generates the proxy objects for {@link Connection}, {@link Statement}, * {@link PreparedStatement}, and {@link CallableStatement}. Additionally it injects @@ -127,7 +126,7 @@ public final class JavassistProxyFactory } Set methods = new HashSet<>(); - Set> interfaces = ClassLoaderUtils.getAllInterfaces(primaryInterface); + Set> interfaces = getAllInterfaces(primaryInterface); for (Class intf : interfaces) { CtClass intfCt = classPool.getCtClass(intf.getName()); targetCt.addInterface(intfCt); @@ -214,6 +213,26 @@ public final class JavassistProxyFactory return intf.getDeclaredMethod(intfMethod.getName(), paramTypes.toArray(new Class[paramTypes.size()])).toString().contains("default "); } + private static Set> getAllInterfaces(Class clazz) + { + Set> interfaces = new HashSet>(); + for (Class intf : Arrays.asList(clazz.getInterfaces())) { + if (intf.getInterfaces().length > 0) { + interfaces.addAll(getAllInterfaces(intf)); + } + interfaces.add(intf); + } + if (clazz.getSuperclass() != null) { + interfaces.addAll(getAllInterfaces(clazz.getSuperclass())); + } + + if (clazz.isInterface()) { + interfaces.add(clazz); + } + + return interfaces; + } + private static Class toJavaClass(CtClass cls) throws Exception { if (cls.getName().endsWith("[]")) {