Browse Source

testcode for call and decp LTW 133770

tags/post_pr_153572
aclement 17 years ago
parent
commit
0adc866c0f

+ 7
- 0
tests/ltw/callMunging/A.java View File

@@ -0,0 +1,7 @@
public class A {
S s = new S();
public void method() {
System.out.println("A.method() running");
s.m1();
}
}

+ 7
- 0
tests/ltw/callMunging/B.java View File

@@ -0,0 +1,7 @@
public class B {
T t = new T();
public void method() {
System.out.println("B.method() running");
t.m2();
}
}

+ 21
- 0
tests/ltw/callMunging/Main.java View File

@@ -0,0 +1,21 @@
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();
}
}
}

+ 6
- 0
tests/ltw/callMunging/T.java View File

@@ -0,0 +1,6 @@
public class T {

public void m1() {System.out.println("T.m1() running");}
public void m2() {System.out.println("T.m2() running");}

}

+ 9
- 0
tests/ltw/callMunging/X.java View File

@@ -0,0 +1,9 @@
import java.io.Serializable;

public aspect X {
declare parents: T implements Serializable;

before(): call(* Serializable+.m*(..)) {
System.out.println("advice running");
}
}

+ 7
- 0
tests/ltw/callMunging/aop.xml View File

@@ -0,0 +1,7 @@
<aspectj>
<weaver options="-showWeaveInfo -verbose"/>
<aspects>
<aspect name="X"/>
</aspects>
</aspectj>


+ 7
- 0
tests/ltw/callMunging/case1/A.java View File

@@ -0,0 +1,7 @@
public class A {
T t = new T();
public void method() {
System.out.println("A.method() running");
t.m1();
}
}

+ 17
- 0
tests/ltw/callMunging/case1/Main.java View File

@@ -0,0 +1,17 @@
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();
}
}
}

+ 3
- 0
tests/ltw/callMunging/case1/T.java View File

@@ -0,0 +1,3 @@
public class T {
public void m1() {System.out.println("T.m1() running");}
}

+ 9
- 0
tests/ltw/callMunging/case1/X.java View File

@@ -0,0 +1,9 @@
import java.io.Serializable;

public aspect X {
declare parents: T implements Serializable;

before(): call(* Serializable+.m*(..)) {
System.out.println("advice running");
}
}

+ 7
- 0
tests/ltw/callMunging/case1/aop.xml View File

@@ -0,0 +1,7 @@
<aspectj>
<weaver options="-showWeaveInfo -verbose"/>
<aspects>
<aspect name="X"/>
</aspects>
</aspectj>


+ 1
- 0
tests/ltw/callMunging/case1/readme.txt View File

@@ -0,0 +1 @@
Basic case, where type T needs munging with a declare parents before the join point in A.method() are matched.

+ 7
- 0
tests/ltw/callMunging/case2/A.java View File

@@ -0,0 +1,7 @@
public class A {
T t = new T();
public void method() {
System.out.println("A.method() running");
t.m1();
}
}

+ 17
- 0
tests/ltw/callMunging/case2/Main.java View File

@@ -0,0 +1,17 @@
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();
}
}
}

+ 3
- 0
tests/ltw/callMunging/case2/MarkerAnnotation.java View File

@@ -0,0 +1,3 @@
import java.lang.annotation.*;

public @interface MarkerAnnotation {}

+ 3
- 0
tests/ltw/callMunging/case2/T.java View File

@@ -0,0 +1,3 @@
public class T {
public void m1() {System.out.println("T.m1() running");}
}

+ 9
- 0
tests/ltw/callMunging/case2/X.java View File

@@ -0,0 +1,9 @@
import java.io.Serializable;

public aspect X {
declare @type: T: @MarkerAnnotation;

before(): call(* (@MarkerAnnotation *).m*(..)) {
System.out.println("advice running");
}
}

+ 7
- 0
tests/ltw/callMunging/case2/aop.xml View File

@@ -0,0 +1,7 @@
<aspectj>
<weaver options="-showWeaveInfo -verbose"/>
<aspects>
<aspect name="X"/>
</aspects>
</aspectj>


+ 1
- 0
tests/ltw/callMunging/case2/readme.txt View File

@@ -0,0 +1 @@
Now type T needs munging with a declare annotation

+ 7
- 0
tests/ltw/callMunging/case3/A.java View File

@@ -0,0 +1,7 @@
public class A {
S s = new S();
public void method() {
System.out.println("A.method() running");
s.m1();
}
}

+ 17
- 0
tests/ltw/callMunging/case3/Main.java View File

@@ -0,0 +1,17 @@
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();
}
}
}

+ 2
- 0
tests/ltw/callMunging/case3/S.java View File

@@ -0,0 +1,2 @@
public class S extends T {
}

+ 3
- 0
tests/ltw/callMunging/case3/T.java View File

@@ -0,0 +1,3 @@
public class T {
public void m1() {System.out.println("T.m1() running");}
}

+ 9
- 0
tests/ltw/callMunging/case3/X.java View File

@@ -0,0 +1,9 @@
import java.io.Serializable;

public aspect X {
declare parents: T implements Serializable;

before(): call(* Serializable+.m*(..)) {
System.out.println("advice running");
}
}

+ 7
- 0
tests/ltw/callMunging/case3/aop.xml View File

@@ -0,0 +1,7 @@
<aspectj>
<weaver options="-showWeaveInfo -verbose"/>
<aspects>
<aspect name="X"/>
</aspects>
</aspectj>


+ 1
- 0
tests/ltw/callMunging/case3/readme.txt View File

@@ -0,0 +1 @@
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

+ 7
- 0
tests/ltw/hier/aop-single.xml View File

@@ -0,0 +1,7 @@
<aspectj>
<weaver options="-showWeaveInfo"/>
<aspects>
<aspect name="child.Advisor"/>
</aspects>
</aspectj>


+ 23
- 0
tests/ltw/hier/child/Advisor.aj View File

@@ -0,0 +1,23 @@
/*******************************************************************************
* 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");
}
}

+ 20
- 0
tests/ltw/hier/child/Executor.aj View File

@@ -0,0 +1,20 @@
/*******************************************************************************
* 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();
}
}

+ 2
- 0
tests/ltw/hier/null-aop.xml View File

@@ -0,0 +1,2 @@
<!-- empty aop.xml file. Used to turn on load-time weaving with no aspects defined at top-level -->
<aspectj/>

+ 18
- 0
tests/ltw/hier/top/SimpleMain.aj View File

@@ -0,0 +1,18 @@
/*******************************************************************************
* 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();
}
}

+ 16
- 0
tests/ltw/hier/util/A.aj View File

@@ -0,0 +1,16 @@
/*******************************************************************************
* 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() {}
}

+ 14
- 0
tests/ltw/hier/util/T.aj View File

@@ -0,0 +1,14 @@
/*******************************************************************************
* 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 {}

Loading…
Cancel
Save