diff options
author | acolyer <acolyer> | 2006-06-24 11:36:59 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2006-06-24 11:36:59 +0000 |
commit | c9f311aeeb11fb1427ec8857c24cfe3ffa6c7c9d (patch) | |
tree | 7b504df238cfdb1e0d2352c97014816eb6535f35 /tests/features152 | |
parent | 16d8120ef10e7934c658c5457fb46e67d4ed9b78 (diff) | |
download | aspectj-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/features152')
-rw-r--r-- | tests/features152/synthetic/TheWholeShow.aj | 139 | ||||
-rw-r--r-- | tests/features152/synthetic/design.txt | 2 |
2 files changed, 141 insertions, 0 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. |