summaryrefslogtreecommitdiffstats
path: root/tests/new/introTypeMissing/AspectInIntroducedMethod.java
blob: 17de800e91fc19f99166ed95adbb9336e8999cd9 (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
import org.aspectj.testing.Tester;

public class AspectInIntroducedMethod {
    public static void main(String[] args) {
        String result = new TargetClass().addMethod();
        Tester.check("inner".equals(result),
                     "\"inner\".equals(\"" + result + "\")");
    }
} 
aspect A {
    class inner {
      public String name() { return "inner"; } 
    }
    /** shows A usable in non-introductions */
    public String getName() {
        new inner();
        A a = this;
        return a.new inner().name();
    }

    // NPE at NewInstanceExpr.java:287 
    /** @testcase qualified new expression using aspect type in method introduction body */
    public String TargetClass.addMethod() {
        String result = null;
        A a = A.aspectOf();
        result = a.getName();
        result = a.new inner().name(); // bug: remove this to avoid NPE
        return result;
    }
}
class TargetClass {}