diff options
author | acolyer <acolyer> | 2005-09-21 14:59:55 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-09-21 14:59:55 +0000 |
commit | a39f595c0cdcddf8eac0b99e1918d0578f2dc501 (patch) | |
tree | 94865da1d5f277582d9d0720347693cd3b3c258a /aspectj5rt/java5-src | |
parent | fc2d08e2ae9d03fb377bd0ed0bd56983af4687a5 (diff) | |
download | aspectj-a39f595c0cdcddf8eac0b99e1918d0578f2dc501.tar.gz aspectj-a39f595c0cdcddf8eac0b99e1918d0578f2dc501.zip |
tests and implementation for 108120 - runtime pointcut parsing and matching.
Diffstat (limited to 'aspectj5rt/java5-src')
4 files changed, 28 insertions, 2 deletions
diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java index 13b177f5f..58305aeb1 100644 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java +++ b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java @@ -418,7 +418,7 @@ public class AjTypeImpl<T> implements AjType { int nextDollar = name.indexOf("$"); if (nextDollar != -1) name = name.substring(0,nextDollar); } - return new PointcutImpl(name,pcAnn.value(),method,AjTypeSystem.getAjType(method.getDeclaringClass())); + return new PointcutImpl(name,pcAnn.value(),method,AjTypeSystem.getAjType(method.getDeclaringClass()),pcAnn.argNames()); } else { return null; } diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutImpl.java index e0c102f2f..defae8c59 100644 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutImpl.java +++ b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutImpl.java @@ -12,6 +12,7 @@ package org.aspectj.internal.lang.reflect; import java.lang.reflect.Method; +import java.util.StringTokenizer; import org.aspectj.lang.reflect.AjType; import org.aspectj.lang.reflect.Pointcut; @@ -27,12 +28,14 @@ public class PointcutImpl implements Pointcut { private final PointcutExpression pc; private final Method baseMethod; private final AjType declaringType; + private String[] parameterNames = new String[0]; - protected PointcutImpl(String name, String pc, Method method, AjType declaringType) { + protected PointcutImpl(String name, String pc, Method method, AjType declaringType, String pNames) { this.name = name; this.pc = new PointcutExpressionImpl(pc); this.baseMethod = method; this.declaringType = declaringType; + this.parameterNames = splitOnComma(pNames); } /* (non-Javadoc) @@ -57,5 +60,17 @@ public class PointcutImpl implements Pointcut { public AjType getDeclaringType() { return declaringType; } + + public String[] getParameterNames() { + return parameterNames; + } + private String[] splitOnComma(String s) { + StringTokenizer strTok = new StringTokenizer(s,","); + String[] ret = new String[strTok.countTokens()]; + for (int i = 0; i < ret.length; i++) { + ret[i] = strTok.nextToken().trim(); + } + return ret; + } } diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/Pointcut.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/Pointcut.java index 364066e06..ec4b3461e 100644 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/Pointcut.java +++ b/aspectj5rt/java5-src/org/aspectj/lang/annotation/Pointcut.java @@ -29,4 +29,13 @@ public @interface Pointcut { * The pointcut expression */ String value(); + + /** + * When compiling without debug info, or when interpreting pointcuts at runtime, + * the names of any arguments used in the pointcut are not available. + * Under these circumstances only, it is necessary to provide the arg names in + * the annotation - these MUST duplicate the names used in the annotated method. + * Format is a simple comma-separated list. + */ + String argNames() default ""; } diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/Pointcut.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/Pointcut.java index a82941306..c514bea01 100644 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/Pointcut.java +++ b/aspectj5rt/java5-src/org/aspectj/lang/reflect/Pointcut.java @@ -21,5 +21,7 @@ public interface Pointcut { Class<?>[] getParameterTypes(); + String[] getParameterNames(); + AjType getDeclaringType(); } |