diff options
author | NingZhang-Ericsson <ning.n.zhang@ericsson.com> | 2018-07-13 13:06:20 +0800 |
---|---|---|
committer | NingZhang-Ericsson <ning.n.zhang@ericsson.com> | 2018-07-13 13:06:20 +0800 |
commit | fd1d535bb36e3d6cc2a82d19784c45f29c064cc7 (patch) | |
tree | 8dedb97445e157fa8c478d0f8ebda00dcc8cba6e /src/main | |
parent | a59658da9986ec2a9952a6539000c57ff1f02026 (diff) | |
download | javassist-fd1d535bb36e3d6cc2a82d19784c45f29c064cc7.tar.gz javassist-fd1d535bb36e3d6cc2a82d19784c45f29c064cc7.zip |
fixed JASSIST-267
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/javassist/util/proxy/ProxyFactory.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/main/javassist/util/proxy/ProxyFactory.java b/src/main/javassist/util/proxy/ProxyFactory.java index 072fb42c..da9e29c6 100644 --- a/src/main/javassist/util/proxy/ProxyFactory.java +++ b/src/main/javassist/util/proxy/ProxyFactory.java @@ -1190,7 +1190,7 @@ public class ProxyFactory { // ignore a bridge method with the same signature that the overridden one has. if (null != oldMethod && isBridge(m) && !Modifier.isPublic(oldMethod.getDeclaringClass().getModifiers()) - && !Modifier.isAbstract(oldMethod.getModifiers()) && !isOverloaded(i, methods)) + && !Modifier.isAbstract(oldMethod.getModifiers()) && !isDuplicated(i, methods)) hash.put(key, oldMethod); // check if visibility has been reduced @@ -1203,16 +1203,35 @@ public class ProxyFactory { } } - private static boolean isOverloaded(int index, Method[] methods) { + private static boolean isDuplicated(int index, Method[] methods) { String name = methods[index].getName(); for (int i = 0; i < methods.length; i++) if (i != index) - if (name.equals(methods[i].getName())) + if (name.equals(methods[i].getName()) && areParametersSame(methods[index], methods[i])) return true; return false; } - + + private static boolean areParametersSame(Method method, Method targetMethod) { + Class<?>[] methodTypes = method.getParameterTypes(); + Class<?>[] targetMethodTypes = targetMethod.getParameterTypes(); + int i = -1; + if (methodTypes.length == targetMethodTypes.length) { + for (Class<?> clz : methodTypes) { + i++; + + if (clz.equals(targetMethodTypes[i].getClass())) { + continue; + } else { + return false; + } + } + return true; + } + return false; + } + private static final String HANDLER_GETTER_KEY = HANDLER_GETTER + ":()"; |