From: acolyer Date: Mon, 12 Sep 2005 10:04:51 +0000 (+0000) Subject: tests and fix for pr108903 - MUST process from super aspect to sub aspect when findin... X-Git-Tag: preDefaultReweavable~103 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f5030e64039e19f562423d9c8b7f7b4587ecdea7;p=aspectj.git tests and fix for pr108903 - MUST process from super aspect to sub aspect when finding declares --- diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index f157dbbda..4b4ada030 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -122,14 +122,22 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC AnonymousClassPublisher.aspectOf().setAnonymousClassCreationListener(this); // need to build inter-type declarations for all AspectDeclarations at this point - for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { - SourceTypeBinding[] b = units[i].scope.topLevelTypes; - for (int j = 0; j < b.length; j++) { - buildInterTypeAndPerClause(b[j].scope); - addCrosscuttingStructures(b[j].scope); - } - } + // this MUST be done in order from super-types to subtypes + List typesToProcess = new ArrayList(); + for (int i=lastCompletedUnitIndex+1; i<=lastUnitIndex; i++) { + CompilationUnitScope cus = units[i].scope; + SourceTypeBinding[] stbs = cus.topLevelTypes; + for (int j=0; j0) { + // removes types from the list as they are processed... + collectAllITDsAndDeclares((SourceTypeBinding)typesToProcess.get(0),typesToProcess); + } + factory.finishTypeMungers(); // now do weaving @@ -156,7 +164,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC boolean typeProcessingOrderIsImportant = declareParents.size()>0 || declareAnnotationOnTypes.size()>0; //DECAT if (typeProcessingOrderIsImportant) { - List typesToProcess = new ArrayList(); + typesToProcess = new ArrayList(); for (int i=lastCompletedUnitIndex+1; i<=lastUnitIndex; i++) { CompilationUnitScope cus = units[i].scope; SourceTypeBinding[] stbs = cus.topLevelTypes; @@ -201,6 +209,24 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC lastCompletedUnitIndex = lastUnitIndex; } + + /** + * Find all the ITDs and Declares, but it is important we do this from the supertypes + * down to the subtypes. + * @param sourceType + * @param yetToProcess + */ + private void collectAllITDsAndDeclares(SourceTypeBinding sourceType, Collection yetToProcess) { + // Look at the supertype first + ReferenceBinding superType = sourceType.superclass(); + if (yetToProcess.contains(superType) && superType instanceof SourceTypeBinding) { + collectAllITDsAndDeclares((SourceTypeBinding)superType, yetToProcess); + } + buildInterTypeAndPerClause(sourceType.scope); + addCrosscuttingStructures(sourceType.scope); + yetToProcess.remove(sourceType); + } + /** * Weave the parents and intertype decls into a given type. This method looks at the * supertype and superinterfaces for the specified type and recurses to weave those first diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java index 406542ec1..e95c78233 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java @@ -27,7 +27,6 @@ import org.aspectj.ajdt.internal.core.builder.AjBuildManager; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.IMessage.Kind; import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; -import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; diff --git a/tests/bugs150/pr108903/com/designpattern/decorator/HeaderDecorator.aj b/tests/bugs150/pr108903/com/designpattern/decorator/HeaderDecorator.aj new file mode 100644 index 000000000..fe9f12b88 --- /dev/null +++ b/tests/bugs150/pr108903/com/designpattern/decorator/HeaderDecorator.aj @@ -0,0 +1,19 @@ +/** + * + */ +package com.designpattern.decorator; + +public aspect HeaderDecorator extends OrderDecorator +{ + + void around(Order order) : print(order) + { + printHeader(order); + proceed(order); + } + + private void printHeader(Order order) + { + System.out.println("XYZ Incorporated\nDate of Sale:"); + } +} diff --git a/tests/bugs150/pr108903/com/designpattern/decorator/Main.java b/tests/bugs150/pr108903/com/designpattern/decorator/Main.java new file mode 100644 index 000000000..580150e79 --- /dev/null +++ b/tests/bugs150/pr108903/com/designpattern/decorator/Main.java @@ -0,0 +1,11 @@ +package com.designpattern.decorator; + +public class Main { + private static Order order; + + public static void main(String[] args) { + order = new SalesOrder(); + order.print(); + + } +} diff --git a/tests/bugs150/pr108903/com/designpattern/decorator/Order.java b/tests/bugs150/pr108903/com/designpattern/decorator/Order.java new file mode 100644 index 000000000..8ab3a8eb5 --- /dev/null +++ b/tests/bugs150/pr108903/com/designpattern/decorator/Order.java @@ -0,0 +1,9 @@ +package com.designpattern.decorator; + +public abstract class Order { + + public void print() { + System.out.print("Order.print()") ; + } + +} diff --git a/tests/bugs150/pr108903/com/designpattern/decorator/OrderDecorator.aj b/tests/bugs150/pr108903/com/designpattern/decorator/OrderDecorator.aj new file mode 100644 index 000000000..0c4926bee --- /dev/null +++ b/tests/bugs150/pr108903/com/designpattern/decorator/OrderDecorator.aj @@ -0,0 +1,17 @@ +/** + * + */ +package com.designpattern.decorator; + +public abstract aspect OrderDecorator +{ + protected pointcut print(Order order) : target(order) && call(public void print()); + + declare parents : SalesOrder extends Order ; + + public void SalesOrder.print() + { + super.print(); + } + +} diff --git a/tests/bugs150/pr108903/com/designpattern/decorator/SalesOrder.java b/tests/bugs150/pr108903/com/designpattern/decorator/SalesOrder.java new file mode 100644 index 000000000..2dd0add5c --- /dev/null +++ b/tests/bugs150/pr108903/com/designpattern/decorator/SalesOrder.java @@ -0,0 +1,5 @@ +package com.designpattern.decorator; + +public class SalesOrder { + +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 29d58d31f..41105f06d 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -405,7 +405,11 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testSuperCallInITD() { runTest("super call in ITD"); } - + + public void testSuperCallInITDPart2() { + runTest("super call in ITD - part 2"); + } + public void testNoUnusedParameterWarningsForSyntheticAdviceArgs() { runTest("no unused parameter warnings for synthetic advice args"); } @@ -417,6 +421,8 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testCantFindTypeErrorWithGenericReturnTypeOrParameter() { runTest("cant find type error with generic return type or parameter"); } + + // currently failing... // public void testNoVerifyErrorOnGenericCollectionMemberAccess() { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 3e44ba7f1..cbd07c281 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -542,7 +542,12 @@ - + + + + + +