summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/src/org/aspectj/systemtest/ajc169/IntertypeTests.java78
-rw-r--r--tests/src/org/aspectj/systemtest/ajc169/intertype.xml128
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java50
3 files changed, 255 insertions, 1 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc169/IntertypeTests.java b/tests/src/org/aspectj/systemtest/ajc169/IntertypeTests.java
index 4772d4b2b..6090458ab 100644
--- a/tests/src/org/aspectj/systemtest/ajc169/IntertypeTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc169/IntertypeTests.java
@@ -22,10 +22,88 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
/**
* Tests exploring intertype declared inner types and the new intertype syntax.
*
+ * Some design notes.<br>
+ * <p>
+ * Supporting inner types is not quite as straightforward as for the other kinds of ITD like methods, fields and constructors. When
+ * 'resolving' methods/fields/constructors they may refer to intertyped inner types, these means they must be in place early on -
+ * ahead of any member resolution. In order to achieve this they are done really early (for both the cases of pulling in a
+ * binarytypebinding - see AjLookupEnvironment.weaveInterTypeDeclarations(), and for sourcetypebindings
+ * AjLookupEnvironment.completeTypeBindings() where it calls processInterTypeMemberTypes).
+ * <p>
+ * The logic in AjLookupEnvironment.weaveInterTypeDeclarations() is temporarily disabled because I can't write a testcase that
+ * requires it! It should be an incremental build where a class is loaded as a binary type binding on a secondary (incremental)
+ * compile and that class needs the inner class applying.
+ * <p>
+ * Eclipse polices the names of inner types when loading binary type data. The name of the inner is actually maintained as the
+ * aspect name (so an inner type of Foo in an aspect Bar will be called Bar$Foo). The compiler looks after 'attaching' the inner
+ * type to the target type binding when required.
+ *
* @author Andy Clement
*/
public class IntertypeTests extends org.aspectj.testing.XMLBasedAjcTestCase {
+ public void testErrorTargettingTypeThatAlreadyHasIt() {
+ runTest("already has it");
+ }
+
+ public void testConstruction4() {
+ runTest("construction4");
+ }
+
+ public void testConstruction3() {
+ runTest("construction3");
+ }
+
+ public void testConstruction2() {
+ runTest("construction2");
+ }
+
+ public void testConstruction() {
+ runTest("construction");
+ }
+
+ // now the itd and the itd member class are in different aspects
+ public void testVoteItdMixture2() {
+ runTest("vote - itd mixture 2");
+ }
+
+ // This test is necessary because it verifies what happens when other ITDs are around
+ // in addition to the itd member class. In order to apply the other ITDs the methods in a target
+ // may get resolved. When they are resolved their types (return,etc) are resolved. If this
+ // happens before the innertype has been added to the target and the types involved reference that
+ // member type, then a failure will occur.
+ public void testVoteItdMixture() {
+ runTest("vote - itd mixture");
+ }
+
+ public void testVoteMethodReference() {
+ runTest("vote - method reference");
+ }
+
+ public void testVoteFieldReference() {
+ runTest("vote - field reference");
+ }
+
+ public void testVoteInnerInner() {
+ runTest("vote - inner inner");
+ }
+
+ public void testVoteReferenceViaAnnotation2() {
+ runTest("vote - reference via annotation - two");
+ }
+
+ public void testVoteReferenceViaAnnotation() {
+ runTest("vote - reference via annotation");
+ }
+
+ public void testVoteConstruction() {
+ runTest("vote - construction");
+ }
+
+ public void testVoteBasic() {
+ runTest("vote - basic");
+ }
+
// inter type declared classes - working scenarios
public void testFieldAccess() throws Exception {
runTest("field access");
diff --git a/tests/src/org/aspectj/systemtest/ajc169/intertype.xml b/tests/src/org/aspectj/systemtest/ajc169/intertype.xml
index 2cbb61190..b7d63078f 100644
--- a/tests/src/org/aspectj/systemtest/ajc169/intertype.xml
+++ b/tests/src/org/aspectj/systemtest/ajc169/intertype.xml
@@ -1,7 +1,133 @@
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
<suite>
-
+
+ <ajc-test dir="features169/itdInnerTypes/eleven" title="already has it">
+ <compile files="Target.java Aspect1.java" options="-1.5">
+ <message kind="error" text="target type already declares a member type with the name 'Inner'"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes" title="construction4">
+ <compile files="Construction4.java" options="-1.5"/>
+ <run class="Construction4">
+ <stdout>
+ <line text="abc"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes" title="construction3">
+ <compile files="Construction3.java" options="-1.5"/>
+ <run class="Construction3">
+ <stdout>
+ <line text="abc"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes/ten" title="construction2">
+ <compile files="Construction.java Aspect1.java Aspect2.java" options="-1.5"/>
+ <run class="Construction">
+ <stdout>
+ <line text="abcde"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes" title="construction">
+ <compile files="Construction.java" options="-1.5"/>
+ <run class="Construction">
+ <stdout>
+ <line text="done"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes/nine" title="vote - itd mixture 2">
+ <compile files="Underscorer.aj Vote.java Runner.java RelatedType.java" options="-1.5"/>
+ <run class="a.b.c.Runner">
+ <stdout>
+ <line text="wibble"/>
+ <line text="@a.b.c.RelatedType(value=class a.b.c.Underscorer$_$choice)"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes/eight" title="vote - itd mixture">
+ <compile files="Underscorer.aj Vote.java Runner.java RelatedType.java" options="-1.5"/>
+ <run class="a.b.c.Runner">
+ <stdout>
+ <line text="wibble"/>
+ <line text="@a.b.c.RelatedType(value=class a.b.c.Underscorer$_$choice)"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes/seven" title="vote - method reference">
+ <compile files="Underscorer.aj Vote.java Runner.java RelatedType.java" options="-1.5"/>
+ <run class="a.b.c.Runner">
+ <stdout>
+ <line text="wibble"/>
+ <line text="@a.b.c.RelatedType(value=class a.b.c.Underscorer$_$choice)"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes/six" title="vote - field reference">
+ <compile files="Vote.java Vote_Amender.aj Runner.java RelatedType.java" options="-1.5"/>
+ <run class="a.b.c.Runner">
+ <stdout>
+ <line text="wibble"/>
+ <line text="@a.b.c.RelatedType(value=class a.b.c.Vote_Amender$_$choice)"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes/five" title="vote - inner inner">
+ <compile files="Vote.java Vote_Amender.aj Runner.java RelatedType.java" options="-1.5"/>
+ <run class="a.b.c.Runner">
+ <stdout>
+ <line text="wibble"/>
+ <line text="@a.b.c.RelatedType(value=class a.b.c.Vote_Amender$_$choice)"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes/four" title="vote - reference via annotation - two">
+ <compile files="Vote.java Vote_Amender.aj Runner.java RelatedType.java" options="-1.5"/>
+ <run class="a.b.c.Runner">
+ <stdout>
+ <line text="wibble"/>
+ <line text="@a.b.c.RelatedType(value=class a.b.c.Vote_Amender$_$choice)"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes/three" title="vote - reference via annotation">
+ <compile files="Vote.java Vote_Amender.aj Runner.java RelatedType.java" options="-1.5"/>
+ <run class="a.b.c.Runner">
+ <stdout>
+ <line text="wibble"/>
+ <line text="@a.b.c.RelatedType(value=class a.b.c.Vote_Amender$_)"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes/two" title="vote - construction">
+ <compile files="Vote.java Vote_Amender.aj Runner.java" options="-1.5"/>
+ <run class="a.b.c.Runner">
+ <stdout>
+ <line text="wibble"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes/one" title="vote - basic">
+ <compile files="Vote.java Vote_Amender.aj Runner.java" options="-1.5"/>
+ <run class="a.b.c.Runner"/>
+ </ajc-test>
+
<ajc-test dir="features169/itdInnerTypes" title="choice - generics 1">
<compile files="ChoiceGenerics1.java" options="-1.5"/>
</ajc-test>
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
index d56c20838..ef5301b99 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
@@ -63,6 +63,56 @@ import org.aspectj.weaver.World;
*/
public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed {
+ public void testIncrementalITDInners3() throws Exception {
+ AjdeInteractionTestbed.VERBOSE = true;
+ String p = "prInner3";
+ initialiseProject(p);
+ build(p);
+ checkWasFullBuild();
+ // touch the aspect making the ITD member type
+ alter(p, "inc1");
+ build(p);
+ checkWasntFullBuild();
+ // touch the aspect making the ITD that depends on the member type
+ alter(p, "inc2");
+ build(p);
+ checkWasntFullBuild();
+ // touch the type affected by the ITDs
+ alter(p, "inc3");
+ build(p);
+ checkWasntFullBuild();
+ }
+
+ // mixing ITDs with inner type intertypes
+ public void testIncrementalITDInners2() throws Exception {
+ String p = "prInner2";
+ initialiseProject(p);
+ build(p);
+ checkWasFullBuild();
+ // touch the aspect making the ITD member type
+ alter(p, "inc1");
+ build(p);
+ checkWasntFullBuild();
+ // touch the aspect making the ITD that depends on the member type
+ alter(p, "inc2");
+ build(p);
+ checkWasntFullBuild();
+ // touch the type affected by the ITDs
+ alter(p, "inc3");
+ build(p);
+ checkWasntFullBuild();
+ }
+
+ public void testIncrementalITDInners() throws Exception {
+ String p = "prInner";
+ initialiseProject(p);
+ build(p);
+ checkWasFullBuild();
+ alter(p, "inc1");
+ build(p);
+ checkWasntFullBuild();
+ }
+
/*
* public void testIncrementalAspectWhitespace() throws Exception { AjdeInteractionTestbed.VERBOSE = true; String p = "xxx";
* initialiseProject(p); configureNonStandardCompileOptions(p, "-showWeaveInfo"); configureShowWeaveInfoMessages(p, true);