From 144143c2970a1e874d74cdbd0f8c622d4282a3c3 Mon Sep 17 00:00:00 2001 From: wisberg Date: Mon, 16 Dec 2002 18:51:06 +0000 Subject: initial version --- tests/new/packagevisibility/PackagesAndAdvice.java | 39 ++++++++++++++++++++++ .../new/packagevisibility/testPackage/Class1.java | 11 ++++++ .../new/packagevisibility/testPackage/Class2.java | 13 ++++++++ 3 files changed, 63 insertions(+) create mode 100644 tests/new/packagevisibility/PackagesAndAdvice.java create mode 100644 tests/new/packagevisibility/testPackage/Class1.java create mode 100644 tests/new/packagevisibility/testPackage/Class2.java (limited to 'tests/new/packagevisibility') diff --git a/tests/new/packagevisibility/PackagesAndAdvice.java b/tests/new/packagevisibility/PackagesAndAdvice.java new file mode 100644 index 000000000..ca17f0da7 --- /dev/null +++ b/tests/new/packagevisibility/PackagesAndAdvice.java @@ -0,0 +1,39 @@ +package packagevisibility; +import org.aspectj.testing.Tester; + +import packagevisibility.testPackage.*; + +public class PackagesAndAdvice +{ + public static void main(String[] args) { test(); } + + public static void test() { + packagevisibility.testPackage.Class1 c1 = + new packagevisibility.testPackage.Class1(); + Tester.checkEqual(c1.doIt("-1"), + "-1-advised-advised1-1-class1", + "publically visible"); + Tester.checkEqual(c1.doItToClass2("-2"), + "-2-advised-advised1-2-class2", + "package visible"); + } + +} + +aspect A { + static String message = "-advised"; + + String around(String s): + call(String doIt(String)) && args(s) && + (target(packagevisibility.testPackage.Class1) || + target(packagevisibility.testPackage.Class2)) { + String result = s + message; + result += A1.message; + return result + proceed(s); + } + +} + +class A1 { + static String message = "-advised1"; +} diff --git a/tests/new/packagevisibility/testPackage/Class1.java b/tests/new/packagevisibility/testPackage/Class1.java new file mode 100644 index 000000000..d53733d34 --- /dev/null +++ b/tests/new/packagevisibility/testPackage/Class1.java @@ -0,0 +1,11 @@ +package packagevisibility.testPackage; + +public class Class1 { + public String doIt(String s) { + return s + "-class1"; + } + + public String doItToClass2(String s) { + return (new packagevisibility.testPackage.Class2()).doIt(s); + } +} diff --git a/tests/new/packagevisibility/testPackage/Class2.java b/tests/new/packagevisibility/testPackage/Class2.java new file mode 100644 index 000000000..d32e84683 --- /dev/null +++ b/tests/new/packagevisibility/testPackage/Class2.java @@ -0,0 +1,13 @@ +package packagevisibility.testPackage; + +class Class2 { + String doIt(String s) { + new Runnable() { + public void run() { + System.out.println("running"); + } + }.run(); + + return s + "-class2"; + } +} -- cgit v1.2.3