]> source.dussan.org Git - aspectj.git/commitdiff
fix and test for Bugzilla Bug 41359
authorjhugunin <jhugunin>
Thu, 28 Aug 2003 21:44:55 +0000 (21:44 +0000)
committerjhugunin <jhugunin>
Thu, 28 Aug 2003 21:44:55 +0000 (21:44 +0000)
   percflow aspects compiled from jars share one instance for all entry points

org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
tests/ajcTests.xml
tests/bugs/perCflowAndJar/PerCFlowCompileFromJar.java [new file with mode: 0644]
tests/bugs/perCflowAndJar/PerCFlowCompileFromJarTest.java [new file with mode: 0644]
tests/bugs/perCflowAndJar/lib.jar [new file with mode: 0644]

index 935b6c3f04474177a26667cb84d6ffb700fc2151..e0967d667e09b563e5229d81ab43627e584f4bad 100644 (file)
@@ -658,12 +658,14 @@ public class AspectDeclaration extends MemberTypeDeclaration {
 
        
        private PerClause.Kind lookupPerClauseKind(ReferenceBinding binding) {
-               if (binding instanceof SourceTypeBinding && !(binding instanceof BinaryTypeBinding)) {
+        PerClause perClause;
+        if (binding instanceof BinaryTypeBinding) {
+            ResolvedTypeX superTypeX = factory.fromEclipse(binding);
+            perClause = superTypeX.getPerClause();
+        } else if (binding instanceof SourceTypeBinding ) {
                        SourceTypeBinding sourceSc = (SourceTypeBinding)binding;
                        if (sourceSc.scope.referenceContext instanceof AspectDeclaration) {
-                               PerClause perClause = ((AspectDeclaration)sourceSc.scope.referenceContext).perClause;
-                               if (perClause == null) return lookupPerClauseKind(binding.superclass());
-                               else return perClause.getKind();
+                               perClause = ((AspectDeclaration)sourceSc.scope.referenceContext).perClause;
                        } else {
                                return null;
                        }
@@ -671,7 +673,12 @@ public class AspectDeclaration extends MemberTypeDeclaration {
                        //XXX need to handle this too
                        return null;
                }
-       }
+        if (perClause == null) {
+            return lookupPerClauseKind(binding.superclass()); 
+        } else {
+            return perClause.getKind();
+           }
+    }
        
 
        private void buildPerClause(ClassScope scope) {
index 1412ad04d6c74b049f7d4072d5942daad962914b..db51bfc2c667523bf664092aa5035fb389d316f7 100644 (file)
                    <message kind="error" line="3"/>
                </compile>
        </ajc-test>
+       
+       <ajc-test dir="bugs/perCflowAndJar"
+               pr="41359"
+               title="percflow aspects compiled from jars share one instance for all entry points">
+               <compile files="PerCFlowCompileFromJar.java,PerCFlowCompileFromJarTest.java"/>
+               <run class="PerCFlowCompileFromJarTest"/>
+       </ajc-test>
+       
+       <ajc-test dir="bugs/perCflowAndJar"
+               pr="41359"
+               title="(using aspectpath) percflow aspects compiled from jars share one instance for all entry points">
+               <compile files="PerCFlowCompileFromJarTest.java"
+                               aspectpath="lib.jar"/>
+               <run class="PerCFlowCompileFromJarTest"/>
+       </ajc-test>
 </suite>
diff --git a/tests/bugs/perCflowAndJar/PerCFlowCompileFromJar.java b/tests/bugs/perCflowAndJar/PerCFlowCompileFromJar.java
new file mode 100644 (file)
index 0000000..cfb7c73
--- /dev/null
@@ -0,0 +1,20 @@
+public abstract aspect PerCFlowCompileFromJar percflow( topOfFlow() ){
+       
+       private boolean thisAspectInstanceIsDead = false; 
+
+       protected abstract pointcut entryPoint();
+       protected pointcut topOfFlow(): entryPoint() && !cflowbelow( entryPoint() );
+
+       after() : topOfFlow() {
+               this.killThisAspectInstance();
+       }
+
+       protected void killThisAspectInstance(){
+               if (thisAspectInstanceIsDead)
+                       throw new IllegalStateException("This aspect instance has been used and can't be used again.");
+               else
+                       thisAspectInstanceIsDead = true;
+       }       
+}
+
+
diff --git a/tests/bugs/perCflowAndJar/PerCFlowCompileFromJarTest.java b/tests/bugs/perCflowAndJar/PerCFlowCompileFromJarTest.java
new file mode 100644 (file)
index 0000000..cf30fcc
--- /dev/null
@@ -0,0 +1,23 @@
+
+public class PerCFlowCompileFromJarTest  {
+
+    public static void main(String[] args) throws Exception {
+               PerCFlowTestHelper c1 = new PerCFlowTestHelper();
+               PerCFlowTestHelper c2 = new PerCFlowTestHelper();
+               PerCFlowTestHelper c3 = new PerCFlowTestHelper();
+               c1.startNewPerCFlow();
+               c2.startNewPerCFlow();
+               c3.startNewPerCFlow();
+       }
+}
+
+class PerCFlowTestHelper {
+       public void startNewPerCFlow()throws Exception{
+               //do nothing            
+       }       
+}
+
+aspect MyTestPerCFlowEntryPoint extends PerCFlowCompileFromJar {
+       protected pointcut entryPoint():
+               execution( public void PerCFlowTestHelper.startNewPerCFlow() ); 
+}
\ No newline at end of file
diff --git a/tests/bugs/perCflowAndJar/lib.jar b/tests/bugs/perCflowAndJar/lib.jar
new file mode 100644 (file)
index 0000000..6ca2c50
Binary files /dev/null and b/tests/bugs/perCflowAndJar/lib.jar differ