~ubuntu-branches/ubuntu/natty/aspectj/natty

« back to all changes in this revision

Viewing changes to org.aspectj/modules/tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects2.aj

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2009-10-04 16:37:23 UTC
  • mfrom: (1.1.3 upstream) (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091004163723-ck4y7j7fhjxskkie
Tags: 1.6.6+dfsg-1
* New upstream release.
  - Update 02_use_gjdoc.diff patch
* Update my email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 * Copyright (c) 2005 Contributors.
3
 
 * All rights reserved. 
4
 
 * This program and the accompanying materials are made available 
5
 
 * under the terms of the Eclipse Public License v1.0 
6
 
 * which accompanies this distribution and is available at 
7
 
 * http://eclipse.org/legal/epl-v10.html 
8
 
 * 
9
 
 * Contributors:
10
 
 *   Alexandre Vasseur         initial implementation
11
 
 *******************************************************************************/
12
 
package ataspectj;
13
 
 
14
 
import org.aspectj.lang.annotation.Aspect;
15
 
import org.aspectj.lang.annotation.Around;
16
 
import org.aspectj.lang.annotation.Before;
17
 
import org.aspectj.lang.annotation.SuppressAjWarnings;
18
 
import org.aspectj.lang.ProceedingJoinPoint;
19
 
 
20
 
/**
21
 
 * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
22
 
 */
23
 
public class AroundInlineMungerTestAspects2 {
24
 
 
25
 
    public static abstract aspect OpenBase {
26
 
        protected void superMethod() {}
27
 
    }
28
 
 
29
 
    public static abstract aspect OpenSubBase extends OpenBase {}
30
 
 
31
 
    // aspect will be prepared for inlining
32
 
    public static aspect Open extends OpenSubBase {
33
 
 
34
 
        public static int aroundCount = 0;
35
 
        public static int beforeCount = 0;
36
 
 
37
 
        private int i;
38
 
        private static int I;
39
 
 
40
 
        @SuppressAjWarnings
41
 
        Object around() : execution(* ataspectj.AroundInlineMungerTest2.target()) {
42
 
            aroundCount++;
43
 
            priv(1, 2L, 3);
44
 
            super.superMethod();
45
 
            new Inner().priv();//fails to be wrapped so this advice will not be inlined but previous call were still prepared
46
 
            return proceed();
47
 
        }
48
 
 
49
 
        // this advice to test around advice body call/get/set advising
50
 
        @SuppressAjWarnings
51
 
        before() : (call(* ataspectj.AroundInlineMungerTestAspects2.Open.priv(..))
52
 
                  || get(int ataspectj.AroundInlineMungerTestAspects2.Open.i)
53
 
                  || set(int ataspectj.AroundInlineMungerTestAspects2.Open.i)
54
 
                  || get(int ataspectj.AroundInlineMungerTestAspects2.Open.I)
55
 
                  || set(int ataspectj.AroundInlineMungerTestAspects2.Open.I)
56
 
                 )&& this(ataspectj.AroundInlineMungerTestAspects2.Open) {
57
 
            beforeCount++;
58
 
        }
59
 
 
60
 
        @SuppressAjWarnings
61
 
        Object around() : execution(* ataspectj.AroundInlineMungerTest2.target()) {
62
 
            aroundCount++;
63
 
            super.superMethod();
64
 
            new Inner().priv();//fails to be wrapped so next calls won't be prepared but previous was
65
 
            priv(1, 2L, 3);
66
 
            return proceed();
67
 
        }
68
 
 
69
 
        @SuppressAjWarnings
70
 
        Object around() : execution(* ataspectj.AroundInlineMungerTest2.target()) {
71
 
            aroundCount++;
72
 
            // all those field access will be wrapped
73
 
            int li = i;
74
 
            i = li;
75
 
            int lI = I;
76
 
            I = lI;
77
 
            return proceed();
78
 
        }
79
 
 
80
 
        // -- some private member for which access will be wrapped so that around advice can be inlined
81
 
 
82
 
        private void priv(int i, long j, int k) {
83
 
            long l = i + j + k;
84
 
        }
85
 
 
86
 
        private static class Inner {
87
 
            private Inner() {}
88
 
            private void priv() {};
89
 
        }
90
 
    }
91
 
 
92
 
}