aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoracolyer <acolyer>2006-06-24 11:36:59 +0000
committeracolyer <acolyer>2006-06-24 11:36:59 +0000
commitc9f311aeeb11fb1427ec8857c24cfe3ffa6c7c9d (patch)
tree7b504df238cfdb1e0d2352c97014816eb6535f35 /tests
parent16d8120ef10e7934c658c5457fb46e67d4ed9b78 (diff)
downloadaspectj-c9f311aeeb11fb1427ec8857c24cfe3ffa6c7c9d.tar.gz
aspectj-c9f311aeeb11fb1427ec8857c24cfe3ffa6c7c9d.zip
tests and implementation for enh 147711 (use true synthetic attribute/flag for aj synthetic members).
Diffstat (limited to 'tests')
-rw-r--r--tests/features152/synthetic/TheWholeShow.aj139
-rw-r--r--tests/features152/synthetic/design.txt2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ajc150.xml4
-rw-r--r--tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java1
-rw-r--r--tests/src/org/aspectj/systemtest/ajc152/ajc152.xml5
5 files changed, 149 insertions, 2 deletions
diff --git a/tests/features152/synthetic/TheWholeShow.aj b/tests/features152/synthetic/TheWholeShow.aj
new file mode 100644
index 000000000..d1e032e8b
--- /dev/null
+++ b/tests/features152/synthetic/TheWholeShow.aj
@@ -0,0 +1,139 @@
+import java.lang.reflect.*;
+
+public class TheWholeShow {
+
+ private int f;
+
+ public void foo() {}
+
+ private void bar() {}
+
+ public static void main(String[] args) {
+ Field[] twsFields = TheWholeShow.class.getDeclaredFields();
+ for (Field f : twsFields) {
+ if (!f.getName().equals("f") && !f.getName().equals("x")) {
+ if (!f.isSynthetic()) {
+ System.err.println("Found non-synthetic field: " + f.getName());
+ throw new IllegalStateException("Found non-synthetic field: " + f.getName());
+ }
+ if (!Modifier.isStatic(f.getModifiers()) && !Modifier.isTransient(f.getModifiers())) {
+ System.err.println("Found non-transient field: " + f.getName());
+ throw new IllegalStateException("Found non-transient field: " + f.getName());
+ }
+ }
+ }
+
+ Method[] twsMethods = TheWholeShow.class.getDeclaredMethods();
+ for (Method m: twsMethods) {
+ if (! (m.getName().equals("foo") || m.getName().equals("bar") || m.getName().equals("<init>") ||
+ m.getName().equals("main") || m.getName().equals("checkOnlyHasAdviceMembers") || m.getName().equals("getX")) ) {
+ if (!m.isSynthetic()) {
+ System.err.println("Found non-synthetic method: " + m.getName());
+ throw new IllegalStateException("Found non-synthetic method: " + m.getName());
+ }
+ }
+ }
+
+ checkOnlyHasAdviceMembers(MakeITDs.class);
+ checkOnlyHasAdviceMembers(Declares.class);
+ checkOnlyHasAdviceMembers(Advises.class);
+ checkOnlyHasAdviceMembers(PerObject.class);
+ checkOnlyHasAdviceMembers(PTW.class);
+ checkOnlyHasAdviceMembers(Priv.class);
+
+ }
+
+
+ private static void checkOnlyHasAdviceMembers(Class c) {
+ Method[] ms = c.getDeclaredMethods();
+ Field[] fs = c.getDeclaredFields();
+
+ for (Field f : fs) {
+ if (!f.isSynthetic()) {
+ System.err.println("Found non-synthetic field: " + f.getName() + " in " + c.getName());
+ throw new IllegalStateException("Found non-synthetic field: " + f.getName());
+ }
+ }
+
+ for (Method m : ms) {
+ if (!m.isSynthetic()) {
+ String name = m.getName();
+ if ( ! (name.startsWith("ajc$before") || name.startsWith("ajc$after") || name.startsWith("ajc$around") ||
+ name.startsWith("ajc$interMethod$"))) {
+ System.err.println("Found non-synthetic method: " + m.getName() + " in " + c.getName());
+ throw new IllegalStateException("Found non-synthetic method: " + m.getName());
+ } else if (name.startsWith("ajc$around") && name.endsWith("proceed")) {
+ System.err.println("Found non-synthetic method: " + m.getName() + " in " + c.getName());
+ throw new IllegalStateException("Found non-synthetic method: " + m.getName());
+ }
+ }
+ }
+ }
+}
+
+
+aspect MakeITDs {
+
+ public int TheWholeShow.x = 5;
+ private int TheWholeShow.y = 6;
+ int TheWholeShow.z = 7;
+
+ public int TheWholeShow.getX() { return x; }
+
+ private int TheWholeShow.getY() { return y; }
+
+ int TheWholeShow.getZ() { return z; }
+
+}
+
+aspect Declares {
+
+ interface Foo {}
+
+ declare parents : TheWholeShow implements Foo;
+
+ declare warning : execution(* TheWholeShow.notThere(..)) : "foo";
+
+ declare soft : Exception : execution(* TheWholeShow.foo(..));
+
+}
+
+aspect Advises {
+
+ pointcut pc() : execution(* TheWholeShow.*(..));
+
+ before() : pc() {}
+
+ Object around(Object tws) : pc() && this(tws) {
+ return proceed(new TheWholeShow());
+ }
+
+ after() : pc() {}
+
+ after() returning : pc() {}
+
+ after() throwing : pc() {}
+
+
+}
+
+aspect PerObject perthis(execution(* TheWholeShow.*(..))) {
+
+}
+
+aspect PTW pertypewithin(TheWholeShow) {}
+
+aspect Cflow {
+
+ before() : set(* x) && cflow(execution(* TheWholeShow.*(..))) {}
+
+}
+
+privileged aspect Priv {
+
+ before(TheWholeShow tws) : execution(* TheWholeShow.foo()) && this(tws) {
+ tws.bar();
+ tws.f = 12;
+ }
+
+} \ No newline at end of file
diff --git a/tests/features152/synthetic/design.txt b/tests/features152/synthetic/design.txt
index bfc7909ff..c6574c1ef 100644
--- a/tests/features152/synthetic/design.txt
+++ b/tests/features152/synthetic/design.txt
@@ -61,3 +61,5 @@ ajc$interField$... field ITD-field yes
ajc$interFieldGet$... method on target of ITD-field yes
ajc$interFieldSet$... method on target of ITD-field yes
ajc$interMethodDispatch2$... method on target of ITD-method yes
+
+** note - also make sure that every ajc$ field we introduce in a woven type is marked as transient.
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
index 091042fae..57efbdf93 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
@@ -84,7 +84,7 @@
<run class="Declaration1">
<stdout>
<line text="public java.lang.String Test.firstProperty has annotation:true"/>
- <line text="public java.lang.String Test.ajc$interField$Declaration1$TestInterface$secondProperty has annotation:true"/>
+ <line text="public transient java.lang.String Test.ajc$interField$Declaration1$TestInterface$secondProperty has annotation:true"/>
</stdout>
</run>
</ajc-test>
@@ -117,7 +117,7 @@
<run class="Declaration2">
<stdout>
<line text="public java.lang.String Test.firstProperty has annotation:true"/>
- <line text="public java.lang.String Test.ajc$interField$Declaration2$TestInterface$secondProperty has annotation:true"/>
+ <line text="public transient java.lang.String Test.ajc$interField$Declaration2$TestInterface$secondProperty has annotation:true"/>
</stdout>
</run>
</ajc-test>
diff --git a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
index 202e592a4..e0764bc6b 100644
--- a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
@@ -103,6 +103,7 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void testGenericAspectHierarchyWithBounds_pr147845() { runTest("Generic abstract aspect hierarchy with bounds"); }
public void testJRockitBooleanReturn_pr148007() { runTest("jrockit boolean fun");}
public void testJRockitBooleanReturn2_pr148007() { runTest("jrockit boolean fun (no aspects)");}
+ public void testSyntheticAjcMembers_pr147711() { runTest("synthetic ajc$ members"); }
public void testDeclareAtMethodRelationship_pr143924() {
//AsmManager.setReporting("c:/debug.txt",true,true,true,true);
diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
index 1505d989a..87d466f62 100644
--- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
+++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
@@ -755,5 +755,10 @@
<ajc-test dir="bugs152/pr148007/purejava" title="jrockit boolean fun (no aspects)">
<compile files="test/BooleanUnitTest.java, test/LoggingAspect.java" options="-inlineJSR"/>
<run class="test.BooleanUnitTest"/>
+ </ajc-test>
+
+ <ajc-test dir="features152/synthetic" title="synthetic ajc$ members">
+ <compile files="TheWholeShow.aj" options="-1.5"/>
+ <run class="TheWholeShow"/>
</ajc-test>
</suite> \ No newline at end of file