diff --git a/spring-aop/src/main/java/org/springframework/aop/MethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/MethodMatcher.java
index 15526c1fc8..7cba7648cf 100644
--- a/spring-aop/src/main/java/org/springframework/aop/MethodMatcher.java
+++ b/spring-aop/src/main/java/org/springframework/aop/MethodMatcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -86,7 +86,7 @@ public interface MethodMatcher {
* @return whether there's a runtime match
* @see MethodMatcher#matches(Method, Class)
*/
- boolean matches(Method method, Class> targetClass, Object[] args);
+ boolean matches(Method method, Class> targetClass, Object... args);
/**
diff --git a/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java
index 0b82427e8b..cf21e97c91 100644
--- a/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java
+++ b/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -29,12 +29,14 @@ class TrueMethodMatcher implements MethodMatcher, Serializable {
public static final TrueMethodMatcher INSTANCE = new TrueMethodMatcher();
+
/**
* Enforce Singleton pattern.
*/
private TrueMethodMatcher() {
}
+
@Override
public boolean isRuntime() {
return false;
@@ -46,11 +48,17 @@ class TrueMethodMatcher implements MethodMatcher, Serializable {
}
@Override
- public boolean matches(Method method, Class> targetClass, Object[] args) {
+ public boolean matches(Method method, Class> targetClass, Object... args) {
// Should never be invoked as isRuntime returns false.
throw new UnsupportedOperationException();
}
+
+ @Override
+ public String toString() {
+ return "MethodMatcher.TRUE";
+ }
+
/**
* Required to support serialization. Replaces with canonical
* instance on deserialization, protecting Singleton pattern.
@@ -60,9 +68,4 @@ class TrueMethodMatcher implements MethodMatcher, Serializable {
return INSTANCE;
}
- @Override
- public String toString() {
- return "MethodMatcher.TRUE";
- }
-
}
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 60427610a6..3cb2613689 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
@@ -305,7 +305,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
}
@Override
- public boolean matches(Method method, Class> targetClass, Object[] args) {
+ public boolean matches(Method method, Class> targetClass, Object... args) {
checkReadyToMatch();
ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method);
ShadowMatch originalShadowMatch = getShadowMatch(method, method);
diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java
index 3fad461004..98c74f7ad0 100644
--- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java
+++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -61,34 +61,6 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
private static final String AJC_MAGIC = "ajc$";
- /**
- * Find and return the first AspectJ annotation on the given method
- * (there should only be one anyway...)
- */
- @SuppressWarnings("unchecked")
- protected static AspectJAnnotation> findAspectJAnnotationOnMethod(Method method) {
- Class>[] classesToLookFor = new Class>[] {
- Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
- for (Class> c : classesToLookFor) {
- AspectJAnnotation> foundAnnotation = findAnnotation(method, (Class) c);
- if (foundAnnotation != null) {
- return foundAnnotation;
- }
- }
- return null;
- }
-
- private static AspectJAnnotation findAnnotation(Method method, Class toLookFor) {
- A result = AnnotationUtils.findAnnotation(method, toLookFor);
- if (result != null) {
- return new AspectJAnnotation(result);
- }
- else {
- return null;
- }
- }
-
-
/** Logger available to subclasses */
protected final Log logger = LogFactory.getLog(getClass());
@@ -181,6 +153,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
throw new IllegalStateException("Expecting at least " + argNames.length +
" arguments in the advice declaration, but only found " + paramTypes.length);
}
+
// Make the simplifying assumption for now that all of the JoinPoint based arguments
// come first in the advice declaration.
int typeOffset = paramTypes.length - argNames.length;
@@ -191,7 +164,36 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
}
+ /**
+ * Find and return the first AspectJ annotation on the given method
+ * (there should only be one anyway...)
+ */
+ @SuppressWarnings("unchecked")
+ protected static AspectJAnnotation> findAspectJAnnotationOnMethod(Method method) {
+ Class>[] classesToLookFor = new Class>[] {
+ Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
+ for (Class> c : classesToLookFor) {
+ AspectJAnnotation> foundAnnotation = findAnnotation(method, (Class) c);
+ if (foundAnnotation != null) {
+ return foundAnnotation;
+ }
+ }
+ return null;
+ }
+
+ private static AspectJAnnotation findAnnotation(Method method, Class toLookFor) {
+ A result = AnnotationUtils.findAnnotation(method, toLookFor);
+ if (result != null) {
+ return new AspectJAnnotation(result);
+ }
+ else {
+ return null;
+ }
+ }
+
+
protected enum AspectJAnnotationType {
+
AtPointcut,
AtBefore,
AtAfter,
diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorFactory.java
index 36bf115105..7eba0606d5 100644
--- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorFactory.java
+++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -63,31 +63,31 @@ public interface AspectJAdvisorFactory {
/**
* Build Spring AOP Advisors for all annotated At-AspectJ methods
* on the specified aspect instance.
- * @param aif the aspect instance factory (not the aspect instance itself
- * in order to avoid eager instantiation)
+ * @param aspectInstanceFactory the aspect instance factory
+ * (not the aspect instance itself in order to avoid eager instantiation)
* @return a list of advisors for this class
*/
- List getAdvisors(MetadataAwareAspectInstanceFactory aif);
+ List getAdvisors(MetadataAwareAspectInstanceFactory aspectInstanceFactory);
/**
* Build a Spring AOP Advisor for the given AspectJ advice method.
* @param candidateAdviceMethod the candidate advice method
- * @param aif the aspect instance factory
- * @param declarationOrderInAspect the declaration order within the aspect
+ * @param aspectInstanceFactory the aspect instance factory
+ * @param declarationOrder the declaration order within the aspect
* @param aspectName the name of the aspect
* @return {@code null} if the method is not an AspectJ advice method
* or if it is a pointcut that will be used by other advice but will not
* create a Spring advice in its own right
*/
- Advisor getAdvisor(Method candidateAdviceMethod,
- MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName);
+ Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
+ int declarationOrder, String aspectName);
/**
* Build a Spring AOP Advice for the given AspectJ advice method.
* @param candidateAdviceMethod the candidate advice method
- * @param pointcut the corresponding AspectJ expression pointcut
- * @param aif the aspect instance factory
- * @param declarationOrderInAspect the declaration order within the aspect
+ * @param expressionPointcut the AspectJ expression pointcut
+ * @param aspectInstanceFactory the aspect instance factory
+ * @param declarationOrder the declaration order within the aspect
* @param aspectName the name of the aspect
* @return {@code null} if the method is not an AspectJ advice method
* or if it is a pointcut that will be used by other advice but will not
@@ -98,7 +98,7 @@ public interface AspectJAdvisorFactory {
* @see org.springframework.aop.aspectj.AspectJAfterReturningAdvice
* @see org.springframework.aop.aspectj.AspectJAfterThrowingAdvice
*/
- Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut pointcut,
- MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName);
+ Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut expressionPointcut,
+ MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName);
}
diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java
index b58d4ffc1f..27d3a9ba43 100644
--- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java
+++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java
@@ -54,7 +54,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
private transient Method aspectJAdviceMethod;
- private final AspectJAdvisorFactory atAspectJAdvisorFactory;
+ private final AspectJAdvisorFactory aspectJAdvisorFactory;
private final MetadataAwareAspectInstanceFactory aspectInstanceFactory;
@@ -73,28 +73,30 @@ class InstantiationModelAwarePointcutAdvisorImpl
private Boolean isAfterAdvice;
- public InstantiationModelAwarePointcutAdvisorImpl(AspectJAdvisorFactory af, AspectJExpressionPointcut ajexp,
- MetadataAwareAspectInstanceFactory aif, Method method, int declarationOrderInAspect, String aspectName) {
+ public InstantiationModelAwarePointcutAdvisorImpl(AspectJExpressionPointcut declaredPointcut,
+ Method aspectJAdviceMethod, AspectJAdvisorFactory aspectJAdvisorFactory,
+ MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName) {
- this.declaredPointcut = ajexp;
- this.declaringClass = method.getDeclaringClass();
- this.methodName = method.getName();
- this.parameterTypes = method.getParameterTypes();
- this.aspectJAdviceMethod = method;
- this.atAspectJAdvisorFactory = af;
- this.aspectInstanceFactory = aif;
- this.declarationOrder = declarationOrderInAspect;
+ this.declaredPointcut = declaredPointcut;
+ this.declaringClass = aspectJAdviceMethod.getDeclaringClass();
+ this.methodName = aspectJAdviceMethod.getName();
+ this.parameterTypes = aspectJAdviceMethod.getParameterTypes();
+ this.aspectJAdviceMethod = aspectJAdviceMethod;
+ this.aspectJAdvisorFactory = aspectJAdvisorFactory;
+ this.aspectInstanceFactory = aspectInstanceFactory;
+ this.declarationOrder = declarationOrder;
this.aspectName = aspectName;
- if (aif.getAspectMetadata().isLazilyInstantiated()) {
+ if (aspectInstanceFactory.getAspectMetadata().isLazilyInstantiated()) {
// Static part of the pointcut is a lazy type.
- Pointcut preInstantiationPointcut =
- Pointcuts.union(aif.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut);
+ Pointcut preInstantiationPointcut = Pointcuts.union(
+ aspectInstanceFactory.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut);
// Make it dynamic: must mutate from pre-instantiation to post-instantiation state.
// If it's not a dynamic pointcut, it may be optimized out
// by the Spring AOP infrastructure after the first evaluation.
- this.pointcut = new PerTargetInstantiationModelPointcut(this.declaredPointcut, preInstantiationPointcut, aif);
+ this.pointcut = new PerTargetInstantiationModelPointcut(
+ this.declaredPointcut, preInstantiationPointcut, aspectInstanceFactory);
this.lazy = true;
}
else {
@@ -155,7 +157,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
private Advice instantiateAdvice(AspectJExpressionPointcut pcut) {
- return this.atAspectJAdvisorFactory.getAdvice(this.aspectJAdviceMethod, pcut,
+ return this.aspectJAdvisorFactory.getAdvice(this.aspectJAdviceMethod, pcut,
this.aspectInstanceFactory, this.declarationOrder, this.aspectName);
}
@@ -279,7 +281,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
}
@Override
- public boolean matches(Method method, Class> targetClass, Object[] args) {
+ public boolean matches(Method method, Class> targetClass, Object... args) {
// This can match only on declared pointcut.
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass));
}
diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java
index 825cb0ceab..ce139f710d 100644
--- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java
+++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java
@@ -79,8 +79,9 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
new Converter() {
@Override
public Annotation convert(Method method) {
- AspectJAnnotation> annotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
- return annotation == null ? null : annotation.getAnnotation();
+ AspectJAnnotation> annotation =
+ AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
+ return (annotation != null ? annotation.getAnnotation() : null);
}
}));
comparator.addComparator(new ConvertingComparator(
@@ -95,17 +96,17 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
@Override
- public List getAdvisors(MetadataAwareAspectInstanceFactory maaif) {
- final Class> aspectClass = maaif.getAspectMetadata().getAspectClass();
- final String aspectName = maaif.getAspectMetadata().getAspectName();
+ public List getAdvisors(MetadataAwareAspectInstanceFactory aspectInstanceFactory) {
+ Class> aspectClass = aspectInstanceFactory.getAspectMetadata().getAspectClass();
+ String aspectName = aspectInstanceFactory.getAspectMetadata().getAspectName();
validate(aspectClass);
// We need to wrap the MetadataAwareAspectInstanceFactory with a decorator
// so that it will only instantiate once.
- final MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory =
- new LazySingletonAspectInstanceFactoryDecorator(maaif);
+ MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory =
+ new LazySingletonAspectInstanceFactoryDecorator(aspectInstanceFactory);
- final List advisors = new LinkedList();
+ List advisors = new LinkedList();
for (Method method : getAdvisorMethods(aspectClass)) {
Advisor advisor = getAdvisor(method, lazySingletonAspectInstanceFactory, advisors.size(), aspectName);
if (advisor != null) {
@@ -171,18 +172,19 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
@Override
- public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aif,
+ public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
int declarationOrderInAspect, String aspectName) {
- validate(aif.getAspectMetadata().getAspectClass());
+ validate(aspectInstanceFactory.getAspectMetadata().getAspectClass());
- AspectJExpressionPointcut ajexp =
- getPointcut(candidateAdviceMethod, aif.getAspectMetadata().getAspectClass());
- if (ajexp == null) {
+ AspectJExpressionPointcut expressionPointcut = getPointcut(
+ candidateAdviceMethod, aspectInstanceFactory.getAspectMetadata().getAspectClass());
+ if (expressionPointcut == null) {
return null;
}
- return new InstantiationModelAwarePointcutAdvisorImpl(
- this, ajexp, aif, candidateAdviceMethod, declarationOrderInAspect, aspectName);
+
+ return new InstantiationModelAwarePointcutAdvisorImpl(expressionPointcut, candidateAdviceMethod,
+ this, aspectInstanceFactory, declarationOrderInAspect, aspectName);
}
private AspectJExpressionPointcut getPointcut(Method candidateAdviceMethod, Class> candidateAspectClass) {
@@ -191,6 +193,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
if (aspectJAnnotation == null) {
return null;
}
+
AspectJExpressionPointcut ajexp =
new AspectJExpressionPointcut(candidateAspectClass, new String[0], new Class>[0]);
ajexp.setExpression(aspectJAnnotation.getPointcutExpression());
@@ -199,10 +202,10 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
@Override
- public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut ajexp,
- MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName) {
+ public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut expressionPointcut,
+ MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName) {
- Class> candidateAspectClass = aif.getAspectMetadata().getAspectClass();
+ Class> candidateAspectClass = aspectInstanceFactory.getAspectMetadata().getAspectClass();
validate(candidateAspectClass);
AspectJAnnotation> aspectJAnnotation =
@@ -227,27 +230,32 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
switch (aspectJAnnotation.getAnnotationType()) {
case AtBefore:
- springAdvice = new AspectJMethodBeforeAdvice(candidateAdviceMethod, ajexp, aif);
+ springAdvice = new AspectJMethodBeforeAdvice(
+ candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
break;
case AtAfter:
- springAdvice = new AspectJAfterAdvice(candidateAdviceMethod, ajexp, aif);
+ springAdvice = new AspectJAfterAdvice(
+ candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
break;
case AtAfterReturning:
- springAdvice = new AspectJAfterReturningAdvice(candidateAdviceMethod, ajexp, aif);
+ springAdvice = new AspectJAfterReturningAdvice(
+ candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
AfterReturning afterReturningAnnotation = (AfterReturning) aspectJAnnotation.getAnnotation();
if (StringUtils.hasText(afterReturningAnnotation.returning())) {
springAdvice.setReturningName(afterReturningAnnotation.returning());
}
break;
case AtAfterThrowing:
- springAdvice = new AspectJAfterThrowingAdvice(candidateAdviceMethod, ajexp, aif);
+ springAdvice = new AspectJAfterThrowingAdvice(
+ candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
AfterThrowing afterThrowingAnnotation = (AfterThrowing) aspectJAnnotation.getAnnotation();
if (StringUtils.hasText(afterThrowingAnnotation.throwing())) {
springAdvice.setThrowingName(afterThrowingAnnotation.throwing());
}
break;
case AtAround:
- springAdvice = new AspectJAroundAdvice(candidateAdviceMethod, ajexp, aif);
+ springAdvice = new AspectJAroundAdvice(
+ candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
break;
case AtPointcut:
if (logger.isDebugEnabled()) {
@@ -256,12 +264,12 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
return null;
default:
throw new UnsupportedOperationException(
- "Unsupported advice type on method " + candidateAdviceMethod);
+ "Unsupported advice type on method: " + candidateAdviceMethod);
}
// Now to configure the advice...
springAdvice.setAspectName(aspectName);
- springAdvice.setDeclarationOrder(declarationOrderInAspect);
+ springAdvice.setDeclarationOrder(declarationOrder);
String[] argNames = this.parameterNameDiscoverer.getParameterNames(candidateAdviceMethod);
if (argNames != null) {
springAdvice.setArgumentNamesFromStringArray(argNames);
@@ -270,6 +278,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
return springAdvice;
}
+
/**
* Synthetic advisor that instantiates the aspect.
* Triggered by per-clause pointcut on non-singleton aspect.
diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
index ed95bd96de..9b3b307467 100644
--- a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
+++ b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -113,7 +113,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
* Create a AdvisedSupport instance with the given parameters.
* @param interfaces the proxied interfaces
*/
- public AdvisedSupport(Class>[] interfaces) {
+ public AdvisedSupport(Class>... interfaces) {
this();
setInterfaces(interfaces);
}
diff --git a/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java
index d41a36c250..1989a6dae4 100644
--- a/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java
+++ b/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -91,17 +91,17 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
}
@Override
- public boolean matches(Method method, Class> targetClass, Object[] args) {
- ++this.evaluations;
+ public boolean matches(Method method, Class> targetClass, Object... args) {
+ this.evaluations++;
ControlFlow cflow = ControlFlowFactory.createControlFlow();
- return (this.methodName != null) ? cflow.under(this.clazz, this.methodName) : cflow.under(this.clazz);
+ return (this.methodName != null ? cflow.under(this.clazz, this.methodName) : cflow.under(this.clazz));
}
/**
* It's useful to know how many times we've fired, for optimization.
*/
public int getEvaluations() {
- return evaluations;
+ return this.evaluations;
}
@@ -115,6 +115,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
return this;
}
+
@Override
public boolean equals(Object other) {
if (this == other) {
diff --git a/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java b/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java
index b71e2c2399..9a64d07431 100644
--- a/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java
+++ b/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -138,7 +138,7 @@ public abstract class MethodMatchers {
}
@Override
- public boolean matches(Method method, Class> targetClass, Object[] args) {
+ public boolean matches(Method method, Class> targetClass, Object... args) {
return this.mm1.matches(method, targetClass, args) || this.mm2.matches(method, targetClass, args);
}
@@ -245,7 +245,7 @@ public abstract class MethodMatchers {
}
@Override
- public boolean matches(Method method, Class> targetClass, Object[] args) {
+ public boolean matches(Method method, Class> targetClass, Object... args) {
// Because a dynamic intersection may be composed of a static and dynamic part,
// we must avoid calling the 3-arg matches method on a dynamic matcher, as
// it will probably be an unsupported operation.
diff --git a/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java b/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java
index df6e57bfa4..b17977ba48 100644
--- a/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java
+++ b/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -71,7 +71,7 @@ public abstract class Pointcuts {
* @param args arguments to the method
* @return whether there's a runtime match
*/
- public static boolean matches(Pointcut pointcut, Method method, Class> targetClass, Object[] args) {
+ public static boolean matches(Pointcut pointcut, Method method, Class> targetClass, Object... args) {
Assert.notNull(pointcut, "Pointcut must not be null");
if (pointcut == Pointcut.TRUE) {
return true;
@@ -98,9 +98,9 @@ public abstract class Pointcuts {
@Override
public boolean matches(Method method, Class> targetClass) {
- return method.getName().startsWith("set") &&
- method.getParameterTypes().length == 1 &&
- method.getReturnType() == Void.TYPE;
+ return (method.getName().startsWith("set") &&
+ method.getParameterTypes().length == 1 &&
+ method.getReturnType() == Void.TYPE);
}
private Object readResolve() {
@@ -119,8 +119,8 @@ public abstract class Pointcuts {
@Override
public boolean matches(Method method, Class> targetClass) {
- return method.getName().startsWith("get") &&
- method.getParameterTypes().length == 0;
+ return (method.getName().startsWith("get") &&
+ method.getParameterTypes().length == 0);
}
private Object readResolve() {
diff --git a/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java
index 8bb1d74d73..0627248ee9 100644
--- a/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java
+++ b/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -32,7 +32,7 @@ public abstract class StaticMethodMatcher implements MethodMatcher {
}
@Override
- public final boolean matches(Method method, Class> targetClass, Object[] args) {
+ public final boolean matches(Method method, Class> targetClass, Object... args) {
// should never be invoked because isRuntime() returns false
throw new UnsupportedOperationException("Illegal MethodMatcher usage");
}
diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java
index 6419fbe774..28622ba8d2 100644
--- a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -53,17 +53,15 @@ public final class AspectJExpressionPointcutTests {
private Method setSomeNumber;
- private Method isPostProcessed;
-
@Before
public void setUp() throws NoSuchMethodException {
- getAge = TestBean.class.getMethod("getAge", (Class>[])null);
- setAge = TestBean.class.getMethod("setAge", new Class[]{int.class});
- setSomeNumber = TestBean.class.getMethod("setSomeNumber", new Class[]{Number.class});
- isPostProcessed = TestBean.class.getMethod("isPostProcessed", (Class[]) null);
+ getAge = TestBean.class.getMethod("getAge");
+ setAge = TestBean.class.getMethod("setAge", int.class);
+ setSomeNumber = TestBean.class.getMethod("setSomeNumber", Number.class);
}
+
@Test
public void testMatchExplicit() {
String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
@@ -111,21 +109,9 @@ public final class AspectJExpressionPointcutTests {
testThisOrTarget("target");
}
- public static class OtherIOther implements IOther {
-
- @Override
- public void absquatulate() {
- // Empty
- }
-
- }
-
/**
* This and target are equivalent. Really instanceof pointcuts.
* @param which this or target
- * @throws Exception
- * @throws NoSuchMethodException
- * @throws SecurityException
*/
private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException {
String matchesTestBean = which + "(org.springframework.tests.sample.beans.TestBean)";
@@ -138,11 +124,8 @@ public final class AspectJExpressionPointcutTests {
assertTrue(testBeanPc.matches(TestBean.class));
assertTrue(testBeanPc.matches(getAge, TestBean.class));
- assertTrue(iOtherPc.matches(OtherIOther.class.getMethod("absquatulate", (Class>[])null),
- OtherIOther.class));
-
- assertFalse(testBeanPc.matches(OtherIOther.class.getMethod("absquatulate", (Class>[])null),
- OtherIOther.class));
+ assertTrue(iOtherPc.matches(OtherIOther.class.getMethod("absquatulate"), OtherIOther.class));
+ assertFalse(testBeanPc.matches(OtherIOther.class.getMethod("absquatulate"), OtherIOther.class));
}
@Test
@@ -171,8 +154,7 @@ public final class AspectJExpressionPointcutTests {
assertEquals(matchSubpackages, withinBeansPc.matches(
DeepBean.class.getMethod("aMethod", String.class), DeepBean.class));
assertFalse(withinBeansPc.matches(String.class));
- assertFalse(withinBeansPc.matches(OtherIOther.class.getMethod("absquatulate", (Class>[])null),
- OtherIOther.class));
+ assertFalse(withinBeansPc.matches(OtherIOther.class.getMethod("absquatulate"), OtherIOther.class));
}
@Test
@@ -183,7 +165,7 @@ public final class AspectJExpressionPointcutTests {
fail();
}
catch (IllegalStateException ex) {
- assertTrue(ex.getMessage().indexOf("expression") != -1);
+ assertTrue(ex.getMessage().contains("expression"));
}
}
@@ -195,7 +177,7 @@ public final class AspectJExpressionPointcutTests {
fail();
}
catch (IllegalStateException ex) {
- assertTrue(ex.getMessage().indexOf("expression") != -1);
+ assertTrue(ex.getMessage().contains("expression"));
}
}
@@ -207,7 +189,7 @@ public final class AspectJExpressionPointcutTests {
fail();
}
catch (IllegalStateException ex) {
- assertTrue(ex.getMessage().indexOf("expression") != -1);
+ assertTrue(ex.getMessage().contains("expression"));
}
}
@@ -226,10 +208,10 @@ public final class AspectJExpressionPointcutTests {
//assertDoesNotMatchStringClass(classFilter);
assertTrue("Should match with setSomeNumber with Double input",
- methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Double(12)}));
+ methodMatcher.matches(setSomeNumber, TestBean.class, new Double(12)));
assertFalse("Should not match setSomeNumber with Integer input",
- methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Integer(11)}));
- assertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.class, null));
+ methodMatcher.matches(setSomeNumber, TestBean.class, new Integer(11)));
+ assertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.class));
assertTrue("Should be a runtime match", methodMatcher.isRuntime());
}
@@ -281,7 +263,6 @@ public final class AspectJExpressionPointcutTests {
}
catch (IllegalArgumentException ex) {
assertTrue(true);
- System.out.println(ex.getMessage());
}
}
@@ -326,16 +307,14 @@ public final class AspectJExpressionPointcutTests {
@Test
public void testAndSubstitution() {
Pointcut pc = getPointcut("execution(* *(..)) and args(String)");
- PointcutExpression expr =
- ((AspectJExpressionPointcut) pc).getPointcutExpression();
+ PointcutExpression expr = ((AspectJExpressionPointcut) pc).getPointcutExpression();
assertEquals("execution(* *(..)) && args(String)",expr.getPointcutExpression());
}
@Test
public void testMultipleAndSubstitutions() {
Pointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)");
- PointcutExpression expr =
- ((AspectJExpressionPointcut) pc).getPointcutExpression();
+ PointcutExpression expr = ((AspectJExpressionPointcut) pc).getPointcutExpression();
assertEquals("execution(* *(..)) && args(String) && this(Object)",expr.getPointcutExpression());
}
@@ -344,6 +323,15 @@ public final class AspectJExpressionPointcutTests {
pointcut.setExpression(expression);
return pointcut;
}
+
+
+ public static class OtherIOther implements IOther {
+
+ @Override
+ public void absquatulate() {
+ // Empty
+ }
+ }
}
diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java
index f14bee5dfc..ddb7c1afe2 100644
--- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -36,7 +36,7 @@ import static org.junit.Assert.*;
* @author Rod Johnson
* @author Chris Beams
*/
-public final class TigerAspectJExpressionPointcutTests {
+public class TigerAspectJExpressionPointcutTests {
// TODO factor into static in AspectJExpressionPointcut
private Method getAge;
@@ -46,7 +46,7 @@ public final class TigerAspectJExpressionPointcutTests {
@Before
public void setUp() throws NoSuchMethodException {
- getAge = TestBean.class.getMethod("getAge", (Class[]) null);
+ getAge = TestBean.class.getMethod("getAge");
// Assumes no overloading
for (Method m : HasGeneric.class.getMethods()) {
methodsOnHasGeneric.put(m.getName(), m);
@@ -54,18 +54,6 @@ public final class TigerAspectJExpressionPointcutTests {
}
- public static class HasGeneric {
-
- public void setFriends(List friends) {
- }
- public void setEnemies(List enemies) {
- }
- public void setPartners(List> partners) {
- }
- public void setPhoneNumbers(List numbers) {
- }
- }
-
@Test
public void testMatchGenericArgument() {
String expression = "execution(* set*(java.util.List) )";
@@ -132,15 +120,12 @@ public final class TigerAspectJExpressionPointcutTests {
public void testMatchAnnotationOnClassWithSubpackageWildcard() throws SecurityException, NoSuchMethodException {
String expression = "within(@(test.annotation..*) *)";
AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression);
- assertFalse(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class),
- TestBean.class));
- assertTrue(springAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
- SpringAnnotated.class));
+ assertFalse(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class), TestBean.class));
+ assertTrue(springAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo"), SpringAnnotated.class));
expression = "within(@(test.annotation.transaction..*) *)";
AspectJExpressionPointcut springTxAnnotatedPc = testMatchAnnotationOnClass(expression);
- assertFalse(springTxAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
- SpringAnnotated.class));
+ assertFalse(springTxAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo"), SpringAnnotated.class));
}
@Test
@@ -154,7 +139,7 @@ public final class TigerAspectJExpressionPointcutTests {
ajexp.setExpression(expression);
assertFalse(ajexp.matches(getAge, TestBean.class));
- assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
+ assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo"), HasTransactionalAnnotation.class));
assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
assertTrue(ajexp.matches(BeanB.class.getMethod("setName", String.class), BeanB.class));
assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
@@ -168,10 +153,10 @@ public final class TigerAspectJExpressionPointcutTests {
ajexp.setExpression(expression);
assertFalse(ajexp.matches(getAge, TestBean.class));
- assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
+ assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo"), HasTransactionalAnnotation.class));
assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
- assertTrue(ajexp.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
+ assertTrue(ajexp.matches(BeanA.class.getMethod("getAge"), BeanA.class));
assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
}
@@ -182,10 +167,10 @@ public final class TigerAspectJExpressionPointcutTests {
anySpringMethodAnnotation.setExpression(expression);
assertFalse(anySpringMethodAnnotation.matches(getAge, TestBean.class));
- assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
+ assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("foo"), HasTransactionalAnnotation.class));
assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
assertFalse(anySpringMethodAnnotation.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
- assertTrue(anySpringMethodAnnotation.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
+ assertTrue(anySpringMethodAnnotation.matches(BeanA.class.getMethod("getAge"), BeanA.class));
assertFalse(anySpringMethodAnnotation.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
}
@@ -196,10 +181,10 @@ public final class TigerAspectJExpressionPointcutTests {
takesSpringAnnotatedArgument2.setExpression(expression);
assertFalse(takesSpringAnnotatedArgument2.matches(getAge, TestBean.class));
- assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
+ assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo"), HasTransactionalAnnotation.class));
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
- assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
+ assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge"), BeanA.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
assertTrue(takesSpringAnnotatedArgument2.matches(
@@ -213,8 +198,7 @@ public final class TigerAspectJExpressionPointcutTests {
assertFalse(takesSpringAnnotatedArgument2.matches(
ProcessesSpringAnnotatedParameters.class.getMethod("takesNoAnnotatedParameters", TestBean.class, BeanA.class),
- ProcessesSpringAnnotatedParameters.class,
- new Object[] { new TestBean(), new BeanA()})
+ ProcessesSpringAnnotatedParameters.class, new TestBean(), new BeanA())
);
}
@@ -225,10 +209,10 @@ public final class TigerAspectJExpressionPointcutTests {
takesSpringAnnotatedArgument2.setExpression(expression);
assertFalse(takesSpringAnnotatedArgument2.matches(getAge, TestBean.class));
- assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
+ assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo"), HasTransactionalAnnotation.class));
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
- assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
+ assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge"), BeanA.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
assertTrue(takesSpringAnnotatedArgument2.matches(
@@ -240,6 +224,19 @@ public final class TigerAspectJExpressionPointcutTests {
}
+ public static class HasGeneric {
+
+ public void setFriends(List friends) {
+ }
+ public void setEnemies(List enemies) {
+ }
+ public void setPartners(List> partners) {
+ }
+ public void setPhoneNumbers(List numbers) {
+ }
+ }
+
+
public static class ProcessesSpringAnnotatedParameters {
public void takesAnnotatedParameters(TestBean tb, SpringAnnotated sa) {
diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java
index 6d925271ce..3f34ff592e 100644
--- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.aop.aspectj.annotation;
import java.io.FileNotFoundException;
@@ -961,7 +962,7 @@ abstract class AbstractMakeModifiable {
private Method getGetterFromSetter(Method setter) {
String getterName = setter.getName().replaceFirst("set", "get");
try {
- return setter.getDeclaringClass().getMethod(getterName, (Class[]) null);
+ return setter.getDeclaringClass().getMethod(getterName);
}
catch (NoSuchMethodException ex) {
// must be write only
diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java
index 3cf475bee4..2f84af9c41 100644
--- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java
@@ -41,9 +41,11 @@ public class AspectJPointcutAdvisorTests {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
- InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
+ InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(
+ ajexp, TestBean.class.getMethod("getAge"), af,
new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null), "someBean"),
- TestBean.class.getMethod("getAge", (Class[]) null), 1, "someBean");
+ 1, "someBean");
+
assertSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
assertFalse(ajpa.isPerInstance());
}
@@ -53,19 +55,21 @@ public class AspectJPointcutAdvisorTests {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
- InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
- new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(),"someBean"),
- TestBean.class.getMethod("getAge", (Class[]) null), 1, "someBean");
+ InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(
+ ajexp, TestBean.class.getMethod("getAge"), af,
+ new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(), "someBean"),
+ 1, "someBean");
+
assertNotSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut);
assertTrue(ajpa.isPerInstance());
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class));
assertFalse(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
- TestBean.class.getMethod("getAge", (Class[]) null), TestBean.class));
+ TestBean.class.getMethod("getAge"), TestBean.class));
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
- TestBean.class.getMethod("getSpouse", (Class[]) null), TestBean.class));
+ TestBean.class.getMethod("getSpouse"), TestBean.class));
}
@Test(expected = AopConfigException.class)
diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java
index 7083320483..2a7f726fb7 100644
--- a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -37,7 +37,7 @@ public final class MethodInvocationTests {
@Test
public void testValidInvocation() throws Throwable {
- Method m = Object.class.getMethod("hashCode", (Class[]) null);
+ Method m = Object.class.getMethod("hashCode");
Object proxy = new Object();
final Object returnValue = new Object();
List