SourceTypeBinding[] b = units[i].scope.topLevelTypes;
for (int j = 0; j < b.length; j++) {
buildInterTypeAndPerClause(b[j].scope);
- }
- }
- for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
- SourceTypeBinding[] b = units[i].scope.topLevelTypes;
- for (int j = 0; j < b.length; j++) {
- resolvePointcutDeclarations(b[j].scope);
- }
- }
-
- for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
- SourceTypeBinding[] b = units[i].scope.topLevelTypes;
- for (int j = 0; j < b.length; j++) {
addCrosscuttingStructures(b[j].scope);
}
- }
+ }
+
factory.finishTypeMungers();
// now do weaving
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
weaveInterTypeDeclarations(units[i].scope, typeMungers, declareParents);
- units[i] = null; // release unnecessary reference to the parsed unit
}
+
+ for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
+ SourceTypeBinding[] b = units[i].scope.topLevelTypes;
+ for (int j = 0; j < b.length; j++) {
+ resolvePointcutDeclarations(b[j].scope);
+ }
+ }
+
+ for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
+ SourceTypeBinding[] b = units[i].scope.topLevelTypes;
+ for (int j = 0; j < b.length; j++) {
+ addAdviceLikeDeclares(b[j].scope);
+ }
+ }
+
+ for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
+ units[i] = null; // release unnecessary reference to the parsed unit
+ }
stepCompleted = BUILD_FIELDS_AND_METHODS;
lastCompletedUnitIndex = lastUnitIndex;
}
pendingTypesToWeave.clear();
}
+
+ private void addAdviceLikeDeclares(ClassScope s) {
+ TypeDeclaration dec = s.referenceContext;
+
+ if (dec instanceof AspectDeclaration) {
+ ResolvedTypeX typeX = factory.fromEclipse(dec.binding);
+ factory.getWorld().getCrosscuttingMembersSet().addAdviceLikeDeclares(typeX);
+ }
+
+ SourceTypeBinding sourceType = s.referenceContext.binding;
+ ReferenceBinding[] memberTypes = sourceType.memberTypes;
+ for (int i = 0, length = memberTypes.length; i < length; i++) {
+ addCrosscuttingStructures(((SourceTypeBinding) memberTypes[i]).scope);
+ }
+ }
private void addCrosscuttingStructures(ClassScope s) {
TypeDeclaration dec = s.referenceContext;
<compile files="aspects/Softener.aj,test/NoSoftener.java"/>
<run class="test.NoSoftener"/>
</ajc-test>
+
+ <ajc-test dir="bugs" pr="42993"
+ title="Interaction between pointcut binding and declare parents">
+ <compile files="ParentsAndPointcuts.java"/>
+ <run class="ParentsAndPointcuts"/>
+ </ajc-test>
</suite>
--- /dev/null
+import org.aspectj.testing.Tester;
+
+public class ParentsAndPointcuts {
+ public static void main(String[] args) {
+ ContainerDescriptor d = new ContainerDescriptor();
+ Tester.check(d instanceof AbstractCaching.Key, "instanceof");
+ }
+}
+
+aspect AspectBug extends AbstractCaching
+perthis(execution(ContainerLoader+.new(..)))
+{
+ declare parents: ContainerDescriptor implements AbstractCaching.Key;
+
+ protected pointcut loadExecutions( Key key ):
+ ContainerLoader.containerLoads( *, key );
+}
+
+abstract aspect AbstractCaching {
+ interface Key {}
+ protected abstract pointcut loadExecutions(Key key);
+}
+
+class Key {
+}
+
+class ContainerDescriptor {
+}
+
+class ActiveContainer {
+}
+
+class ContainerLoader {
+ public ActiveContainer createContainer(ContainerDescriptor c) {
+ return null;
+ }
+
+ public pointcut containerLoads(ContainerLoader loader,
+
+ContainerDescriptor containerDesc ):
+ this(loader) && args(containerDesc)
+ && execution(ActiveContainer ContainerLoader.createContainer
+(ContainerDescriptor));
+}
\ No newline at end of file
}
}
}
+
+ public void addAdviceLikeDeclares(ResolvedTypeX aspectType) {
+ CrosscuttingMembers xcut = (CrosscuttingMembers)members.get(aspectType);
+ xcut.addDeclares(aspectType.collectDeclares(true));
+ }
public boolean deleteAspect(TypeX aspectType) {
boolean isAspect = members.remove(aspectType) != null;
public boolean containsAspect(TypeX aspectType) {
return members.containsKey(aspectType);
}
-
+
//XXX only for testing
public void addFixedCrosscuttingMembers(ResolvedTypeX aspectType) {
members.put(aspectType, aspectType.crosscuttingMembers);
declareDominates = ret;
}
return declareDominates;
- }
-
-
-
+ }
}
crosscuttingMembers.setPerClause(getPerClause());
crosscuttingMembers.addShadowMungers(collectShadowMungers());
crosscuttingMembers.addTypeMungers(getTypeMungers());
- crosscuttingMembers.addDeclares(collectDeclares());
+ crosscuttingMembers.addDeclares(collectDeclares(!this.doesNotExposeShadowMungers()));
crosscuttingMembers.addPrivilegedAccesses(getPrivilegedAccesses());
//System.err.println("collected cc members: " + this + ", " + collectDeclares());
return crosscuttingMembers;
}
- private final Collection collectDeclares() {
+ public final Collection collectDeclares(boolean includeAdviceLike) {
if (! this.isAspect() ) return Collections.EMPTY_LIST;
ArrayList ret = new ArrayList();
Declare dec = (Declare) i.next();
if (!dec.isAdviceLike()) ret.add(dec);
}
+
+ if (!includeAdviceLike) return ret;
+
if (!this.isAbstract()) {
//ret.addAll(getDeclares());
final Iterators.Filter dupFilter = Iterators.dupFilter();