aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs150/pr104229.aj
blob: d3feb328bc7a9855c40576853a5bfe0b0f5fbc91 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import java.lang.annotation.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;

interface GoalSelectedNotice {
	  public void goalSelected(Object goal);
}

@Retention(RetentionPolicy.RUNTIME) 
@interface DefaultImplementation {}

aspect X {
	/**
	 * Watch for goalSelected(..) method being called when
	 * not within this aspect.
	 */
	pointcut goalSelectedPointcut(GoalSelectedNotice _this, Object goal): 
		call(void GoalSelectedNotice.goalSelected(Object))
	    && target(_this) && args(goal) && !cflow(adviceexecution());	
	
	declare warning : call(void GoalSelectedNotice.goalSelected(Object)) : "bingo";
	
	after(Object caller, Object o) returning : call(void GoalSelectedNotice.goalSelected(Object)) && args(o) && target(caller){
		System.out.println("call match " + caller.getClass());
	}
	
	after(GoalSelectedNotice _this, Object goal) returning:
	goalSelectedPointcut(_this, goal){
	  System.out.println("OK it worked!");
	}
	/**
	 * Empty body, can be overriden by classes implementing
	 * {@link GoalSelectedNotice}.
	 */
    @DefaultImplementation 
	public void GoalSelectedNotice.goalSelected(Object goal){
	}
}

public class pr104229 implements GoalSelectedNotice {
	
	interface CallMe { void doIt(); }
	
	public static void main(String[] args) {
		pr104229 pr = new pr104229();
		pr.callInner();
	}
	
	public void callInner() {
		
		CallMe callMe = new CallMe() {
			public void doIt() {
				pr104229.this.goalSelected("MyGoal");
			}
		};
		
		callMe.doIt();
		
	}
	
	
}

class ListPanel extends JPanel implements GoalSelectedNotice{

	private JComboBox jComboBox = null;
	private JList jList = null;
	/**
	 * This is the default constructor
	 */
	public ListPanel() {
		super();
		initialize();
	}
	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private  void initialize() {
		this.setLayout(new BorderLayout());
		this.setSize(300,200);
		this.add(getJComboBox(), java.awt.BorderLayout.NORTH);
		this.add(getJList(), java.awt.BorderLayout.CENTER);
	}
	/**
	 * This method initializes jComboBox	
	 * 	
	 * @return javax.swing.JComboBox	
	 */    
	private JComboBox getJComboBox() {
		if (jComboBox == null) {
			jComboBox = new JComboBox((ComboBoxModel)null);
		}
		return jComboBox;
	}
	/**
	 * This method initializes jList	
	 * 	
	 * @return javax.swing.JList	
	 */    
	private JList getJList() {
		if (jList == null) { 
			jList = new JList((ListModel)null);
			jList.addListSelectionListener(
					new  ListSelectionListener(){
						public void valueChanged(ListSelectionEvent e){
							if(!e.getValueIsAdjusting()){
								JList list = (JList)e.getSource();
								Object goal = list.getSelectedValue();
								System.out.println(goal);

// If I replace the line below with...
								ListPanel.this.goalSelected(goal); //the join point is not seen!;
// This was working before a switched to source level 5!				
				ListPanel.this.sendGoalSelectedNotice(goal); // this is workaround!

							}
						}
					}
					);
		}
		return jList;
	}

	// this is part of workaround
	protected void sendGoalSelectedNotice(Object goal){
                // join point is found by pointcut here!  This is ok!
		goalSelected(goal);
	}
}