]> source.dussan.org Git - aspectj.git/commitdiff
updates to reflection library (largely javadoc, but with a few small tweaks)
authoracolyer <acolyer>
Fri, 30 Sep 2005 14:58:56 +0000 (14:58 +0000)
committeracolyer <acolyer>
Fri, 30 Sep 2005 14:58:56 +0000 (14:58 +0000)
37 files changed:
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AdviceImpl.java
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareErrorOrWarningImpl.java
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PerClauseImpl.java
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutBasedPerClauseImpl.java [new file with mode: 0644]
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutExpressionImpl.java
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutImpl.java
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/SignaturePatternImpl.java [new file with mode: 0644]
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternBasedPerClauseImpl.java [new file with mode: 0644]
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternImpl.java [new file with mode: 0644]
aspectj5rt/java5-src/org/aspectj/lang/reflect/Advice.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/AdviceKind.java [new file with mode: 0644]
aspectj5rt/java5-src/org/aspectj/lang/reflect/AdviceType.java [deleted file]
aspectj5rt/java5-src/org/aspectj/lang/reflect/AjType.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/AjTypeSystem.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareAnnotation.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareErrorOrWarning.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareParents.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclarePrecedence.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareSoft.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/NoSuchAdviceException.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/NoSuchPointcutException.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/PerClause.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/PerClauseKind.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/Pointcut.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutBasedPerClause.java [new file with mode: 0644]
aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutExpression.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/SignaturePattern.java [new file with mode: 0644]
aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePattern.java [new file with mode: 0644]
aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePatternBasedPerClause.java [new file with mode: 0644]
aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTests.java
aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTestsWithAspects.java
lib/aspectj/lib/aspectjrt.jar
lib/test/aspectjrt.jar
tests/java5/ataspectj/annotationGen/PointcutsWithParams.aj
tests/java5/ataspectj/annotationGen/ReferencePointcuts.aj
weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java

index d46b0bf610bf8e1331c0e24741d79d34c3a693ed..7bfba4ca1ae4759acc3438fa4b1dc533eb3b19d8 100644 (file)
@@ -15,7 +15,9 @@ import java.lang.reflect.Method;
 
 import org.aspectj.lang.annotation.AdviceName;
 import org.aspectj.lang.reflect.Advice;
-import org.aspectj.lang.reflect.AdviceType;
+import org.aspectj.lang.reflect.AdviceKind;
+import org.aspectj.lang.reflect.AjType;
+import org.aspectj.lang.reflect.AjTypeSystem;
 import org.aspectj.lang.reflect.PointcutExpression;
 
 /**
@@ -24,17 +26,21 @@ import org.aspectj.lang.reflect.PointcutExpression;
  */
 public class AdviceImpl implements Advice {
 
-       private final AdviceType kind;
+       private final AdviceKind kind;
        private final Method adviceMethod;
        private PointcutExpression pointcutExpression;
        
-       protected AdviceImpl(Method method, String pointcut, AdviceType type) {
+       protected AdviceImpl(Method method, String pointcut, AdviceKind type) {
                this.kind = type;
                this.adviceMethod = method;
                this.pointcutExpression = new PointcutExpressionImpl(pointcut);
        }
        
-       public AdviceType getKind() {
+       public AjType getDeclaringType() {
+               return AjTypeSystem.getAjType(adviceMethod.getDeclaringClass());
+       }
+       
+       public AdviceKind getKind() {
                return kind;
        }
        
index 71c6c74880f64fbd7efa74f07ed97216df2c9ffd..bb5faf65532a47bb51806a7402b4b1e7d84ebb0a 100644 (file)
@@ -35,7 +35,7 @@ import org.aspectj.lang.annotation.Before;
 import org.aspectj.lang.annotation.DeclareError;
 import org.aspectj.lang.annotation.DeclareWarning;
 import org.aspectj.lang.reflect.Advice;
-import org.aspectj.lang.reflect.AdviceType;
+import org.aspectj.lang.reflect.AdviceKind;
 import org.aspectj.lang.reflect.AjType;
 import org.aspectj.lang.reflect.AjTypeSystem;
 import org.aspectj.lang.reflect.DeclareAnnotation;
@@ -88,8 +88,9 @@ public class AjTypeImpl<T> implements AjType<T> {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getInterfaces()
         */
-       public Class[] getInterfaces() {
-               return clazz.getInterfaces();
+       public AjType<?>[] getInterfaces() {
+               Class<?>[] baseInterfaces = clazz.getInterfaces();
+               return toAjTypeArray(baseInterfaces);
        }
 
        /* (non-Javadoc)
@@ -98,11 +99,15 @@ public class AjTypeImpl<T> implements AjType<T> {
        public int getModifiers() {
                return clazz.getModifiers();
        }
+       
+       public Class<T> getJavaClass() {
+               return clazz;
+       }
 
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getSupertype()
         */
-       public AjType getSupertype() {
+       public AjType<?> getSupertype() {
                return new AjTypeImpl(clazz.getSuperclass());
        }
 
@@ -130,7 +135,7 @@ public class AjTypeImpl<T> implements AjType<T> {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getEnclosingType()
         */
-       public AjType getEnclosingType() {
+       public AjType<?> getEnclosingType() {
                Class<?> enc = clazz.getEnclosingClass();
                return enc != null ? new AjTypeImpl(enc) : null;
        }
@@ -138,7 +143,7 @@ public class AjTypeImpl<T> implements AjType<T> {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getDeclaringType()
         */
-       public AjType getDeclaringType() {
+       public AjType<?> getDeclaringType() {
                Class dec = clazz.getDeclaringClass();
                return dec != null ? new AjTypeImpl(dec) : null;
        }
@@ -148,17 +153,20 @@ public class AjTypeImpl<T> implements AjType<T> {
                        Aspect aspectAnn = clazz.getAnnotation(Aspect.class);
                        String perClause = aspectAnn.value();
                        if (perClause.equals("")) {
-                               return new PerClauseImpl(PerClauseKind.SINGLETON,"");
+                               if (getSupertype().isAspect()) {
+                                       return getSupertype().getPerClause();
+                               } 
+                               return new PerClauseImpl(PerClauseKind.SINGLETON);
                        } else if (perClause.startsWith("perthis(")) {
-                               return new PerClauseImpl(PerClauseKind.PERTHIS,perClause.substring("perthis(".length(),perClause.length() - 1));
+                               return new PointcutBasedPerClauseImpl(PerClauseKind.PERTHIS,perClause.substring("perthis(".length(),perClause.length() - 1));
                        } else if (perClause.startsWith("pertarget(")) {
-                               return new PerClauseImpl(PerClauseKind.PERTARGET,perClause.substring("pertarget(".length(),perClause.length() - 1));                            
+                               return new PointcutBasedPerClauseImpl(PerClauseKind.PERTARGET,perClause.substring("pertarget(".length(),perClause.length() - 1));                               
                        } else if (perClause.startsWith("percflow(")) {
-                               return new PerClauseImpl(PerClauseKind.PERCFLOW,perClause.substring("percflow(".length(),perClause.length() - 1));                                                              
+                               return new PointcutBasedPerClauseImpl(PerClauseKind.PERCFLOW,perClause.substring("percflow(".length(),perClause.length() - 1));                                                         
                        } else if (perClause.startsWith("percflowbelow(")) {
-                               return new PerClauseImpl(PerClauseKind.PERCFLOWBELOW,perClause.substring("percflowbelow(".length(),perClause.length() - 1));
+                               return new PointcutBasedPerClauseImpl(PerClauseKind.PERCFLOWBELOW,perClause.substring("percflowbelow(".length(),perClause.length() - 1));
                        } else if (perClause.startsWith("pertypewithin")) {
-                               return new PerClauseImpl(PerClauseKind.PERTYPEWITHIN,perClause.substring("pertypewithin(".length(),perClause.length() - 1));                            
+                               return new TypePatternBasedPerClauseImpl(PerClauseKind.PERTYPEWITHIN,perClause.substring("pertypewithin(".length(),perClause.length() - 1));                            
                        } else {
                                throw new IllegalStateException("Per-clause not recognized: " + perClause);
                        }
@@ -195,32 +203,24 @@ public class AjTypeImpl<T> implements AjType<T> {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getAspects()
         */
-       public AjType[] getAjTypes() {
+       public AjType<?>[] getAjTypes() {
                Class[] classes = clazz.getClasses();
-               AjType[] ret = new AjType[classes.length];
-               for (int i = 0; i < ret.length; i++) {
-                       ret[i] = new AjTypeImpl(classes[i]);
-               }
-               return ret;
+               return toAjTypeArray(classes);
        }
 
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getDeclaredAspects()
         */
-       public AjType[] getDeclaredAjTypes() {
+       public AjType<?>[] getDeclaredAjTypes() {
                Class[] classes = clazz.getDeclaredClasses();
-               AjType[] ret = new AjType[classes.length];
-               for (int i = 0; i < ret.length; i++) {
-                       ret[i] = new AjTypeImpl(classes[i]);
-               }
-               return ret;
+               return toAjTypeArray(classes);
        }
 
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getConstructor(java.lang.Class...)
         */
-       public Constructor getConstructor(Class... parameterTypes) throws NoSuchMethodException {
-               return clazz.getConstructor(parameterTypes);
+       public Constructor getConstructor(AjType<?>... parameterTypes) throws NoSuchMethodException {
+               return clazz.getConstructor(toClassArray(parameterTypes));
        }
 
        /* (non-Javadoc)
@@ -233,8 +233,8 @@ public class AjTypeImpl<T> implements AjType<T> {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getDeclaredConstructor(java.lang.Class...)
         */
-       public Constructor getDeclaredConstructor(Class... parameterTypes) throws NoSuchMethodException {
-               return clazz.getDeclaredConstructor(parameterTypes);
+       public Constructor getDeclaredConstructor(AjType<?>... parameterTypes) throws NoSuchMethodException {
+               return clazz.getDeclaredConstructor(toClassArray(parameterTypes));
        }
 
        /* (non-Javadoc)
@@ -274,7 +274,7 @@ public class AjTypeImpl<T> implements AjType<T> {
         * @see org.aspectj.lang.reflect.AjType#getField(java.lang.String)
         */
        public Field getField(String name)  throws NoSuchFieldException {
-               Field f =  clazz.getDeclaredField(name);
+               Field f =  clazz.getField(name);
                if (f.getName().startsWith(ajcMagic)) throw new NoSuchFieldException(name);
                return f;
        }
@@ -299,8 +299,8 @@ public class AjTypeImpl<T> implements AjType<T> {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getDeclaredMethod(java.lang.String, java.lang.Class...)
         */
-       public Method getDeclaredMethod(String name, Class... parameterTypes) throws NoSuchMethodException {
-               Method m =  clazz.getDeclaredMethod(name,parameterTypes);
+       public Method getDeclaredMethod(String name, AjType<?>... parameterTypes) throws NoSuchMethodException {
+               Method m =  clazz.getDeclaredMethod(name,toClassArray(parameterTypes));
                if (!isReallyAMethod(m)) throw new NoSuchMethodException(name);
                return m;
        }
@@ -308,8 +308,8 @@ public class AjTypeImpl<T> implements AjType<T> {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getMethod(java.lang.String, java.lang.Class...)
         */
-       public Method getMethod(String name, Class... parameterTypes) throws NoSuchMethodException {
-               Method m =  clazz.getMethod(name,parameterTypes);
+       public Method getMethod(String name, AjType<?>... parameterTypes) throws NoSuchMethodException {
+               Method m =  clazz.getMethod(name,toClassArray(parameterTypes));
                if (!isReallyAMethod(m)) throw new NoSuchMethodException(name);
                return m;
        }
@@ -367,7 +367,7 @@ public class AjTypeImpl<T> implements AjType<T> {
         * @see org.aspectj.lang.reflect.AjType#getPointcut(java.lang.String)
         */
        public Pointcut getPointcut(String name) throws NoSuchPointcutException {
-               Pointcut[] pcs = getDeclaredPointcuts();
+               Pointcut[] pcs = getPointcuts();
                for (Pointcut pc : pcs)
                        if (pc.getName().equals(name)) return pc;
                throw new NoSuchPointcutException(name);
@@ -425,23 +425,23 @@ public class AjTypeImpl<T> implements AjType<T> {
        }
        
        
-       public Advice[] getDeclaredAdvice(AdviceType... ofType) {
-               Set<AdviceType> types;
+       public Advice[] getDeclaredAdvice(AdviceKind... ofType) {
+               Set<AdviceKind> types;
                if (ofType.length == 0) {
-                       types = EnumSet.allOf(AdviceType.class);
+                       types = EnumSet.allOf(AdviceKind.class);
                } else {
-                       types = EnumSet.noneOf(AdviceType.class);
+                       types = EnumSet.noneOf(AdviceKind.class);
                        types.addAll(Arrays.asList(ofType));
                }
                return getDeclaredAdvice(types);
        }
        
-       public Advice[] getAdvice(AdviceType... ofType) {
-               Set<AdviceType> types;
+       public Advice[] getAdvice(AdviceKind... ofType) {
+               Set<AdviceKind> types;
                if (ofType.length == 0) {
-                       types = EnumSet.allOf(AdviceType.class);
+                       types = EnumSet.allOf(AdviceKind.class);
                } else {
-                       types = EnumSet.noneOf(AdviceType.class);
+                       types = EnumSet.noneOf(AdviceKind.class);
                        types.addAll(Arrays.asList(ofType));
                }
                return getAdvice(types);
@@ -487,7 +487,7 @@ public class AjTypeImpl<T> implements AjType<T> {
        }
 
        private void initAdvice() {
-               Method[] methods = clazz.getDeclaredMethods();
+               Method[] methods = clazz.getMethods();
                List<Advice> adviceList = new ArrayList<Advice>();
                for (Method method : methods) {
                        Advice advice = asAdvice(method);
@@ -519,23 +519,23 @@ public class AjTypeImpl<T> implements AjType<T> {
        private Advice asAdvice(Method method) {
                if (method.getAnnotations().length == 0) return null;
                Before beforeAnn = method.getAnnotation(Before.class);
-               if (beforeAnn != null) return new AdviceImpl(method,beforeAnn.value(),AdviceType.BEFORE);
+               if (beforeAnn != null) return new AdviceImpl(method,beforeAnn.value(),AdviceKind.BEFORE);
                After afterAnn = method.getAnnotation(After.class);
-               if (afterAnn != null) return new AdviceImpl(method,afterAnn.value(),AdviceType.AFTER);
+               if (afterAnn != null) return new AdviceImpl(method,afterAnn.value(),AdviceKind.AFTER);
                AfterReturning afterReturningAnn = method.getAnnotation(AfterReturning.class);
                if (afterReturningAnn != null) {
                        String pcExpr = afterReturningAnn.pointcut();
                        if (pcExpr.equals("")) pcExpr = afterReturningAnn.value();
-                       return new AdviceImpl(method,pcExpr,AdviceType.AFTER_RETURNING);
+                       return new AdviceImpl(method,pcExpr,AdviceKind.AFTER_RETURNING);
                }
                AfterThrowing afterThrowingAnn = method.getAnnotation(AfterThrowing.class);
                if (afterThrowingAnn != null) {
                        String pcExpr = afterThrowingAnn.pointcut();
                        if (pcExpr == null) pcExpr = afterThrowingAnn.value();
-                       return new AdviceImpl(method,pcExpr,AdviceType.AFTER_THROWING);
+                       return new AdviceImpl(method,pcExpr,AdviceKind.AFTER_THROWING);
                }
                Around aroundAnn = method.getAnnotation(Around.class);
-               if (aroundAnn != null) return new AdviceImpl(method,aroundAnn.value(),AdviceType.AROUND);
+               if (aroundAnn != null) return new AdviceImpl(method,aroundAnn.value(),AdviceKind.AROUND);
                return null;
        }
        
@@ -543,7 +543,7 @@ public class AjTypeImpl<T> implements AjType<T> {
         * @see org.aspectj.lang.reflect.AjType#getDeclaredITDMethod(java.lang.String, java.lang.Class, java.lang.Class...)
         */
        public InterTypeMethodDeclaration getDeclaredITDMethod(String name,
-                       Class target, Class... parameterTypes) {
+                       AjType<?> target, AjType<?>... parameterTypes) {
                // TODO Auto-generated method stub
                return null;
        }
@@ -559,8 +559,8 @@ public class AjTypeImpl<T> implements AjType<T> {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getITDMethod(java.lang.String, java.lang.Class, java.lang.Class...)
         */
-       public InterTypeMethodDeclaration getITDMethod(String name, Class target,
-                       Class... parameterTypes) {
+       public InterTypeMethodDeclaration getITDMethod(String name, AjType<?> target,
+                       AjType<?>... parameterTypes) {
                // TODO Auto-generated method stub
                return null;
        }
@@ -577,7 +577,7 @@ public class AjTypeImpl<T> implements AjType<T> {
         * @see org.aspectj.lang.reflect.AjType#getDeclaredITDConstructor(java.lang.Class, java.lang.Class...)
         */
        public InterTypeConstructorDeclaration getDeclaredITDConstructor(
-                       Class target, Class... parameterTypes) {
+                       AjType<?> target, AjType<?>... parameterTypes) {
                // TODO Auto-generated method stub
                return null;
        }
@@ -593,8 +593,8 @@ public class AjTypeImpl<T> implements AjType<T> {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getITDConstructor(java.lang.Class, java.lang.Class...)
         */
-       public InterTypeConstructorDeclaration getITDConstructor(Class target,
-                       Class... parameterTypes) {
+       public InterTypeConstructorDeclaration getITDConstructor(AjType<?> target,
+                       AjType<?>... parameterTypes) {
                // TODO Auto-generated method stub
                return null;
        }
@@ -611,7 +611,7 @@ public class AjTypeImpl<T> implements AjType<T> {
         * @see org.aspectj.lang.reflect.AjType#getDeclaredITDField(java.lang.String, java.lang.Class)
         */
        public InterTypeFieldDeclaration getDeclaredITDField(String name,
-                       Class target) {
+                       AjType<?> target) {
                // TODO Auto-generated method stub
                return null;
        }
@@ -627,7 +627,7 @@ public class AjTypeImpl<T> implements AjType<T> {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.AjType#getITDField(java.lang.String, java.lang.Class)
         */
-       public InterTypeFieldDeclaration getITDField(String name, Class target) {
+       public InterTypeFieldDeclaration getITDField(String name, AjType<?> target) {
                // TODO Auto-generated method stub
                return null;
        }
@@ -651,14 +651,14 @@ public class AjTypeImpl<T> implements AjType<T> {
                                         DeclareWarning dw = field.getAnnotation(DeclareWarning.class);
                                         if (Modifier.isPublic(field.getModifiers()) && Modifier.isStatic(field.getModifiers())) {
                                                 String message = (String) field.get(null);
-                                                DeclareErrorOrWarningImpl deow = new DeclareErrorOrWarningImpl(dw.value(),message,false);
+                                                DeclareErrorOrWarningImpl deow = new DeclareErrorOrWarningImpl(dw.value(),message,false,this);
                                                 deows.add(deow);
                                         } 
                                } else if (field.isAnnotationPresent(DeclareError.class)) {
                                         DeclareError de = field.getAnnotation(DeclareError.class);
                                         if (Modifier.isPublic(field.getModifiers()) && Modifier.isStatic(field.getModifiers())) {
                                                 String message = (String) field.get(null);
-                                                DeclareErrorOrWarningImpl deow = new DeclareErrorOrWarningImpl(de.value(),message,true);
+                                                DeclareErrorOrWarningImpl deow = new DeclareErrorOrWarningImpl(de.value(),message,true,this);
                                                 deows.add(deow);
                                         }                              
                                }
@@ -671,7 +671,7 @@ public class AjTypeImpl<T> implements AjType<T> {
                for (Method method : clazz.getDeclaredMethods()) {
                        if (method.isAnnotationPresent(ajcDeclareEoW.class)) {
                                ajcDeclareEoW deowAnn = method.getAnnotation(ajcDeclareEoW.class);
-                               DeclareErrorOrWarning deow = new DeclareErrorOrWarningImpl(deowAnn.pointcut(),deowAnn.message(),deowAnn.isError());
+                               DeclareErrorOrWarning deow = new DeclareErrorOrWarningImpl(deowAnn.pointcut(),deowAnn.message(),deowAnn.isError(),this);
                                deows.add(deow);
                        }
                }
@@ -803,5 +803,21 @@ public class AjTypeImpl<T> implements AjType<T> {
        public int hashCode() {
                return clazz.hashCode();
        }
+       
+       private AjType<?>[] toAjTypeArray(Class<?>[] classes) {
+               AjType<?>[] ajtypes = new AjType<?>[classes.length];
+               for (int i = 0; i < ajtypes.length; i++) {
+                       ajtypes[i] = AjTypeSystem.getAjType(classes[i]);
+               }
+               return ajtypes;
+       }
+       
+       private Class<?>[] toClassArray(AjType<?>[] ajTypes) {
+               Class<?>[] classes = new Class<?>[ajTypes.length];
+               for (int i = 0; i < classes.length; i++) {
+                       classes[i] = ajTypes[i].getJavaClass();
+               }
+               return classes;
+       }
 
 }
index 03ea6d40c217c60ddf4f1474864944a9f511f7b3..f474698eada42d25233b404cac7228b5bbe081ca 100644 (file)
@@ -11,6 +11,7 @@
  * ******************************************************************/
 package org.aspectj.internal.lang.reflect;
 
+import org.aspectj.lang.reflect.AjType;
 import org.aspectj.lang.reflect.DeclareErrorOrWarning;
 import org.aspectj.lang.reflect.PointcutExpression;
 
@@ -23,13 +24,17 @@ public class DeclareErrorOrWarningImpl implements DeclareErrorOrWarning {
        private PointcutExpression pc;
        private String msg;
        private boolean isError;
+       private AjType declaringType;
        
-       public DeclareErrorOrWarningImpl(String pointcut, String message, boolean isError) {
+       public DeclareErrorOrWarningImpl(String pointcut, String message, boolean isError, AjType decType) {
                this.pc = new PointcutExpressionImpl(pointcut);
                this.msg = message;
                this.isError = isError;
+               this.declaringType = decType;
        }
        
+       public AjType getDeclaringType() { return this.declaringType; }
+       
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.DeclareErrorOrWarning#getPointcutExpression()
         */
index 819d044bf1b91d35051db263c509647119c90997..779e3a46e551df5c5f19bdf0fe57ce448f578e07 100644 (file)
@@ -13,7 +13,6 @@ package org.aspectj.internal.lang.reflect;
 
 import org.aspectj.lang.reflect.PerClause;
 import org.aspectj.lang.reflect.PerClauseKind;
-import org.aspectj.lang.reflect.PointcutExpression;
 
 /**
  * @author colyer
@@ -22,11 +21,9 @@ import org.aspectj.lang.reflect.PointcutExpression;
 public class PerClauseImpl implements PerClause {
 
        private final PerClauseKind kind;
-       private final PointcutExpression pointcutExpression;
        
-       protected PerClauseImpl(PerClauseKind kind, String pointcutExpression) {
+       protected PerClauseImpl(PerClauseKind kind) {
                this.kind = kind;
-               this.pointcutExpression = new PointcutExpressionImpl(pointcutExpression);
        }
        
        /* (non-Javadoc)
@@ -36,11 +33,4 @@ public class PerClauseImpl implements PerClause {
                return kind;
        }
 
-       /* (non-Javadoc)
-        * @see org.aspectj.lang.reflect.PerClause#getPointcutExpression()
-        */
-       public PointcutExpression getPointcutExpression() {
-               return pointcutExpression;
-       }
-
 }
diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutBasedPerClauseImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutBasedPerClauseImpl.java
new file mode 100644 (file)
index 0000000..3e3eb2f
--- /dev/null
@@ -0,0 +1,37 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.internal.lang.reflect;
+
+import org.aspectj.lang.reflect.PerClauseKind;
+import org.aspectj.lang.reflect.PointcutBasedPerClause;
+import org.aspectj.lang.reflect.PointcutExpression;
+
+/**
+ * @author colyer
+ *
+ */
+public class PointcutBasedPerClauseImpl extends PerClauseImpl implements
+               PointcutBasedPerClause {
+
+       private final PointcutExpression pointcutExpression;
+
+       public PointcutBasedPerClauseImpl(PerClauseKind kind,
+                       String pointcutExpression) {
+               super(kind);
+               this.pointcutExpression = new PointcutExpressionImpl(pointcutExpression);
+       }
+       
+       public PointcutExpression getPointcutExpression() {
+               return pointcutExpression;
+       }
+
+}
index e31bd1949686db6c68b9b63d08b9c1205de5c1b9..facf7d99dfc21191d30f66ba3c12e463be7aacb7 100644 (file)
@@ -24,7 +24,9 @@ public class PointcutExpressionImpl implements PointcutExpression {
                this.expression = aPointcutExpression;
        }
        
-       public String toString() {
+       public String asString() {
                return expression;
        }
+       
+       public String toString() { return asString(); }
 }
index defae8c591b6917ffac9a53c3343f643891c83e9..63c8764a3bfc60f58b33892d60681cc4b82f401f 100644 (file)
@@ -15,6 +15,7 @@ import java.lang.reflect.Method;
 import java.util.StringTokenizer;
 
 import org.aspectj.lang.reflect.AjType;
+import org.aspectj.lang.reflect.AjTypeSystem;
 import org.aspectj.lang.reflect.Pointcut;
 import org.aspectj.lang.reflect.PointcutExpression;
 
@@ -53,8 +54,13 @@ public class PointcutImpl implements Pointcut {
                return baseMethod.getModifiers();
        }
 
-       public Class<?>[] getParameterTypes() {
-               return baseMethod.getParameterTypes();
+       public AjType<?>[] getParameterTypes() {
+               Class<?>[] baseParamTypes =  baseMethod.getParameterTypes();
+               AjType<?>[] ajParamTypes = new AjType<?>[baseParamTypes.length];
+               for (int i = 0; i < ajParamTypes.length; i++) {
+                       ajParamTypes[i] = AjTypeSystem.getAjType(baseParamTypes[i]);
+               }
+               return ajParamTypes;
        }
 
        public AjType getDeclaringType() {
diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/SignaturePatternImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/SignaturePatternImpl.java
new file mode 100644 (file)
index 0000000..9820667
--- /dev/null
@@ -0,0 +1,37 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.internal.lang.reflect;
+
+import org.aspectj.lang.reflect.SignaturePattern;
+
+/**
+ * Basic implementation of signature pattern
+ *
+ */
+public class SignaturePatternImpl implements SignaturePattern {
+
+       private String sigPattern;
+       
+       public SignaturePatternImpl(String pattern) {
+               this.sigPattern = pattern;
+       }
+
+       /* (non-Javadoc)
+        * @see org.aspectj.lang.reflect.SignaturePattern#asString()
+        */
+       public String asString() {
+               return sigPattern;
+       }
+       
+       public String toString() { return asString(); }
+
+}
diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternBasedPerClauseImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternBasedPerClauseImpl.java
new file mode 100644 (file)
index 0000000..df80a0e
--- /dev/null
@@ -0,0 +1,39 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.internal.lang.reflect;
+
+import org.aspectj.lang.reflect.PerClauseKind;
+import org.aspectj.lang.reflect.TypePattern;
+import org.aspectj.lang.reflect.TypePatternBasedPerClause;
+
+/**
+ * @author colyer
+ *
+ */
+public class TypePatternBasedPerClauseImpl extends PerClauseImpl implements
+               TypePatternBasedPerClause {
+
+       private TypePattern typePattern;
+
+       public TypePatternBasedPerClauseImpl(PerClauseKind kind, String pattern) {
+               super(kind);
+               this.typePattern = new TypePatternImpl(pattern);
+       }
+
+       /* (non-Javadoc)
+        * @see org.aspectj.lang.reflect.TypePatternBasedPerClause#getTypePattern()
+        */
+       public TypePattern getTypePattern() {
+               return this.typePattern;
+       }
+
+}
diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternImpl.java
new file mode 100644 (file)
index 0000000..9973ed3
--- /dev/null
@@ -0,0 +1,37 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.internal.lang.reflect;
+
+import org.aspectj.lang.reflect.TypePattern;
+
+/**
+ * Default impl of a type pattern.
+ *
+ */
+public class TypePatternImpl implements TypePattern {
+
+       private String typePattern;
+       
+       public TypePatternImpl(String pattern) {
+               this.typePattern = pattern;
+       }
+
+       /* (non-Javadoc)
+        * @see org.aspectj.lang.reflect.TypePattern#asString()
+        */
+       public String asString() {
+               return this.typePattern;
+       }
+       
+       public String toString() { return asString(); }
+
+}
index 4792a3ba9cb158d8c2824ca543c05624e2772dd6..581c5a5fb4df53c96fd2850af7362d7def3e5c22 100644 (file)
  * ******************************************************************/
 package org.aspectj.lang.reflect;
 
+/**
+ * Runtime representation of an advice declaration inside an aspect
+ */
 public interface Advice {
 
-       AdviceType getKind();
+       /**
+        * The declaring aspect
+        */
+       AjType getDeclaringType();
        
+       /**
+        * The kind of advice (before, after-returning, after-throwing, etc.)
+        */
+       AdviceKind getKind();
+       
+       /**
+        * Returns the advice name, or the empty string if the advice is anonymous.
+        * If using the @AspectJ annotations, the advice name is the name of the
+        * annotated advice method. If using the code style, the advice is
+        * anonymous, unless the advice is annotated with the @AdviceName annotation,
+        * in which case the name given in the annotation is returned. 
+        */
        String getName();
        
+       /**
+        * The pointcut expression associated with the advice declaration.
+        */
        PointcutExpression getPointcutExpression();
 }
diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/AdviceKind.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/AdviceKind.java
new file mode 100644 (file)
index 0000000..82351db
--- /dev/null
@@ -0,0 +1,23 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.lang.reflect;
+
+/**
+ * The different kinds of advice in AspectJ
+ */
+public enum AdviceKind {
+       BEFORE,
+       AFTER,
+       AFTER_RETURNING,
+       AFTER_THROWING,
+       AROUND;
+}
diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/AdviceType.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/AdviceType.java
deleted file mode 100644 (file)
index 5413348..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2005 Contributors.
- * All rights reserved. 
- * This program and the accompanying materials are made available 
- * under the terms of the Eclipse Public License v1.0 
- * which accompanies this distribution and is available at 
- * http://eclipse.org/legal/epl-v10.html 
- *  
- * Contributors: 
- *   Adrian Colyer                     Initial implementation
- * ******************************************************************/
-package org.aspectj.lang.reflect;
-
-/**
- * The different types of advice in AspectJ
- *
- */
-public enum AdviceType {
-       BEFORE,
-       AFTER,
-       AFTER_RETURNING,
-       AFTER_THROWING,
-       AROUND;
-}
index 095db2172b9aedf2608f9212b8f3a1f78f33a5bb..e2db1407f0978e58d4d7c5caee13fc8ddb1688de 100644 (file)
@@ -11,7 +11,7 @@
  * ******************************************************************/
 package org.aspectj.lang.reflect;
 
-import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -22,160 +22,359 @@ import java.lang.reflect.TypeVariable;
  * The runtime representation of a type (Aspect, Class, Interface, Annotation, Enum, or Array) in an AspectJ
  * program.
  */
-public interface AjType<T> extends Type {
+public interface AjType<T> extends Type, AnnotatedElement {
        
+       /**
+        * The name of this type, in the same format as returned by Class.getName()
+        */
        public String getName();
        
+       /**
+        * The package in which this type is declared
+        */
        public Package getPackage();
        
-       public Class[] getInterfaces();
+       /**
+        * The interfaces implemented by this type
+        */
+       public AjType<?>[] getInterfaces();
                
+       /**
+        * The modifiers declared for this type. The return value can be interpreted
+        * using java.lang.reflect.Modifier
+        */
        public int getModifiers();
+       
+       /**
+        * The java.lang.Class that corresponds to this AjType
+        */
+       public Class<T> getJavaClass();
 
        // scope
        
-       public AjType getSupertype();
+       /**
+        * The supertype of this type. If this type represents Object or a primitive type
+        * then null is returned.
+        */
+       public AjType<?> getSupertype();
 
+       /**
+        * The generic supertype of this type, as defined by Class.getGenericSupertype
+        */
        public Type getGenericSupertype();
 
+       /**
+        * If this type represents a local or anonymous type declared within a method, return 
+        * then enclosing Method object.
+        */
        public Method getEnclosingMethod();
        
+       /**
+        * If this type represents a local or anonymous type declared within a constructor, return 
+        * then enclosing Method object.
+        */
        public Constructor getEnclosingConstructor();
 
-       public AjType getEnclosingType();
-       
-       public AjType getDeclaringType();
+       /**
+        * Returns the immediately enclosing type of this type.
+        */
+       public AjType<?> getEnclosingType();
+       
+       /**
+        * If this type is a member of another type, return the AjType representing the type
+        * in which it was declared.
+        */
+       public AjType<?> getDeclaringType();
 
+       /**
+        * If this type represents an aspect, returns the associated per-clause.
+        * Returns null for non-aspect types.
+        */
        public PerClause getPerClause(); 
        
-       // annotations
-       
-       public boolean isAnnotationPresent(Class<? extends Annotation> annotationType);
-       
-       public <A extends Annotation> A getAnnotation(Class<A> annotationType);
-       
-       public Annotation[] getAnnotations();
-       
-       public Annotation[] getDeclaredAnnotations();
-       
        // inner types
+       /**
+        * Returns an array containing all the public types that are members of this type
+        */
+       public AjType<?>[] getAjTypes();
        
-       public AjType[] getAjTypes();
-       
-       public AjType[] getDeclaredAjTypes();
+       /**
+        * Returns an array containing all the types declared by this type
+        */
+       public AjType<?>[] getDeclaredAjTypes();
        
        // constructors
        
-       public Constructor getConstructor(Class... parameterTypes) throws NoSuchMethodException;
+       /**
+        * Returns the constructor object for the specified public constructor of this type
+        */
+       public Constructor getConstructor(AjType<?>... parameterTypes) throws NoSuchMethodException;
        
+       /**
+        * Returns all of the public constructors of this type
+        */
        public Constructor[] getConstructors();
        
-       public Constructor getDeclaredConstructor(Class... parameterTypes) throws NoSuchMethodException;
-       
+       /**
+        * Returns the constructor object for the specified constructor of this type
+        */
+       public Constructor getDeclaredConstructor(AjType<?>... parameterTypes) throws NoSuchMethodException;
+
+       /**
+        * Returns all the constructors declared in this type
+        */
        public Constructor[] getDeclaredConstructors();
        
        // fields
        
+       /**
+        * Return the field declared in this type with the given name
+        */
        public Field getDeclaredField(String name) throws NoSuchFieldException;
        
+       /** 
+        * Returns all the fields declared in this type
+        */
        public Field[] getDeclaredFields();
        
+       /**
+        * Return the public field with the given name 
+        */
        public Field getField(String name) throws NoSuchFieldException;
        
+       /**
+        * Return the public fields declared by this type
+        */
        public Field[] getFields();
        
        // methods
-       
-       public Method getDeclaredMethod(String name, Class... parameterTypes) throws NoSuchMethodException;
-       
-       public Method getMethod(String name, Class... parameterTypes) throws NoSuchMethodException;
-       
+
+       /**
+        * Return the method object for the specified method declared in this type
+        */
+       public Method getDeclaredMethod(String name, AjType<?>... parameterTypes) throws NoSuchMethodException;
+       
+       /**
+        * Return the method object for the specified public method declared in this type 
+        */
+       public Method getMethod(String name, AjType<?>... parameterTypes) throws NoSuchMethodException;
+       
+       /**
+        * Return all the methods declared by this type
+        */
        public Method[] getDeclaredMethods();
        
+       /**
+        * Returns all the public methods of this type
+        */
        public Method[] getMethods();
        
        // pointcuts
        
+       /**
+        * Return the pointcut object representing the specified pointcut declared by this type
+        */
        public Pointcut getDeclaredPointcut(String name) throws NoSuchPointcutException;
        
+       /**
+        * Return the pointcut object representing the specified public pointcut
+        */
        public Pointcut getPointcut(String name) throws NoSuchPointcutException;
-       
+
+       /**
+        * Returns all of the pointcuts declared by this type
+        */
        public Pointcut[] getDeclaredPointcuts();
-       
+
+       /**
+        * Returns all of the public pointcuts of this type
+        */
        public Pointcut[] getPointcuts();
        
        // advice
-       
-       public Advice[] getDeclaredAdvice(AdviceType... ofTypes);
-       
-       public Advice[] getAdvice(AdviceType... ofTypes);
-       
+
+       /**
+        * Returns all of the advice declared by this type, of an advice kind contained in the
+        * parameter list.
+        */
+       public Advice[] getDeclaredAdvice(AdviceKind... ofTypes);
+       
+       /**
+        * Returns all of the advice for this type, of an advice kind contained in the parameter
+        * list. 
+        */
+       public Advice[] getAdvice(AdviceKind... ofTypes);
+       
+       /**
+        * Returns the advice with the given name. For an @AspectJ declared advice member,
+        * this is the name of the annotated method. For a code-style advice declaration, this
+        * is the name given in the @AdviceName annotation if present.
+        */
        public Advice getAdvice(String name) throws NoSuchAdviceException;
        
+       /**
+        * Returns the advice declared in this type with the given name. For an @AspectJ declared advice member,
+        * this is the name of the annotated method. For a code-style advice declaration, this
+        * is the name given in the @AdviceName annotation if present.
+        */
        public Advice getDeclaredAdvice(String name) throws NoSuchAdviceException;
                
        // inter-type declarations
        
-       public InterTypeMethodDeclaration getDeclaredITDMethod(String name, Class target, Class... parameterTypes);
+       /**
+        * Return the inter-type method declared by this type matching the given specification
+        */
+       public InterTypeMethodDeclaration getDeclaredITDMethod(String name, AjType<?> target, AjType<?>... parameterTypes);
        
+       /**
+        * Return all of the inter-type methods declared by this type
+        */
        public InterTypeMethodDeclaration[] getDeclaredITDMethods();
-       
-       public InterTypeMethodDeclaration getITDMethod(String name, Class target, Class... parameterTypes);
-       
+
+       /**
+        * Return the public inter-type method of this type matching the given specification
+        */
+       public InterTypeMethodDeclaration getITDMethod(String name, AjType<?> target, AjType<?>... parameterTypes);
+       
+       /**
+        * Return all of the public inter-type declared methods of this type
+        */
        public InterTypeMethodDeclaration[] getITDMethods();
                
-       public InterTypeConstructorDeclaration getDeclaredITDConstructor(Class target, Class... parameterTypes);
-       
+       /**
+        * Return the inter-type constructor declared by this type matching the given specification
+        */
+       public InterTypeConstructorDeclaration getDeclaredITDConstructor(AjType<?> target, AjType<?>... parameterTypes);
+       
+       /**
+        * Returns all of the inter-type constructors declared by this type
+        */
        public InterTypeConstructorDeclaration[] getDeclaredITDConstructors();
 
-       public InterTypeConstructorDeclaration getITDConstructor(Class target, Class... parameterTypes);
-       
+       /**
+        * Return the public inter-type constructor matching the given specification
+        */
+       public InterTypeConstructorDeclaration getITDConstructor(AjType<?> target, AjType<?>... parameterTypes);
+
+       /**
+        * Return all of the public inter-type constructors of this type
+        */
        public InterTypeConstructorDeclaration[] getITDConstructors();
-       
-       public InterTypeFieldDeclaration getDeclaredITDField(String name, Class target);
-       
+
+       /**
+        * Return the inter-type field declared in this type with the given specification
+        */
+       public InterTypeFieldDeclaration getDeclaredITDField(String name, AjType<?> target);
+
+       /**
+        * Return all of the inter-type fields declared in this type
+        */
        public InterTypeFieldDeclaration[] getDeclaredITDFields();
-       
-       public InterTypeFieldDeclaration getITDField(String name, Class target);
-       
+
+       /**
+        * Return the public inter-type field matching the given specification
+        */
+       public InterTypeFieldDeclaration getITDField(String name, AjType<?> target);
+
+       /**
+        * Return all of the public inter-type fields for this type
+        */
        public InterTypeFieldDeclaration[] getITDFields();
                
        // declare statements
-       
+       /**
+        * Returns all of the declare error and declare warning members of this type,
+        * including declare error/warning members inherited from super-types
+        */
        public DeclareErrorOrWarning[] getDeclareErrorOrWarnings();
        
+       /**
+        * Returns all of the declare parents members of this type, including
+        * declare parent members inherited from super-types
+        */
        public DeclareParents[] getDeclareParents();
        
+       /**
+        * Return all of the declare soft members of this type, including declare
+        * soft members inherited from super-types
+        */
        public DeclareSoft[] getDeclareSofts();
-       
+
+       /**
+        * Return all of the declare annotation members of this type, including declare
+        * annotation members inherited from super-types
+        */
        public DeclareAnnotation[] getDeclareAnnotations();
        
+       /**
+        * Return all of the declare precedence members of this type, including declare
+        * precedence members inherited from super-types
+        */
        public DeclarePrecedence[] getDeclarePrecedence();
        
        // misc
        
+       /**
+        * Returns the elements of this enum class, or null if this type does not represent
+        * an enum type.
+        */
     public T[] getEnumConstants();
        
+    /**
+     * Returns an array of TypeVariable objects that represent the type variables declared by
+     * this type (if any)
+     */
        public TypeVariable<Class<T>>[] getTypeParameters();
-       
+
+       /**
+        * True if this is an enum type
+        */
        public boolean isEnum();
-       
+
+       /**
+        * True if the given object is assignment-compatible with an object of the type represented
+        * by this AjType
+        */
        public boolean isInstance(Object o);
-       
+
+       /**
+        * True if this is an interface type
+        */
        public boolean isInterface();
-       
+
+       /**
+        * Returns true if and only if the underlying type is a local class
+        */
        public boolean isLocalClass();
        
+       /**
+        * Returns true if and only if the underlying type is a member class
+        */
        public boolean isMemberClass();
        
+       /**
+        * Return true if this is an array type
+        */
        public boolean isArray();
-       
+
+       /**
+        * Return true if this object represents a primitive type
+        */
        public boolean isPrimitive();
-       
+
+       /**
+        * Return true if this is an aspect type
+        */
        public boolean isAspect();
        
+       /**
+        * Returns true if and only if the underlying type is a member aspect
+        */
        public boolean isMemberAspect();
-       
+
+       /**
+        * Returns true if and only if the underlying type is a privileged aspect
+        */
        public boolean isPrivileged();
        
 }
index 7b15995490ec43dd6cb0751cb1677b97ebe9aac0..fbd9a66440d57f99dd4de45bbdc0cf16b4dd04f8 100644 (file)
  * ******************************************************************/
 package org.aspectj.lang.reflect;
 
+import java.lang.ref.WeakReference;
+import java.util.Map;
+import java.util.WeakHashMap;
+
 import org.aspectj.internal.lang.reflect.AjTypeImpl;
 
 /**
- * @author colyer
- *
+ * This is the anchor for the AspectJ runtime type system. 
+ * Typical usage to get the AjType representation of a given type
+ * at runtime is to call <code>AjType<Foo> fooType = AjTypeSystem.getAjType(Foo.class);</code>
  */
 public class AjTypeSystem {
+       
+               private static Map<Class, WeakReference<AjType>> ajTypes = new WeakHashMap<Class,WeakReference<AjType>>();
 
+               /**
+                * Return the AspectJ runtime type representation of the given Java type.
+                * Unlike java.lang.Class, AjType understands pointcuts, advice, declare statements,
+                * and other AspectJ type members. AjType is the recommended reflection API for
+                * AspectJ programs as it offers everything that java.lang.reflect does, with 
+                * AspectJ-awareness on top.
+                */
                public static <T> AjType<T> getAjType(Class<T> fromClass) {
-                       return new AjTypeImpl<T>(fromClass);
+                       if (ajTypes.containsKey(fromClass)) {
+                               WeakReference<AjType> weakRefToAjType = ajTypes.get(fromClass);
+                               AjType<T> theAjType = weakRefToAjType.get();
+                               if (theAjType != null) {
+                                       return theAjType;
+                               } else {
+                                       theAjType = new AjTypeImpl<T>(fromClass);
+                                       ajTypes.put(fromClass, new WeakReference<AjType>(theAjType));
+                                       return theAjType;
+                               }
+                       }
+                       // neither key nor value was found
+                       AjType<T> theAjType =  new AjTypeImpl<T>(fromClass);
+                       ajTypes.put(fromClass, new WeakReference<AjType>(theAjType));
+                       return theAjType;
                }
 }
index cd594e9daee77b0af2b7d83590d87e31de93075d..4e0f78aa7756078a97065f1bd345ac557d96d8e7 100644 (file)
@@ -12,7 +12,7 @@
 package org.aspectj.lang.reflect;
 
 /**
- * @author colyer
+ * The AspectJ runtime representation of a declare annotation member in an aspect.
  *
  */
 public interface DeclareAnnotation {
index c8539c1669ed1d8b24e210e8680d3f3903f5c6a3..a6a5abc538a5ecc339e1629a0a63af514f783020 100644 (file)
 package org.aspectj.lang.reflect;
 
 /**
- * @author colyer
- *
+ * AspectJ runtime representation of a declare error or declare warning member
+ * in an aspect.
  */
 public interface DeclareErrorOrWarning {
+       
+       /**
+        * The type that declared this declare warning or declare error member. 
+        */
+       AjType getDeclaringType();
+       
+       /**
+        * The pointcut expression associated with the warning or error
+        */
        PointcutExpression getPointcutExpression();
+       
+       /**
+        * The message associated with the declare warning / declare error
+        */
        String getMessage();
+       
+       /**
+        * True if this is a declare error member, false if it is declare warning
+        */
        boolean isError();
        
 }
index 6b1d6f5b348c4b325c3ad50571df9a3aa54c2054..f8ee5c99dc205d2e655a9bd01edf26c02776eb9f 100644 (file)
 package org.aspectj.lang.reflect;
 
 /**
- * @author colyer
- *
+ * A declare parents member defined inside an aspect
  */
 public interface DeclareParents {
 
+       /**
+        * The declaring aspect
+        */
+       AjType getDeclaringType();
+       
+       /**
+        * The target type pattern
+        */
+       TypePattern getTargetTypesPattern();
+       
+       /**
+        * True if this is a declare parents...extends member declaration
+        */
+       boolean isExtends();
+       
+       /**
+        * True if this is a declare parents...implements member declaration
+        */
+       boolean isImplements();
+       
+       /**
+        * The set of types that the types matching getTargetTypesPattern are 
+        * declared to implement or extend
+        */
+       AjType[] getParentTypes();
+       
 }
index ad7086d9581ec01c42da134d4629df95feaca203..894580b7038677f44c3e40324cb0b8d281d2341e 100644 (file)
 package org.aspectj.lang.reflect;
 
 /**
- * @author colyer
- *
+ * AspectJ runtime representation of a declare precedence statement as 
+ * declared in an aspect.
  */
 public interface DeclarePrecedence {
 
+       /**
+        * The declaring aspect
+        */
+       AjType getDeclaringType();
+       
+       /**
+        * Returns an ordered set of type patterns. An aspect matching
+        * a type pattern at a lower index in the array takes precedence
+        * over an aspect that only matches a type pattern at a higher
+        * index in the array.
+        */
+       TypePattern[] getPrecedenceOrder();
 }
index ffb392c3f328938a476decae79be2a89b0f0d070..b397c94f3fb964b8cf7ef3714aa1e520203c3ae8 100644 (file)
 package org.aspectj.lang.reflect;
 
 /**
- * @author colyer
- *
+ * AspectJ runtime representation of a declare soft member within an aspect.
  */
 public interface DeclareSoft {
+       
+       /**
+        * The aspect that declared this member
+        */
+       AjType getDeclaringType();
+       
+       /**
+        * The softened exception type
+        */
+       AjType getSoftenedExceptionType();
+       
+       /**
+        * The pointcut determining the join points at which the exception is to be softened.
+        */
+       PointcutExpression getPointcutExpression();
 
 }
index e14dfb7d310d11bad3148fa0d3df0ac99cb1c170..6b1ca8fa0697083aac454f0eb4774e0de4616544 100644 (file)
@@ -12,8 +12,8 @@
 package org.aspectj.lang.reflect;
 
 /**
- * @author colyer
- *
+ * Thrown when AjType.getDeclaredAdvice is called with an advice name and no matching
+ * advice declaration can be found.
  */
 public class NoSuchAdviceException extends Exception {
 
@@ -24,6 +24,9 @@ public class NoSuchAdviceException extends Exception {
                this.name = name;
        }
        
+       /**
+        * The advice name that could not be found.
+        */
        public String getName() {
                return name;
        }
index df1bf918973774c6abdc005fbb95b0237f5397a8..0274b74b4b6e5bc64006eeeffae9b76b71d3f75c 100644 (file)
@@ -12,8 +12,8 @@
 package org.aspectj.lang.reflect;
 
 /**
- * @author colyer
- *
+ * Thrown when AjType.getDeclaredPointcut is called with a pointcut name, and no
+ * matching pointcut declaration can be found.
  */
 public class NoSuchPointcutException extends Exception {
 
@@ -24,6 +24,9 @@ public class NoSuchPointcutException extends Exception {
                this.name = name;
        }
        
+       /**
+        * The name of the pointcut that could not be found.
+        */
        public String getName() {
                return name;
        }
index c3396c5481389d7f239ccdc6a4d2f3e253fe0f9e..c16feda3353729de3ff09d10de34a85a45f26cb6 100644 (file)
 package org.aspectj.lang.reflect;
 
 /**
- * @author colyer
- *
+ * AspectJ runtime representation of the per-clause associated with an aspect.
  */
 public interface PerClause {
+       /**
+        * The kind of per-clause (singleton, perthis, pertarget,...)
+        */
        PerClauseKind getKind();
-       PointcutExpression getPointcutExpression();
+
 }
index 03313d8c5036edd0e701e931804bc50ab29d7aa0..1e2d42ecd44364a1b2369a27b4111d04dd62f92f 100644 (file)
@@ -12,8 +12,8 @@
 package org.aspectj.lang.reflect;
 
 /**
- * @author colyer
- * The different perclauses (aspect instantiation models)
+ * The different per-clauses (aspect instantiation models)
+ * supported by AspectJ
  */
 public enum PerClauseKind {
        SINGLETON,
index c514bea0152b52f06b719155587aaccf6e2d4750..dfec7ccbd923b17a6a2c34f184d5d24da7526873 100644 (file)
  * ******************************************************************/
 package org.aspectj.lang.reflect;
 
+/**
+ * AspectJ runtime representation of a pointcut member inside a class or aspect.
+ */
 public interface Pointcut {
-
-       PointcutExpression getPointcutExpression();
        
+       /**
+        * The declared name of the pointcut.
+        */
        String getName();
        
+       /**
+        * The modifiers associated with the pointcut declaration. 
+        * Use java.lang.reflect.Modifier to interpret the return value
+        */
        int getModifiers();
        
-       Class<?>[] getParameterTypes();
+       /**
+        * The pointcut parameter types.
+        */
+       AjType<?>[] getParameterTypes();
        
+       /**
+        * The pointcut parameter names. Returns an array of empty strings
+        * of length getParameterTypes().length if parameter names are not
+        * available at runtime.
+        */
        String[] getParameterNames();
        
+       /**
+        * The type that declared this pointcut
+        */
        AjType getDeclaringType();
+
+       /**
+        * The pointcut expression associated with this pointcut.
+        */
+       PointcutExpression getPointcutExpression();
+
 }
diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutBasedPerClause.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutBasedPerClause.java
new file mode 100644 (file)
index 0000000..db040ea
--- /dev/null
@@ -0,0 +1,25 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.lang.reflect;
+
+/**
+ * Representation of a pointcut based per-clause associated with an aspect
+ * (perthis/target/cflow/cflowbelow)
+ *
+ */
+public interface PointcutBasedPerClause extends PerClause {
+
+       /**
+        * Get the associated pointcut expression
+        */
+       PointcutExpression getPointcutExpression();
+}
index b2ab44d7c0ab384d5e9b7fdaa7007ad4617cb0d9..e229ba1f04741de786a8cfabbfa2a2a2f66e7613 100644 (file)
@@ -20,5 +20,5 @@ public interface PointcutExpression {
        /**
         * Returns a String representation of the pointcut expression 
         */
-       String toString();
+       String asString();
 }
diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/SignaturePattern.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/SignaturePattern.java
new file mode 100644 (file)
index 0000000..99ba44d
--- /dev/null
@@ -0,0 +1,23 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.lang.reflect;
+
+/**
+ * AspectJ runtime representation of a signature pattern as used in various
+ * aspect members (for example, declare @method, declare @field).
+ */
+public interface SignaturePattern {
+
+       /** return a String representation of this pattern */
+       String asString();
+       
+}
diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePattern.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePattern.java
new file mode 100644 (file)
index 0000000..f3b69b4
--- /dev/null
@@ -0,0 +1,22 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.lang.reflect;
+
+/**
+ * AspectJ runtime representation of a type pattern as used in member declarations
+ * such as declare parents.
+ */
+public interface TypePattern {
+
+       /** a string representation of the pattern */
+       String asString();
+}
diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePatternBasedPerClause.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePatternBasedPerClause.java
new file mode 100644 (file)
index 0000000..402b883
--- /dev/null
@@ -0,0 +1,26 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.lang.reflect;
+
+/**
+ * AspectJ runtime representation of a type pattern based per-clause associated
+ * with an aspect (pertypewithin).
+ *
+ */
+public interface TypePatternBasedPerClause {
+
+       /**
+        * Get the associated type pattern
+        */
+       TypePattern getTypePattern();
+       
+}
index dde2f4fba20979aa4994df97d57ab78f731552a8..211da98c3abc02a4102d888764a228f9a5bac561 100644 (file)
@@ -27,7 +27,7 @@ import org.aspectj.lang.reflect.AjTypeSystem;
 
 public class AjTypeTests extends TestCase {
 
-       private AjType stringType;
+       private AjType<String> stringType;
        
        @Override
        protected void setUp() throws Exception {
@@ -49,10 +49,10 @@ public class AjTypeTests extends TestCase {
        
        public void testGetInterfaces() {
                Class[] i1 = String.class.getInterfaces();
-               Class[] i2 = stringType.getInterfaces();
+               AjType<?>[] i2 = stringType.getInterfaces();
                assertEquals(i1.length,i2.length);
                for (int i = 0; i < i1.length; i++)
-                       assertEquals(i1[i],i2[i]);
+                       assertEquals(i1[i],i2[i].getJavaClass());
        }
        
        public void testGetModifiers() {
@@ -135,7 +135,7 @@ public class AjTypeTests extends TestCase {
        
        public void testGetConstructor() throws Exception {
                Constructor c1 = String.class.getConstructor(String.class);
-               Constructor c2 = stringType.getConstructor(String.class);
+               Constructor c2 = stringType.getConstructor(stringType);
                assertEquals(c1,c2);
        }
        
@@ -149,7 +149,7 @@ public class AjTypeTests extends TestCase {
        
        public void testGetDeclaredConstructor() throws Exception {
                Constructor c1 = String.class.getDeclaredConstructor(String.class);
-               Constructor c2 = stringType.getDeclaredConstructor(String.class);
+               Constructor c2 = stringType.getDeclaredConstructor(stringType);
                assertEquals(c1,c2);
        }
        
index cb1520dbacd52ab274c67b48246f584c0342c00e..a01287d0a3ac716bbb96ed15aa2c170b60070fcf 100644 (file)
@@ -28,7 +28,7 @@ import org.aspectj.lang.annotation.Before;
 import org.aspectj.lang.annotation.DeclareError;
 import org.aspectj.lang.annotation.DeclareWarning;
 import org.aspectj.lang.reflect.Advice;
-import org.aspectj.lang.reflect.AdviceType;
+import org.aspectj.lang.reflect.AdviceKind;
 import org.aspectj.lang.reflect.AjType;
 import org.aspectj.lang.reflect.AjTypeSystem;
 import org.aspectj.lang.reflect.DeclareErrorOrWarning;
@@ -37,6 +37,8 @@ import org.aspectj.lang.reflect.NoSuchPointcutException;
 import org.aspectj.lang.reflect.PerClause;
 import org.aspectj.lang.reflect.PerClauseKind;
 import org.aspectj.lang.reflect.Pointcut;
+import org.aspectj.lang.reflect.PointcutBasedPerClause;
+import org.aspectj.lang.reflect.TypePatternBasedPerClause;
 
 public class AjTypeTestsWithAspects extends TestCase {
 
@@ -56,23 +58,23 @@ public class AjTypeTestsWithAspects extends TestCase {
                
                PerClause pc = perThisA.getPerClause();
                assertEquals(PerClauseKind.PERTHIS,pc.getKind());
-               assertEquals("pc()",pc.getPointcutExpression().toString());
+               assertEquals("pc()",((PointcutBasedPerClause)pc).getPointcutExpression().asString());
                
                pc= perTargetA.getPerClause();
                assertEquals(PerClauseKind.PERTARGET,pc.getKind());
-               assertEquals("pc()",pc.getPointcutExpression().toString());
+               assertEquals("pc()",((PointcutBasedPerClause)pc).getPointcutExpression().asString());
 
                pc= perCflowA.getPerClause();
                assertEquals(PerClauseKind.PERCFLOW,pc.getKind());
-               assertEquals("pc()",pc.getPointcutExpression().toString());
+               assertEquals("pc()",((PointcutBasedPerClause)pc).getPointcutExpression().asString());
 
                pc= perCflowbelowA.getPerClause();
                assertEquals(PerClauseKind.PERCFLOWBELOW,pc.getKind());
-               assertEquals("pc()",pc.getPointcutExpression().toString());
+               assertEquals("pc()",((PointcutBasedPerClause)pc).getPointcutExpression().asString());
 
                pc= perTypeWithinA.getPerClause();
                assertEquals(PerClauseKind.PERTYPEWITHIN,pc.getKind());
-               assertEquals("org.aspectj..*",pc.getPointcutExpression().toString());
+               assertEquals("org.aspectj..*",((TypePatternBasedPerClause)pc).getTypePattern().asString());
 
        }
        
@@ -148,13 +150,13 @@ public class AjTypeTestsWithAspects extends TestCase {
        public void testGetDeclaredPointcut() throws Exception {
                Pointcut p1 = sa.getDeclaredPointcut("simpleAspectMethodExecution");
                assertEquals("simpleAspectMethodExecution",p1.getName());
-               assertEquals("execution(* SimpleAspect.*(..))",p1.getPointcutExpression().toString());
+               assertEquals("execution(* SimpleAspect.*(..))",p1.getPointcutExpression().asString());
                assertEquals(sa,p1.getDeclaringType());
                assertEquals(0,p1.getParameterTypes().length);
                assertTrue(Modifier.isPublic(p1.getModifiers()));
                Pointcut p2 = sa.getDeclaredPointcut("simpleAspectCall");
                assertEquals("simpleAspectCall",p2.getName());
-               assertEquals("call(* SimpleAspect.*(..))",p2.getPointcutExpression().toString());
+               assertEquals("call(* SimpleAspect.*(..))",p2.getPointcutExpression().asString());
                assertEquals(sa,p2.getDeclaringType());
                assertEquals(1,p2.getParameterTypes().length);
                assertTrue(Modifier.isPrivate(p2.getModifiers()));
@@ -169,13 +171,13 @@ public class AjTypeTestsWithAspects extends TestCase {
        public void testGetPointcut() throws Exception {
                Pointcut p1 = sa.getPointcut("simpleAspectMethodExecution");
                assertEquals("simpleAspectMethodExecution",p1.getName());
-               assertEquals("execution(* SimpleAspect.*(..))",p1.getPointcutExpression().toString());
+               assertEquals("execution(* SimpleAspect.*(..))",p1.getPointcutExpression().asString());
                assertEquals(sa,p1.getDeclaringType());
                assertEquals(0,p1.getParameterTypes().length);
                assertTrue(Modifier.isPublic(p1.getModifiers()));
-               Pointcut p2 = sa.getPointcut("simpleAspectCall");
+               Pointcut p2 = sa.getDeclaredPointcut("simpleAspectCall");
                assertEquals("simpleAspectCall",p2.getName());
-               assertEquals("call(* SimpleAspect.*(..))",p2.getPointcutExpression().toString());
+               assertEquals("call(* SimpleAspect.*(..))",p2.getPointcutExpression().asString());
                assertEquals(sa,p2.getDeclaringType());
                assertEquals(1,p2.getParameterTypes().length);
                assertTrue(Modifier.isPrivate(p2.getModifiers()));
@@ -205,20 +207,20 @@ public class AjTypeTestsWithAspects extends TestCase {
        public void testGetDeclaredAdvice() {
                Advice[] advice = sa.getDeclaredAdvice();
                assertEquals(10,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.BEFORE);
+               advice = sa.getDeclaredAdvice(AdviceKind.BEFORE);
                assertEquals(2,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.AFTER);
+               advice = sa.getDeclaredAdvice(AdviceKind.AFTER);
                assertEquals(2,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.AFTER_RETURNING);
+               advice = sa.getDeclaredAdvice(AdviceKind.AFTER_RETURNING);
                assertEquals(2,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.AFTER_THROWING);
+               advice = sa.getDeclaredAdvice(AdviceKind.AFTER_THROWING);
                assertEquals(2,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.AROUND);
+               advice = sa.getDeclaredAdvice(AdviceKind.AROUND);
                assertEquals(2,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.BEFORE,AdviceType.AFTER);
+               advice = sa.getDeclaredAdvice(AdviceKind.BEFORE,AdviceKind.AFTER);
                assertEquals(4,advice.length);
 
-               advice = sa.getDeclaredAdvice(AdviceType.BEFORE);
+               advice = sa.getDeclaredAdvice(AdviceKind.BEFORE);
                // AV: corrupted test: cannot rely on ordering since a Set is used behind
         Advice aone, atwo;
         if (advice[0].getName()!=null && advice[0].getName().length()>0) {
@@ -230,7 +232,7 @@ public class AjTypeTestsWithAspects extends TestCase {
         }
         assertEquals("execution(* SimpleAspect.*(..))",aone.getPointcutExpression().toString());
         assertEquals("logEntry",aone.getName());
-        assertEquals(AdviceType.BEFORE,aone.getKind());
+        assertEquals(AdviceKind.BEFORE,aone.getKind());
         assertEquals("execution(* SimpleAspect.*(..))",atwo.getPointcutExpression().toString());
         assertEquals("",atwo.getName());
        }
@@ -238,27 +240,27 @@ public class AjTypeTestsWithAspects extends TestCase {
        public void testGetAdvice() {
                Advice[] advice = sa.getDeclaredAdvice();
                assertEquals(10,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.BEFORE);
+               advice = sa.getDeclaredAdvice(AdviceKind.BEFORE);
                assertEquals(2,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.AFTER);
+               advice = sa.getDeclaredAdvice(AdviceKind.AFTER);
                assertEquals(2,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.AFTER_RETURNING);
+               advice = sa.getDeclaredAdvice(AdviceKind.AFTER_RETURNING);
                assertEquals(2,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.AFTER_THROWING);
+               advice = sa.getDeclaredAdvice(AdviceKind.AFTER_THROWING);
                assertEquals(2,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.AROUND);
+               advice = sa.getDeclaredAdvice(AdviceKind.AROUND);
                assertEquals(2,advice.length);
-               advice = sa.getDeclaredAdvice(AdviceType.BEFORE,AdviceType.AFTER);
+               advice = sa.getDeclaredAdvice(AdviceKind.BEFORE,AdviceKind.AFTER);
                assertEquals(4,advice.length);          
        }
        
        public void testGetNamedAdvice() throws Exception {
                Advice a = sa.getAdvice("logItAll");
                assertEquals("logItAll",a.getName());
-               assertEquals(AdviceType.AROUND,a.getKind());
+               assertEquals(AdviceKind.AROUND,a.getKind());
                a = sa.getAdvice("whatGoesAround");
                assertEquals("whatGoesAround",a.getName());
-               assertEquals(AdviceType.AROUND,a.getKind());
+               assertEquals(AdviceKind.AROUND,a.getKind());
                try {
                        a = sa.getAdvice("ajc$after$123");
                        fail("Expecting NoSuchAdviceException");
@@ -276,10 +278,10 @@ public class AjTypeTestsWithAspects extends TestCase {
        public void testGetNamedDeclaredAdvice() throws Exception {
                Advice a = sa.getDeclaredAdvice("logItAll");
                assertEquals("logItAll",a.getName());
-               assertEquals(AdviceType.AROUND,a.getKind());
+               assertEquals(AdviceKind.AROUND,a.getKind());
                a = sa.getDeclaredAdvice("whatGoesAround");
                assertEquals("whatGoesAround",a.getName());
-               assertEquals(AdviceType.AROUND,a.getKind());
+               assertEquals(AdviceKind.AROUND,a.getKind());
                try {
                        a = sa.getDeclaredAdvice("ajc$after$123");
                        fail("Expecting NoSuchAdviceException");
index 88303752dc70292019014013ad04a638479c1898..2d53746c761378400e65abfcdc0ab1e18a33b254 100644 (file)
Binary files a/lib/aspectj/lib/aspectjrt.jar and b/lib/aspectj/lib/aspectjrt.jar differ
index 88303752dc70292019014013ad04a638479c1898..2d53746c761378400e65abfcdc0ab1e18a33b254 100644 (file)
Binary files a/lib/test/aspectjrt.jar and b/lib/test/aspectjrt.jar differ
index 6c1e3b8f3d7e388601818b10548dc0ea87417707..1198f6fa918f99b0299e14ec956b79d7ec8b5722 100644 (file)
@@ -8,19 +8,19 @@ public aspect PointcutsWithParams {
        
        public static void main(String[] args) throws NoSuchPointcutException {
                AjType myType = AjTypeSystem.getAjType(PointcutsWithParams.class);
-               Pointcut p1 = myType.getPointcut("pc1");
-               Class[] params = p1.getParameterTypes();
+               Pointcut p1 = myType.getDeclaredPointcut("pc1");
+               AjType<?>[] params = p1.getParameterTypes();
                if (params.length != 1) throw new RuntimeException("expecting one param");
-               if (!params[0].equals(String.class)) throw new RuntimeException("expecting a String");
+               if (!params[0].getJavaClass().equals(String.class)) throw new RuntimeException("expecting a String");
                String[] names = p1.getParameterNames();
                if (names.length != 1) throw new RuntimeException("expecting one name");
                if (!names[0].equals("s")) throw new RuntimeException("expecting 's', found " + names[0]);
-               Pointcut p2 = myType.getPointcut("pc2");
+               Pointcut p2 = myType.getDeclaredPointcut("pc2");
                params = p2.getParameterTypes();
                if (params.length != 3) throw new RuntimeException("expecting three params");
-               if (!params[0].equals(Integer.class)) throw new RuntimeException("expecting an Integer");
-               if (!params[1].equals(Double.class)) throw new RuntimeException("expecting a Double");
-               if (!params[2].equals(String.class)) throw new RuntimeException("expecting a String");
+               if (!params[0].getJavaClass().equals(Integer.class)) throw new RuntimeException("expecting an Integer");
+               if (!params[1].getJavaClass().equals(Double.class)) throw new RuntimeException("expecting a Double");
+               if (!params[2].getJavaClass().equals(String.class)) throw new RuntimeException("expecting a String");
                names = p2.getParameterNames();
                if (names.length != 3) throw new RuntimeException("expecting one name");
                if (!names[0].equals("i")) throw new RuntimeException("expecting 'i', found '" + names[0] + "'");
index e6014d7dadf1e5a37f2f3987d8defcd03dd3377a..37be4f1ffd7587dc3fb1f6b4ce3e1cedf620dbc2 100644 (file)
@@ -8,10 +8,10 @@ public aspect ReferencePointcuts {
        
        public static void main(String[] args) throws NoSuchPointcutException {
                AjType myType = AjTypeSystem.getAjType(ReferencePointcuts.class);
-               Pointcut p1 = myType.getPointcut("pc1");
+               Pointcut p1 = myType.getDeclaredPointcut("pc1");
                if (!p1.getPointcutExpression().toString().equals("call(* *(..))")) 
                        throw new RuntimeException("unexpected pc expression: " + p1.getPointcutExpression());
-               Pointcut p2 = myType.getPointcut("pc2");
+               Pointcut p2 = myType.getDeclaredPointcut("pc2");
                if (!p2.getPointcutExpression().toString().equals("(pc1() || execution(* *(..)))")) 
                        throw new RuntimeException("unexpected pc expression: " + p2.getPointcutExpression());
 
index 164fc9f80e9da542968e98843c53e2cbc86b8fdc..952fdec08e61099de7c4eb21be55ec43bc21e87e 100644 (file)
@@ -203,14 +203,14 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends
                        pointcuts = new ResolvedMember[pcs.length];
                        PointcutParser parser = new PointcutParser();
                        for (int i = 0; i < pcs.length; i++) {
-                               Class[] ptypes = pcs[i].getParameterTypes();
+                               AjType<?>[] ptypes = pcs[i].getParameterTypes();
                                String[] pnames = pcs[i].getParameterNames();
                                if (pnames.length != ptypes.length) {
                                        throw new IllegalStateException("Required parameter names not available when parsing pointcut " + pcs[i].getName() + " in type " + getResolvedTypeX().getName());
                                }
                                PointcutParameter[] parameters = new PointcutParameter[ptypes.length];
                                for (int j = 0; j < parameters.length; j++) {
-                                       parameters[j] = parser.createPointcutParameter(pnames[j],ptypes[j]);
+                                       parameters[j] = parser.createPointcutParameter(pnames[j],ptypes[j].getJavaClass());
                                }
                                String pcExpr = pcs[i].getPointcutExpression().toString();
                                PointcutExpressionImpl pEx = (PointcutExpressionImpl) parser.parsePointcutExpression(pcExpr,getBaseClass(),parameters);