From bccff73e2b4911bc5009a8d4335cfac915736ea3 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 22 Jul 2018 22:28:48 +0200 Subject: [PATCH] AspectJExpressionPointcut leniently ignores non-composable interfaces Issue: SPR-17003 --- .../aop/aspectj/AspectJExpressionPointcut.java | 12 +++++++++--- .../java/org/springframework/util/ClassUtils.java | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java index 3ee4f44ee05..ec4f62a2bb9 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java @@ -433,9 +433,15 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut // Note: AspectJ is only going to take Method.getDeclaringClass() into account. Set> ifcs = ClassUtils.getAllInterfacesForClassAsSet(targetClass); if (ifcs.size() > 1) { - Class compositeInterface = ClassUtils.createCompositeInterface( - ClassUtils.toClassArray(ifcs), targetClass.getClassLoader()); - targetMethod = ClassUtils.getMostSpecificMethod(targetMethod, compositeInterface); + try { + Class compositeInterface = ClassUtils.createCompositeInterface( + ClassUtils.toClassArray(ifcs), targetClass.getClassLoader()); + targetMethod = ClassUtils.getMostSpecificMethod(targetMethod, compositeInterface); + } + catch (IllegalArgumentException ex) { + // Implemented interfaces probably expose conflicting method signatures... + // Proceed with original target method. + } } } return getShadowMatch(targetMethod, method); diff --git a/spring-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index 8e40934cab9..4a7b9e8f938 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -771,6 +771,8 @@ public abstract class ClassUtils { * @param interfaces the interfaces to merge * @param classLoader the ClassLoader to create the composite Class in * @return the merged interface as Class + * @throws IllegalArgumentException if the specified interfaces expose + * conflicting method signatures (or a similar constraint is violated) * @see java.lang.reflect.Proxy#getProxyClass */ @SuppressWarnings("deprecation")