From b449928691553ba791adf20850e9179730b4b3a2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 13 Feb 2018 11:40:28 +0100 Subject: [PATCH] Avoid unused arguments for internal delegates --- .../aop/aspectj/DeclareParentsAdvisor.java | 26 +++++++++---------- .../org/springframework/asm/ClassWriter.java | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java index 988cadd0dc5..d2a607f54e2 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -20,6 +20,7 @@ import org.aopalliance.aop.Advice; import org.springframework.aop.ClassFilter; import org.springframework.aop.IntroductionAdvisor; +import org.springframework.aop.IntroductionInterceptor; import org.springframework.aop.support.ClassFilters; import org.springframework.aop.support.DelegatePerTargetObjectIntroductionInterceptor; import org.springframework.aop.support.DelegatingIntroductionInterceptor; @@ -34,12 +35,12 @@ import org.springframework.aop.support.DelegatingIntroductionInterceptor; */ public class DeclareParentsAdvisor implements IntroductionAdvisor { + private final Advice advice; + private final Class introducedInterface; private final ClassFilter typePatternClassFilter; - private final Advice advice; - /** * Create a new advisor for this DeclareParents field. @@ -48,8 +49,8 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor { * @param defaultImpl the default implementation class */ public DeclareParentsAdvisor(Class interfaceType, String typePattern, Class defaultImpl) { - this(interfaceType, typePattern, defaultImpl, - new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType)); + this(interfaceType, typePattern, + new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType)); } /** @@ -59,8 +60,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor { * @param delegateRef the delegate implementation object */ public DeclareParentsAdvisor(Class interfaceType, String typePattern, Object delegateRef) { - this(interfaceType, typePattern, delegateRef.getClass(), - new DelegatingIntroductionInterceptor(delegateRef)); + this(interfaceType, typePattern, new DelegatingIntroductionInterceptor(delegateRef)); } /** @@ -68,18 +68,16 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor { * (cannot use method such as init() to share common code, due the use of final fields) * @param interfaceType static field defining the introduction * @param typePattern type pattern the introduction is restricted to - * @param implementationClass implementation class - * @param advice delegation advice + * @param interceptor the delegation advice as {@link IntroductionInterceptor} */ - private DeclareParentsAdvisor(Class interfaceType, String typePattern, Class implementationClass, Advice advice) { + private DeclareParentsAdvisor(Class interfaceType, String typePattern, IntroductionInterceptor interceptor) { + this.advice = interceptor; this.introducedInterface = interfaceType; - ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern); // Excludes methods implemented. - ClassFilter exclusion = clazz -> !(introducedInterface.isAssignableFrom(clazz)); - + ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern); + ClassFilter exclusion = (clazz -> !introducedInterface.isAssignableFrom(clazz)); this.typePatternClassFilter = ClassFilters.intersection(typePatternFilter, exclusion); - this.advice = advice; } diff --git a/spring-core/src/main/java/org/springframework/asm/ClassWriter.java b/spring-core/src/main/java/org/springframework/asm/ClassWriter.java index a024937d81e..513b2e5d2e2 100644 --- a/spring-core/src/main/java/org/springframework/asm/ClassWriter.java +++ b/spring-core/src/main/java/org/springframework/asm/ClassWriter.java @@ -1699,7 +1699,7 @@ public class ClassWriter extends ClassVisitor { */ private Item addType(final Item item) { ++typeCount; - Item result = new Item(typeCount, key); + Item result = new Item(typeCount, item); put(result); if (typeTable == null) { typeTable = new Item[16];