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 ced1c255612..ee26513d6b5 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -422,7 +422,8 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut private ShadowMatch getTargetShadowMatch(Method method, Class targetClass) { Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass); - if (targetMethod.getDeclaringClass().isInterface()) { + if (targetMethod.getDeclaringClass().isInterface() && targetMethod.getDeclaringClass() != targetClass && + obtainPointcutExpression().getPointcutExpression().contains("." + targetMethod.getName() + "(")) { // Try to build the most specific interface possible for inherited methods to be // considered for sub-interface matches as well, in particular for proxy classes. // Note: AspectJ is only going to take Method.getDeclaringClass() into account.