aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs160/pr223605/GenericConfigurableBugTest.java
blob: b62f3f995bf6f22fa4812f6e8cb9ce4309948bde (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
51
package test;

import junit.framework.TestCase;

/**
 * Test case to illustrate problem with SPR-4587.
 * 
 * @author Ramnivas Laddad
 *
 */
public class GenericConfigurableBugTest {
    public static void main(String[] argv) {
        RegularClass regular = new RegularClass();
        GenericParameterClass generic = new GenericParameterClass();
        
        if (!(regular instanceof ConfigurableObject)) 
            throw new RuntimeException("regular not instanceof ConfigurableObject");

        if (!(generic instanceof ConfigurableObject)) 
            throw new RuntimeException("generic not instanceof ConfigurableObject");
        
        if (TestAspect.aspectOf().count!=4) 
            throw new RuntimeException("Count should be 4 but is "+TestAspect.aspectOf().count);
    }
}

aspect TestAspect {
    int count = 0;
    
    after() : initialization(ConfigurableObject+.new(..)) {
        System.out.println(thisJoinPoint);
        count++;
    }
    
    declare parents: @Configurable * implements ConfigurableObject;
}

interface ConfigurableObject {
}

@interface Configurable {
}

@Configurable
class RegularClass {
}

@Configurable
class GenericParameterClass<T> {
}