mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-09-13 15:45:38 +02:00
fix and test for Bugzilla Bug 41359
percflow aspects compiled from jars share one instance for all entry points
This commit is contained in:
parent
d8b8674366
commit
5a07dcee3a
@ -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) {
|
||||
|
@ -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>
|
||||
|
20
tests/bugs/perCflowAndJar/PerCFlowCompileFromJar.java
Normal file
20
tests/bugs/perCflowAndJar/PerCFlowCompileFromJar.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
23
tests/bugs/perCflowAndJar/PerCFlowCompileFromJarTest.java
Normal file
23
tests/bugs/perCflowAndJar/PerCFlowCompileFromJarTest.java
Normal file
@ -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() );
|
||||
}
|
BIN
tests/bugs/perCflowAndJar/lib.jar
Normal file
BIN
tests/bugs/perCflowAndJar/lib.jar
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user