]> source.dussan.org Git - aspectj.git/commitdiff
fix for 138215 :- we need to resolve the pointcut expressions associated with declare...
authoracolyer <acolyer>
Tue, 25 Apr 2006 12:05:43 +0000 (12:05 +0000)
committeracolyer <acolyer>
Tue, 25 Apr 2006 12:05:43 +0000 (12:05 +0000)
weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java

index 397e8951c8ddf01495440b56eccb44096d2fe952..bc63e0d8ae6a3739d6cef686b409d5d48f3b119b 100644 (file)
@@ -1236,17 +1236,10 @@ public class AtAjAttributes {
                     reportError("@DeclareError used on a non String constant field", struct);
                     return false;
                 }
-                FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
-                IScope binding = new BindingScope(
-                        struct.enclosingType,
-                        struct.context,
-                        bindings
-                );
                 Pointcut pc = parsePointcut(declareError.getValue().stringifyValue(), struct, false);
                 if (pc == null) {
                     hasError = false;//cannot parse pointcut
-                } else {
-                    pc .resolve(binding);
+                } else {                        
                     DeclareErrorOrWarning deow = new DeclareErrorOrWarning(true, pc, struct.field.getConstantValue().toString());
                     setDeclareErrorOrWarningLocation(deow,struct);
                     struct.ajAttributes.add(new AjAttribute.DeclareAttribute(deow));
@@ -1263,17 +1256,10 @@ public class AtAjAttributes {
                     reportError("@DeclareWarning used on a non String constant field", struct);
                     return false;
                 }
-                FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
-                IScope binding = new BindingScope(
-                        struct.enclosingType,
-                        struct.context,
-                        bindings
-                );
                 Pointcut pc = parsePointcut(declareWarning.getValue().stringifyValue(), struct, false);
                 if (pc == null) {
                     hasWarning = false;//cannot parse pointcut
                 } else {
-                    pc.resolve(binding);
                     DeclareErrorOrWarning deow = new DeclareErrorOrWarning(false, pc, struct.field.getConstantValue().toString());
                     setDeclareErrorOrWarningLocation(deow,struct);
                     struct.ajAttributes.add(new AjAttribute.DeclareAttribute(deow));
index 2bcd7a7d3628599cfc78d9013ac0d769705d1ab3..d48eaa8f834d57d354db24286f4ceca6a62c3388 100644 (file)
@@ -48,7 +48,12 @@ import org.aspectj.weaver.TypeVariable;
 import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.WeaverStateInfo;
 import org.aspectj.weaver.World;
+import org.aspectj.weaver.bcel.AtAjAttributes.BindingScope;
 import org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter.GenericSignatureFormatException;
+import org.aspectj.weaver.patterns.Declare;
+import org.aspectj.weaver.patterns.DeclareErrorOrWarning;
+import org.aspectj.weaver.patterns.FormalBinding;
+import org.aspectj.weaver.patterns.IScope;
 import org.aspectj.weaver.patterns.PerClause;
 
 public class BcelObjectType extends AbstractReferenceTypeDelegate {
@@ -304,6 +309,8 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
                
                this.pointcuts = (ResolvedPointcutDefinition[]) 
                        pointcuts.toArray(new ResolvedPointcutDefinition[pointcuts.size()]);
+               
+               resolveAnnotationDeclares(l);
 
                if (deferredAspectAttribute != null) {
                        // we can finally process the aspect and its associated perclause...
@@ -348,6 +355,29 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
                }
                return deferredAspectAttribute;
        }
+    
+    /**
+     * Extra processing step needed because declares that come from annotations are not pre-resolved.
+     * We can't do the resolution until *after* the pointcuts have been resolved.
+     * @param attributeList
+     */
+    private void resolveAnnotationDeclares(List attributeList) {
+       FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
+        IScope bindingScope = new BindingScope(
+                getResolvedTypeX(),
+                getResolvedTypeX().getSourceContext(),
+                bindings
+        );
+               for (Iterator iter = attributeList.iterator(); iter.hasNext();) {
+                       AjAttribute a = (AjAttribute) iter.next();
+                       if (a instanceof AjAttribute.DeclareAttribute) {
+                               Declare decl = (((AjAttribute.DeclareAttribute)a).getDeclare());
+                               if (decl instanceof DeclareErrorOrWarning) {
+                                 decl.resolve(bindingScope);
+                               }
+                       }
+               }       
+    }
 
        public PerClause getPerClause() {
         ensureAspectJAttributesUnpacked();