--- /dev/null
+public class Eight {
+ public static void main(String[] argv) {
+ Eight a = new Eight();
+ a.m();
+ }
+
+ public void m() {
+ System.out.println("Method m() running");
+ }
+}
+
+abstract aspect Y {
+ abstract pointcut p();
+ before(): execution(* m(..)) && p() {
+ System.out.println("In advice()");
+ }
+}
+
+aspect X extends Y {
+ pointcut p(): if(thisAspectInstance.doit());
+
+ boolean doit() {
+ System.out.println("in doit(): class="+this.getClass().getName());
+ return true;
+ }
+
+}
--- /dev/null
+public class Eleven {
+ public static void main(String[] argv) {
+ Eleven a = new Eleven();
+ a.m();
+ }
+
+ public void m() {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X perthis(this(Eleven)) {
+
+ boolean doit() {
+ System.out.println("In instance check method doit()");
+ return true;
+ }
+
+ before():execution(* m(..)) && if(thisAspectInstance.doit()){
+ System.out.println("In advice()");
+ }
+}
--- /dev/null
+public class Fifteen {
+ public static void main(String[] argv) {
+ Fifteen a = new Fifteen();
+ a.m();
+ }
+
+ public void m() {
+ System.out.println("Method m() running");
+ }
+}
+
+abstract aspect Y {
+ abstract pointcut p();
+ before(): if(thisAspectInstance.doit()) && p() {
+ System.out.println("In advice()");
+ }
+ boolean doit() {
+ System.out.println("in doit(): class="+this.getClass().getName());
+ return true;
+ }
+}
+
+aspect X extends Y {
+ pointcut p(): execution(* m(..));
+}
--- /dev/null
+public class Five {
+ public static void main(String[] argv) {
+ Five a = new Five();
+ a.m("abc");
+ }
+
+ public void m(String s) {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X {
+ boolean doit() {
+ System.out.println("In instance check method doit()");
+ return true;
+ }
+
+ before():execution(* m(..)) && if(thisAspectInstance.doit()){
+ System.out.println("In advice() arg0="+thisJoinPoint.getArgs()[0]);
+ }
+}
--- /dev/null
+public class Four {
+ public static void main(String[] argv) {
+ Four a = new Four();
+ a.m();
+ }
+
+ public void m() {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X {
+ boolean doit() {
+ System.out.println("In instance check method doit()");
+ return true;
+ }
+
+ before():execution(* m(..)) && if(thisAspectInstance.doit()){
+ System.out.println("In advice() "+thisJoinPointStaticPart);
+ }
+}
--- /dev/null
+public class Fourteen {
+ public static void main(String[] argv) {
+ Fourteen a = new Fourteen();
+ a.m("abc");
+ }
+
+ public void m(String s) {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X {
+
+ static boolean printit(Object o) {
+ System.out.println("instance is "+o.getClass().getName());
+return true;
+ }
+
+ before(String s):args(s) && execution(* m(..)) && if(printit(thisAspectInstance)) && if(thisJoinPointStaticPart.toString().indexOf("Fourteen")!=-1) {
+ System.out.println("In advice() arg="+s+" tjpsp="+thisJoinPointStaticPart);
+ }
+}
--- /dev/null
+public class Nine {
+ public static void main(String[] argv) {
+ Nine a = new Nine();
+ a.m();
+ }
+
+ public void m() {
+ System.out.println("Method m() running");
+ }
+}
+
+abstract aspect Y {
+ abstract pointcut p();
+ before(): execution(* m(..)) && p() {
+ System.out.println("In advice()");
+ }
+ boolean doit() {
+ System.out.println("in doit(): class="+this.getClass().getName());
+ return true;
+ }
+}
+
+aspect X extends Y {
+ pointcut p(): if(thisAspectInstance.doit());
+}
--- /dev/null
+public class One {
+ public static void main(String[] argv) {
+ One a = new One();
+ a.m();
+ }
+
+ public void m() {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X {
+ boolean doit() {
+ System.out.println("In instance check method doit()");
+ return true;
+ }
+
+ before():execution(* m(..)) && if(thisAspectInstance.doit()){
+ System.out.println("In advice()");
+ }
+}
--- /dev/null
+public class Seven {
+ public static void main(String[] argv) {
+ Seven a = new Seven();
+ a.m();
+ }
+
+ public void m() {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X {
+ boolean doit() {
+ System.out.println("In instance check method doit()");
+ return true;
+ }
+
+ before(): call(* m(..)) && if(thisAspectInstance.doit()){
+ System.out.println("In advice() "+thisJoinPoint+" "+thisEnclosingJoinPointStaticPart);
+ }
+}
--- /dev/null
+public class Six {
+ public static void main(String[] argv) {
+ Six a = new Six();
+ a.m();
+ }
+
+ public void m() {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X {
+ boolean doit() {
+ System.out.println("In instance check method doit()");
+ return true;
+ }
+
+ before():call(* m(..)) && if(thisAspectInstance.doit()){
+ System.out.println("In advice() "+thisEnclosingJoinPointStaticPart);
+ }
+}
--- /dev/null
+package com.foo.bar;
+
+public class Ten {
+ public static void main(String[] argv) {
+ Ten a = new Ten();
+ a.m();
+ }
+
+ public void m() {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X {
+ boolean doit() {
+ System.out.println("In instance check method doit() class="+this.getClass().getName());
+ return true;
+ }
+
+ before():execution(* m(..)) && if(thisAspectInstance.doit()){
+ System.out.println("In advice()");
+ }
+}
--- /dev/null
+public class Thirteen {
+ public static void main(String[] argv) {
+ Thirteen a = new Thirteen();
+ a.m("abc");
+ }
+
+ public void m(String s) {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X {
+
+ static boolean printit(Object o) {
+ System.out.println("instance is "+o.getClass().getName());
+return true;
+ }
+
+ before(String s):args(s) && execution(* m(..)) && if(printit(thisAspectInstance)){
+ System.out.println("In advice() arg="+s+" tjpsp="+thisJoinPointStaticPart);
+ }
+}
--- /dev/null
+public class Three {
+ public static void main(String[] argv) {
+ Three a = new Three();
+ a.m();
+ a.m();
+ a.m();
+ a.m();
+ }
+
+ public void m() {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X {
+ int count = 0;
+
+ boolean doit() {
+ count++;
+ System.out.println("In instance check method, count="+count+" so doit returns "+((count%2)==0));
+ return (count%2)==0;
+ }
+
+ after():call(* m(..)) && if(thisAspectInstance.doit()){
+ System.out.println("In advice()");
+ }
+}
--- /dev/null
+public class Twelve {
+ public static void main(String[] argv) {
+ Twelve a = new Twelve();
+ a.m("abc");
+ }
+
+ public void m(String s) {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X {
+
+ boolean doit() {
+ System.out.println("In instance check method doit()");
+ return true;
+ }
+
+ before(String s):execution(* m(..)) && if(thisAspectInstance.doit()) && args(s) {
+ System.out.println("In advice() arg="+s+" tjpsp="+thisJoinPointStaticPart);
+ }
+}
--- /dev/null
+public class Two {
+ public static void main(String[] argv) {
+ Two a = new Two();
+ a.m();
+ a.m();
+ a.m();
+ a.m();
+ }
+
+ public void m() {
+ System.out.println("Method m() running");
+ }
+}
+
+aspect X {
+ int count = 0;
+
+ boolean doit() {
+ count++;
+ System.out.println("In instance check method, count="+count+" so doit returns "+((count%2)==0));
+ return (count%2)==0;
+ }
+
+ before():call(* m(..)) && if(thisAspectInstance.doit()){
+ System.out.println("In advice()");
+ }
+}