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;
}
//XXX need to handle this too
return null;
}
- }
+ if (perClause == null) {
+ return lookupPerClauseKind(binding.superclass());
+ } else {
+ return perClause.getKind();
+ }
+ }
private void buildPerClause(ClassScope scope) {
<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>
--- /dev/null
+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;
+ }
+}
+
+
--- /dev/null
+
+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