]> source.dussan.org Git - aspectj.git/commitdiff
updates for final form of @DeclareParents
authoracolyer <acolyer>
Mon, 19 Dec 2005 10:42:34 +0000 (10:42 +0000)
committeracolyer <acolyer>
Mon, 19 Dec 2005 10:42:34 +0000 (10:42 +0000)
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java
aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java
lib/aspectj/lib/aspectjrt.jar
lib/test/aspectjrt.jar
tests/java5/ataspectj/annotationGen/ITDTest.aj
tests/java5/reflection/AtAspectJDeclareParents.aj

index 482ccebb9a91ff9bb62c66a4c85419a69e98be9b..99f1e66ab593f6de78ab88d63ab37eacbb2c51d3 100644 (file)
@@ -661,8 +661,10 @@ public class AjTypeImpl<T> implements AjType<T> {
                if (isAspect()) {
             for (Field f : clazz.getDeclaredFields()) {
                 if (!f.getType().isInterface()) continue;
-                if (!Modifier.isPublic(f.getModifiers()) || !Modifier.isStatic(f.getModifiers())) continue;
-                if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {                  
+                if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
+                       Class<org.aspectj.lang.annotation.DeclareParents> decPAnnClass = org.aspectj.lang.annotation.DeclareParents.class;
+                       org.aspectj.lang.annotation.DeclareParents decPAnn = f.getAnnotation(decPAnnClass);
+                           if (decPAnn.defaultImpl() == decPAnnClass) continue; // doesn't contribute members...
                     for (Method itdM : f.getType().getDeclaredMethods()) {
                         if (!Modifier.isPublic(itdM.getModifiers()) && publicOnly) continue;
                         InterTypeMethodDeclaration itdm = new InterTypeMethodDeclarationImpl(
@@ -951,21 +953,7 @@ public class AjTypeImpl<T> implements AjType<T> {
        
        private void addAnnotationStyleDeclareParents(List<DeclareParents> toList) {
         for (Field f : clazz.getDeclaredFields()) {
-            if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareImplements.class)) {
-                if (!f.getType().isInterface()) continue;
-                org.aspectj.lang.annotation.DeclareImplements ann = f.getAnnotation(org.aspectj.lang.annotation.DeclareImplements.class);
-                String parentType = f.getType().getName();
-                DeclareParentsImpl decp = new DeclareParentsImpl(
-                        ann.value(),
-                        parentType,
-                        false,
-                        this
-                );
-                toList.add(decp);
-            }
-            if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)
-                && Modifier.isStatic(f.getModifiers())
-                && Modifier.isPublic(f.getModifiers())) {
+            if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
                 if (!f.getType().isInterface()) continue;
                 org.aspectj.lang.annotation.DeclareParents ann = f.getAnnotation(org.aspectj.lang.annotation.DeclareParents.class);
                 String parentType = f.getType().getName();
index e26e8c778d7f29a8a32fb9b5e3725c245067bcb5..fe7267849153e1dd38209822ea64f5763b908d6d 100644 (file)
@@ -28,4 +28,14 @@ public @interface DeclareParents {
      */
     String value();
     
+    /**
+     * Optional class defining default implementation
+     * of interface members (equivalent to defining
+     * a set of interface member ITDs for the
+     * public methods of the interface).
+     */
+    Class defaultImpl() default DeclareParents.class;
+    
+    // note - a default of "null" is not allowed,
+    // hence the strange default given above.
 }
index f8d847b2f58d4edb8c610a22dcd0a7bdc8baaf75..297c989ac84ee928985f3b1cd9eca171ebef2182 100644 (file)
Binary files a/lib/aspectj/lib/aspectjrt.jar and b/lib/aspectj/lib/aspectjrt.jar differ
index f8d847b2f58d4edb8c610a22dcd0a7bdc8baaf75..297c989ac84ee928985f3b1cd9eca171ebef2182 100644 (file)
Binary files a/lib/test/aspectjrt.jar and b/lib/test/aspectjrt.jar differ
index dc8089f702b9b6db4d3c3452d2d4947931c02654..46e7feed5a27944ff2c32094801974ff613ebdee 100644 (file)
@@ -186,7 +186,7 @@ class A {}
 @Aspect
 class X {
        
-       @org.aspectj.lang.annotation.DeclareParents("org.xyz..*")
+       @org.aspectj.lang.annotation.DeclareParents(value="org.xyz..*",defaultImpl=Mixin.class)
        public static I myMixin = new Mixin();
 
 
index d60f6a3c65109c988882e75ba610e38f3d0930d2..fddf12a56bd03dead5171c1bc20b9a41a8bb000e 100644 (file)
@@ -2,8 +2,8 @@ import org.aspectj.lang.annotation.*;
 
 public aspect AtAspectJDeclareParents {
        
-       @DeclareParents("C")
-       public static I mixin = new Impl();
+       @DeclareParents(value="C",defaultImpl=Impl.class)
+       private I implementedInterface;
        
 }