From: acolyer Date: Mon, 19 Dec 2005 10:42:34 +0000 (+0000) Subject: updates for final form of @DeclareParents X-Git-Tag: V1_5_0_final~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a3adb42ae574d488a33e9f0d4e2beeb3e1074c3e;p=aspectj.git updates for final form of @DeclareParents --- 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 482ccebb9..99f1e66ab 100644 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java +++ b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java @@ -661,8 +661,10 @@ public class AjTypeImpl implements AjType { 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 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 implements AjType { private void addAnnotationStyleDeclareParents(List 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(); diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java index e26e8c778..fe7267849 100644 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java +++ b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java @@ -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. } diff --git a/lib/aspectj/lib/aspectjrt.jar b/lib/aspectj/lib/aspectjrt.jar index f8d847b2f..297c989ac 100644 Binary files a/lib/aspectj/lib/aspectjrt.jar and b/lib/aspectj/lib/aspectjrt.jar differ diff --git a/lib/test/aspectjrt.jar b/lib/test/aspectjrt.jar index f8d847b2f..297c989ac 100644 Binary files a/lib/test/aspectjrt.jar and b/lib/test/aspectjrt.jar differ diff --git a/tests/java5/ataspectj/annotationGen/ITDTest.aj b/tests/java5/ataspectj/annotationGen/ITDTest.aj index dc8089f70..46e7feed5 100644 --- a/tests/java5/ataspectj/annotationGen/ITDTest.aj +++ b/tests/java5/ataspectj/annotationGen/ITDTest.aj @@ -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(); diff --git a/tests/java5/reflection/AtAspectJDeclareParents.aj b/tests/java5/reflection/AtAspectJDeclareParents.aj index d60f6a3c6..fddf12a56 100644 --- a/tests/java5/reflection/AtAspectJDeclareParents.aj +++ b/tests/java5/reflection/AtAspectJDeclareParents.aj @@ -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; }