--- /dev/null
+public class A {
+ S s = new S();
+ public void method() {
+ System.out.println("A.method() running");
+ s.m1();
+ }
+}
--- /dev/null
+public class B {
+ T t = new T();
+ public void method() {
+ System.out.println("B.method() running");
+ t.m2();
+ }
+}
--- /dev/null
+import java.lang.reflect.Method;
+
+public class Main {
+
+ public static void main(String []argv) {
+ try {
+ System.out.println("into:main");
+ Class clazzA = Class.forName("A");
+ Method clazzAMethod = clazzA.getMethod("method",null);
+ clazzAMethod.invoke(clazzA.newInstance(),null);
+
+ Class clazzB= Class.forName("B");
+ Method clazzBMethod = clazzB.getMethod("method",null);
+ clazzBMethod.invoke(clazzB.newInstance(),null);
+ System.out.println("leave:main");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+}
--- /dev/null
+public class T {
+
+ public void m1() {System.out.println("T.m1() running");}
+ public void m2() {System.out.println("T.m2() running");}
+
+}
--- /dev/null
+import java.io.Serializable;
+
+public aspect X {
+ declare parents: T implements Serializable;
+
+ before(): call(* Serializable+.m*(..)) {
+ System.out.println("advice running");
+ }
+}
--- /dev/null
+<aspectj>
+<weaver options="-showWeaveInfo -verbose"/>
+<aspects>
+<aspect name="X"/>
+</aspects>
+</aspectj>
+
--- /dev/null
+public class A {
+ T t = new T();
+ public void method() {
+ System.out.println("A.method() running");
+ t.m1();
+ }
+}
--- /dev/null
+import java.lang.reflect.Method;
+
+public class Main {
+
+ public static void main(String []argv) {
+ try {
+ System.out.println("into:main");
+ Class clazzA = Class.forName("A");
+ Method clazzAMethod = clazzA.getMethod("method",null);
+ clazzAMethod.invoke(clazzA.newInstance(),null);
+ System.out.println("leave:main");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+}
--- /dev/null
+public class T {
+ public void m1() {System.out.println("T.m1() running");}
+}
--- /dev/null
+import java.io.Serializable;
+
+public aspect X {
+ declare parents: T implements Serializable;
+
+ before(): call(* Serializable+.m*(..)) {
+ System.out.println("advice running");
+ }
+}
--- /dev/null
+<aspectj>
+<weaver options="-showWeaveInfo -verbose"/>
+<aspects>
+<aspect name="X"/>
+</aspects>
+</aspectj>
+
--- /dev/null
+Basic case, where type T needs munging with a declare parents before the join point in A.method() are matched.
\ No newline at end of file
--- /dev/null
+public class A {
+ T t = new T();
+ public void method() {
+ System.out.println("A.method() running");
+ t.m1();
+ }
+}
--- /dev/null
+import java.lang.reflect.Method;
+
+public class Main {
+
+ public static void main(String []argv) {
+ try {
+ System.out.println("into:main");
+ Class clazzA = Class.forName("A");
+ Method clazzAMethod = clazzA.getMethod("method",null);
+ clazzAMethod.invoke(clazzA.newInstance(),null);
+ System.out.println("leave:main");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+}
--- /dev/null
+import java.lang.annotation.*;
+
+public @interface MarkerAnnotation {}
\ No newline at end of file
--- /dev/null
+public class T {
+ public void m1() {System.out.println("T.m1() running");}
+}
--- /dev/null
+import java.io.Serializable;
+
+public aspect X {
+ declare @type: T: @MarkerAnnotation;
+
+ before(): call(* (@MarkerAnnotation *).m*(..)) {
+ System.out.println("advice running");
+ }
+}
--- /dev/null
+<aspectj>
+<weaver options="-showWeaveInfo -verbose"/>
+<aspects>
+<aspect name="X"/>
+</aspects>
+</aspectj>
+
--- /dev/null
+Now type T needs munging with a declare annotation
\ No newline at end of file
--- /dev/null
+public class A {
+ S s = new S();
+ public void method() {
+ System.out.println("A.method() running");
+ s.m1();
+ }
+}
--- /dev/null
+import java.lang.reflect.Method;
+
+public class Main {
+
+ public static void main(String []argv) {
+ try {
+ System.out.println("into:main");
+ Class clazzA = Class.forName("A");
+ Method clazzAMethod = clazzA.getMethod("method",null);
+ clazzAMethod.invoke(clazzA.newInstance(),null);
+ System.out.println("leave:main");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+}
--- /dev/null
+public class S extends T {
+}
--- /dev/null
+public class T {
+ public void m1() {System.out.println("T.m1() running");}
+}
--- /dev/null
+import java.io.Serializable;
+
+public aspect X {
+ declare parents: T implements Serializable;
+
+ before(): call(* Serializable+.m*(..)) {
+ System.out.println("advice running");
+ }
+}
--- /dev/null
+<aspectj>
+<weaver options="-showWeaveInfo -verbose"/>
+<aspects>
+<aspect name="X"/>
+</aspects>
+</aspectj>
+
--- /dev/null
+declare parents, but this time there is an extra layer in the hierarchy, A calls S but S extends T and T is decp targeted
\ No newline at end of file
--- /dev/null
+<aspectj>
+ <weaver options="-showWeaveInfo"/>
+ <aspects>
+ <aspect name="child.Advisor"/>
+ </aspects>
+</aspectj>
+
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ron Bodkin
+ */
+package child;
+
+import util.A;
+import util.T;
+
+aspect Advisor {
+ declare parents: A* implements T;
+
+ before() : call(* T+.*(..)) {
+ System.out.println("T call");
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ron Bodkin
+ */
+package child;
+
+import util.A;
+
+public class Executor implements Runnable {
+ public void run() {
+ new A().foo();
+ }
+}
--- /dev/null
+<!-- empty aop.xml file. Used to turn on load-time weaving with no aspects defined at top-level -->
+<aspectj/>
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ron Bodkin
+ */
+package top;
+
+public class SimpleMain {
+ public static void main(String args[]) throws Exception {
+ new child.Executor().run();
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ron Bodkin
+ */
+package util;
+
+public class A {
+ public void foo() {}
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ron Bodkin
+ */
+package util;
+
+public interface T {}