]> source.dussan.org Git - aspectj.git/commitdiff
fixes inefficient ordering of tests in SignaturePattern (that I inadvertantly introdu...
authoracolyer <acolyer>
Wed, 14 Dec 2005 00:53:28 +0000 (00:53 +0000)
committeracolyer <acolyer>
Wed, 14 Dec 2005 00:53:28 +0000 (00:53 +0000)
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeMethodDeclarationImpl.java
lib/aspectj/lib/aspectjrt.jar
lib/test/aspectjrt.jar
tests/java5/reflection/AtAspectJDeclareParents.aj
tests/java5/reflection/ReflectOnAtAspectJDeclareParents.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java

index 54c5008015860c9c637ab81985176231a8bfd1a2..482ccebb9a91ff9bb62c66a4c85419a69e98be9b 100644 (file)
@@ -662,17 +662,12 @@ public class AjTypeImpl<T> implements AjType<T> {
             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)) {
-                        Class itdSource = f.getType();
-                        try {
-                               itdSource = f.get(null).getClass();
-                        } catch (IllegalAccessException ex) {
-                               //
-                        }
-                    for (Method itdM : itdSource.getDeclaredMethods()) {
+                if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {                  
+                    for (Method itdM : f.getType().getDeclaredMethods()) {
                         if (!Modifier.isPublic(itdM.getModifiers()) && publicOnly) continue;
                         InterTypeMethodDeclaration itdm = new InterTypeMethodDeclarationImpl(
-                                    this, AjTypeSystem.getAjType(f.getType()), itdM
+                                    this, AjTypeSystem.getAjType(f.getType()), itdM,
+                                    Modifier.PUBLIC
                         );
                         toList.add(itdm);
                     }
@@ -684,28 +679,7 @@ public class AjTypeImpl<T> implements AjType<T> {
        private void addAnnotationStyleITDFields(List<InterTypeFieldDeclaration> toList, boolean publicOnly) {
         //AV: I think it is meaningless
         //@AJ decp is interface driven ie no field
-        // AMC: private fields in the mixin type should show as ITDs private to the aspect...
-        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)) {
-                        Class itdSource = f.getType();
-                        try {
-                               itdSource = f.get(null).getClass();
-                        } catch (IllegalAccessException ex) {
-                               //
-                        }
-                    for (Field itdF : itdSource.getDeclaredFields()) {
-                        if (!Modifier.isPublic(itdF.getModifiers()) && publicOnly) continue;
-                        InterTypeFieldDeclaration itdf = new InterTypeFieldDeclarationImpl(
-                                    this, AjTypeSystem.getAjType(f.getType()), itdF
-                        );
-                        toList.add(itdf);
-                    }
-                }
-            }
-               }
+               return;
        }
 
        /* (non-Javadoc)
index 2ed2f89cf3df88ffe0451f82f244227fefc0d48a..eb085a055821a4ebc3ab7e0af456f3377729d9dc 100644 (file)
@@ -47,8 +47,8 @@ public class InterTypeMethodDeclarationImpl extends InterTypeDeclarationImpl
                this.baseMethod = itdInterMethod;
        }
 
-       public InterTypeMethodDeclarationImpl(AjType<?> decType, AjType<?> targetType, Method base) {
-               super(decType,targetType,base.getModifiers());
+       public InterTypeMethodDeclarationImpl(AjType<?> decType, AjType<?> targetType, Method base, int modifiers) {
+               super(decType,targetType,modifiers);
                this.parameterAdjustmentFactor = 0;
                this.name = base.getName();
                this.baseMethod = base;
index 60ce8de3780f2c02aca9ebe6ef54ec1c646b0d32..f8d847b2f58d4edb8c610a22dcd0a7bdc8baaf75 100644 (file)
Binary files a/lib/aspectj/lib/aspectjrt.jar and b/lib/aspectj/lib/aspectjrt.jar differ
index 60ce8de3780f2c02aca9ebe6ef54ec1c646b0d32..f8d847b2f58d4edb8c610a22dcd0a7bdc8baaf75 100644 (file)
Binary files a/lib/test/aspectjrt.jar and b/lib/test/aspectjrt.jar differ
index 2882c87344db13762b815f52a8364428113ebb27..d60f6a3c65109c988882e75ba610e38f3d0930d2 100644 (file)
@@ -9,7 +9,13 @@ public aspect AtAspectJDeclareParents {
 
 class C {}
 
-interface I{}
+interface I{
+       
+       int getX();
+       
+       void setX(int x);
+       
+}
 
 class Impl implements I {
        
index efd48282093fb9bd1536bede57e1a7ff78335458..8f01325af7319cb2bddb4098635ff0c8905cb4de 100644 (file)
@@ -101,21 +101,7 @@ public class ReflectOnAtAspectJDeclareParents {
        
        private void testDeclaredInterTypeFields(AjType<AtAspectJDeclareParents> ajType) {
                InterTypeFieldDeclaration[] itdfs = ajType.getDeclaredITDFields();
-               assertEquals(1,itdfs.length,"number of declared ITD fields");
-               System.out.println(itdfs[0]);
-               try {
-                       InterTypeFieldDeclaration shouldFind = ajType.getDeclaredITDField("x",AjTypeSystem.getAjType(I.class));
-                       System.out.println(shouldFind);
-               } catch (NoSuchFieldException ex) {
-                       throw new RuntimeException("getITDField failed");
-               }
-               try {
-                       ajType.getDeclaredITDField("p",AjTypeSystem.getAjType(C.class));
-                       throw new RuntimeException("failed to fail in getting ITDField");
-               } catch (NoSuchFieldException ex) {
-                       // good!
-               }
-               
+               assertEquals(0,itdfs.length,"number of declared ITD fields");
        }
        
        private void testInterTypeFields(AjType<AtAspectJDeclareParents> ajType) {
index d6814e28e809b2bf159704912d2c53dbc6ae66ed..13bd9e4964371b1066a5142f57facb149013dcc8 100644 (file)
                        <line text="public int I.getX()"/>
                        <line text="public void I.setX(int)"/>
                        <line text="public int I.getX()"/>
-                       <line text="private int I.x"/>
-                       <line text="private int I.x"/>
                  </stdout>
                </run>
        </ajc-test>
index 445cc53a1f8b295b8c605a8847023d34fda99851..9515ec8ccf5f1189e391742dd47ec35841aa3899 100644 (file)
@@ -312,21 +312,24 @@ public class SignaturePattern extends PatternNode {
 //                     else return FuzzyBoolean.MAYBE;
                }
                
-               // annotations match on the *subject* 
-               if (!matchesAnnotations(aMember,inAWorld).alwaysTrue()) {
-                       return FuzzyBoolean.NO;
-               }
                
+               FuzzyBoolean matchesIgnoringAnnotations = FuzzyBoolean.YES;
                if (kind == Member.STATIC_INITIALIZATION) {
-                       return matchesExactlyStaticInitialization(aMember, inAWorld);
+                       matchesIgnoringAnnotations = matchesExactlyStaticInitialization(aMember, inAWorld);
                } else if (kind == Member.FIELD) {
-                       return matchesExactlyField(aMember,inAWorld);
+                       matchesIgnoringAnnotations = matchesExactlyField(aMember,inAWorld);
                } else if (kind == Member.METHOD) {
-                       return matchesExactlyMethod(aMember,inAWorld);
+                       matchesIgnoringAnnotations = matchesExactlyMethod(aMember,inAWorld);
                } else if (kind == Member.CONSTRUCTOR) {
-                       return matchesExactlyConstructor(aMember, inAWorld);
+                       matchesIgnoringAnnotations = matchesExactlyConstructor(aMember, inAWorld);
+               }
+               if (matchesIgnoringAnnotations.alwaysFalse()) return FuzzyBoolean.NO;
+               
+               // annotations match on the *subject* 
+               if (!matchesAnnotations(aMember,inAWorld).alwaysTrue()) {
+                       return FuzzyBoolean.NO;
                } else {
-                       return FuzzyBoolean.YES;
+                       return matchesIgnoringAnnotations;
                }
                
        }