fix and test for Bugzilla Bug 41359

percflow aspects compiled from jars share one instance for all entry points
This commit is contained in:
jhugunin 2003-08-28 21:44:55 +00:00
parent d8b8674366
commit 5a07dcee3a
5 changed files with 70 additions and 5 deletions

View 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) {

View File

@ -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>

View 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;
}
}

View 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() );
}

Binary file not shown.