From c0bd8bfeac1cfcbb0205fb41b8ace3d1834c347d Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Mon, 25 Jan 2016 23:16:43 +0900 Subject: [PATCH] Fixes #555 check for default method is not longer needed because proxy generation is performed at build-time not run-time now. --- .../zaxxer/hikari/util/JavassistProxyFactory.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/zaxxer/hikari/util/JavassistProxyFactory.java b/src/main/java/com/zaxxer/hikari/util/JavassistProxyFactory.java index 1cf805e6..1955e988 100644 --- a/src/main/java/com/zaxxer/hikari/util/JavassistProxyFactory.java +++ b/src/main/java/com/zaxxer/hikari/util/JavassistProxyFactory.java @@ -161,7 +161,7 @@ public final class JavassistProxyFactory // If the super-Proxy has concrete methods (non-abstract), transform the call into a simple super.method() call CtMethod superMethod = superCt.getMethod(intfMethod.getName(), intfMethod.getSignature()); - if ((superMethod.getModifiers() & Modifier.ABSTRACT) != Modifier.ABSTRACT) { + if ((superMethod.getModifiers() & Modifier.ABSTRACT) != Modifier.ABSTRACT && !isDefaultMethod(intf, intfCt, intfMethod)) { modifiedBody = modifiedBody.replace("((cast) ", ""); modifiedBody = modifiedBody.replace("delegate", "super"); modifiedBody = modifiedBody.replace("super)", "super"); @@ -206,6 +206,17 @@ public final class JavassistProxyFactory return false; } + private static boolean isDefaultMethod(Class intf, CtClass intfCt, CtMethod intfMethod) throws Exception + { + List> paramTypes = new ArrayList<>(); + + for (CtClass pt : intfMethod.getParameterTypes()) { + paramTypes.add(toJavaClass(pt)); + } + + return intf.getDeclaredMethod(intfMethod.getName(), paramTypes.toArray(new Class[paramTypes.size()])).toString().contains("default "); + } + private static Set> getAllInterfaces(Class clazz) { Set> interfaces = new HashSet>();