diff --git a/tests/ajcTestsFailing.xml b/tests/ajcTestsFailing.xml index c2fb46b05..27079b95d 100644 --- a/tests/ajcTestsFailing.xml +++ b/tests/ajcTestsFailing.xml @@ -133,4 +133,10 @@ + + + + + diff --git a/tests/bugs/protectedvf/main/Driver.java b/tests/bugs/protectedvf/main/Driver.java new file mode 100644 index 000000000..6590760eb --- /dev/null +++ b/tests/bugs/protectedvf/main/Driver.java @@ -0,0 +1,18 @@ +package main; + +public class Driver{ + + public static void main(String[] args) { + Driver d = new Driver(); + d.doStuff(); + d.doOtherStuff(); + } + + private void doOtherStuff() { + System.out.println("doing other stuff"); + } + + private void doStuff() { + System.out.println("doing stuff"); + } +} diff --git a/tests/bugs/protectedvf/main/p1/ConcreteTest.aj b/tests/bugs/protectedvf/main/p1/ConcreteTest.aj new file mode 100644 index 000000000..be044e544 --- /dev/null +++ b/tests/bugs/protectedvf/main/p1/ConcreteTest.aj @@ -0,0 +1,23 @@ +package main.p1; + +import main.p2.AbstractTest; +import main.Driver; + +final aspect ConcreteTest extends AbstractTest { + + protected pointcut pc(): execution(* Driver.doStuff()); + + protected pointcut pc2(): execution(* Driver.doOtherStuff()); + + Object around(): pc2() { + System.out.println("adding to the other stuff"); + /*If we comment out the next line we don't get a verify error.*/ + System.out.println("The value of the field when replacing is " + getField()); + return proceed(); + } + + protected void hook() { + /*This doesn't cause a verify error seemably because the advice calling it is in AbstractTest*/ + System.out.println("The value of the field is " + getField()); + } +} \ No newline at end of file diff --git a/tests/bugs/protectedvf/main/p2/AbstractTest.aj b/tests/bugs/protectedvf/main/p2/AbstractTest.aj new file mode 100644 index 000000000..0c8b040c4 --- /dev/null +++ b/tests/bugs/protectedvf/main/p2/AbstractTest.aj @@ -0,0 +1,20 @@ +package main.p2; + +public abstract aspect AbstractTest { + + private int field; + + protected abstract pointcut pc(); + + Object around(): pc() { + this.field++; + hook(); + return proceed(); + } + + protected final int getField() { + return this.field; + } + + protected abstract void hook(); +} \ No newline at end of file