aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/packagevisibility/PackagesAndAdviceCf.java
blob: 1abfea48eb73d7b75c0b04f3b153b8153a11a6cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package packagevisibility;
import org.aspectj.testing.Tester;

import packagevisibility.testPackage.*;

public class PackagesAndAdviceCf
{
    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)) {  // Cf type not visible
        String result = s + message;
	result += A1.message;
	return result + proceed(s);
    }

}

class A1 {
    static String message = "-advised1";
}