aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java17
-rw-r--r--tests/ajcTests.xml15
-rw-r--r--tests/bugs/perCflowAndJar/PerCFlowCompileFromJar.java20
-rw-r--r--tests/bugs/perCflowAndJar/PerCFlowCompileFromJarTest.java23
-rw-r--r--tests/bugs/perCflowAndJar/lib.jarbin0 -> 900 bytes
5 files changed, 70 insertions, 5 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
index 935b6c3f0..e0967d667 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
@@ -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) {
diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml
index 1412ad04d..db51bfc2c 100644
--- a/tests/ajcTests.xml
+++ b/tests/ajcTests.xml
@@ -6705,4 +6705,19 @@
<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
index 000000000..cfb7c73e0
--- /dev/null
+++ b/tests/bugs/perCflowAndJar/PerCFlowCompileFromJar.java
@@ -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
index 000000000..cf30fcc78
--- /dev/null
+++ b/tests/bugs/perCflowAndJar/PerCFlowCompileFromJarTest.java
@@ -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
index 000000000..6ca2c5007
--- /dev/null
+++ b/tests/bugs/perCflowAndJar/lib.jar
Binary files differ