aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/IntroducedModifiers.java
blob: d8f9c2a4386d6989785934843c68fcb8d484e061 (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
40
41
42
43
44
45
46
47
48
49
50
import org.aspectj.testing.Tester;

import java.lang.reflect.*;

public class IntroducedModifiers {
    public static void main(String[] args) throws Exception {
        Field f = C.class.getField("cf");
        Tester.check(Modifier.isVolatile(f.getModifiers()), "volatile");
        Tester.check(Modifier.isTransient(f.getModifiers()), "transient");

        Method m = C.class.getMethod("m", new Class[0]);
        Tester.check(Modifier.isSynchronized(m.getModifiers()), "synchronized");
        Tester.check(Modifier.isStrict(m.getModifiers()), "strictfp");

        f = C.class.getField("scf");
        Tester.check(Modifier.isVolatile(f.getModifiers()), "volatile");
        Tester.check(Modifier.isTransient(f.getModifiers()), "transient");
        Tester.check(Modifier.isStatic(f.getModifiers()), "static");

        //XXX this name depends on implementation details for field intro on interfaces
        try {
            f = C.class.getField("iField__I");
        } catch (NoSuchFieldException e) {
            f = C.class.getField("aspectj$iField__I");
        }
        Tester.check(Modifier.isVolatile(f.getModifiers()), "volatile");
        Tester.check(Modifier.isTransient(f.getModifiers()), "transient");

        m = C.class.getMethod("im", new Class[0]);
        Tester.check(Modifier.isSynchronized(m.getModifiers()), "synchronized");
        Tester.check(Modifier.isStrict(m.getModifiers()), "strictfp");
    }
}


interface I {
}

class C implements I {
}

aspect A {
    public transient volatile int C.cf = 0;
    public synchronized strictfp int C.m() { return 0; }

    public transient volatile static int C.scf = 0;

    public synchronized strictfp int I.im() { return 0; }
    public transient volatile int I.iField = 1;
}