KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > transform > inlining > EmittedJoinPoint


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.aspectwerkz.transform.inlining;
5
6 import com.tc.asm.Label;
7
8 import com.tc.aspectwerkz.joinpoint.management.JoinPointType;
9 import com.tc.aspectwerkz.transform.InstrumentationContext;
10
11 /**
12  * A structure that keeps required information needed to regenerate a JIT joinpoint. The weaver emits this
13  * information so that we can add initalization code to the weaved class. Note that EmittedJP are really Emitted -
14  * and can be a subset of actual JP (f.e. call, where information is lost in between each weave phase).
15  * <p/>
16  * FIXME equals and hashcode are wrong if 2 JP in same withincode - should depend on line number f.e. but that won't
17  * even be enough. Muts have a static variable and trust that creation of EmittedJP is ok.
18  * Check where those are used in a map for hashcode / equals to be used.
19  *
20  * @author <a HREF="mailto:alex@gnilux.com">Alexandre Vasseur </a>
21  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
22  */

23 public final class EmittedJoinPoint {
24
25   public final static Label NO_LINE_NUMBER = new Label();
26
27   private final int joinPointType;
28   private final String JavaDoc callerClassName;
29   private final String JavaDoc callerMethodName;
30   private final String JavaDoc callerMethodDesc;
31   private final int callerMethodModifiers;
32   private final String JavaDoc calleeClassName;
33   private final String JavaDoc calleeMemberName;
34   private final String JavaDoc calleeMemberDesc;
35   private final int calleeMemberModifiers;
36   private final int joinPointHash;
37   private final String JavaDoc joinPointClassName;
38   private final Label lineNumberLabel;
39
40   /**
41    * Line number for call / getDefault / set / handler joinpoint
42    * The lineNumber is 0 unless available and resolveLineNumber(Context) has been called.
43    */

44   private int lineNumber = 0;
45
46   /**
47    * Creates a new instance.
48    *
49    * @param joinPointType
50    * @param callerClassName
51    * @param callerMethodName
52    * @param callerMethodDesc
53    * @param callerMethodModifiers
54    * @param calleeClassName
55    * @param calleeMemberName
56    * @param calleeMemberDesc
57    * @param calleeMemberModifiers
58    * @param joinPointHash
59    * @param joinPointClassName
60    * @param lineNumberLabel
61    */

62   public EmittedJoinPoint(final int joinPointType,
63                           final String JavaDoc callerClassName,
64                           final String JavaDoc callerMethodName,
65                           final String JavaDoc callerMethodDesc,
66                           final int callerMethodModifiers,
67                           final String JavaDoc calleeClassName,
68                           final String JavaDoc calleeMemberName,
69                           final String JavaDoc calleeMemberDesc,
70                           final int calleeMemberModifiers,
71                           final int joinPointHash,
72                           final String JavaDoc joinPointClassName,
73                           final Label lineNumberLabel) {
74     this.joinPointType = joinPointType;
75     this.callerClassName = callerClassName;
76     this.callerMethodName = callerMethodName;
77     this.callerMethodDesc = callerMethodDesc;
78     this.callerMethodModifiers = callerMethodModifiers;
79     this.calleeClassName = calleeClassName;
80     this.calleeMemberName = calleeMemberName;
81     this.calleeMemberDesc = calleeMemberDesc;
82     this.calleeMemberModifiers = calleeMemberModifiers;
83     this.joinPointHash = joinPointHash;
84     this.joinPointClassName = joinPointClassName;
85     this.lineNumberLabel = lineNumberLabel;
86   }
87
88   /**
89    * Creates a new instance.
90    *
91    * @param joinPointType
92    * @param callerClassName
93    * @param callerMethodName
94    * @param callerMethodDesc
95    * @param callerMethodModifiers
96    * @param calleeClassName
97    * @param calleeMemberName
98    * @param calleeMemberDesc
99    * @param calleeMemberModifiers
100    * @param joinPointHash
101    * @param joinPointClassName
102    */

103   public EmittedJoinPoint(final int joinPointType,
104                           final String JavaDoc callerClassName,
105                           final String JavaDoc callerMethodName,
106                           final String JavaDoc callerMethodDesc,
107                           final int callerMethodModifiers,
108                           final String JavaDoc calleeClassName,
109                           final String JavaDoc calleeMemberName,
110                           final String JavaDoc calleeMemberDesc,
111                           final int calleeMemberModifiers,
112                           final int joinPointHash,
113                           final String JavaDoc joinPointClassName) {
114     this(joinPointType, callerClassName, callerMethodName, callerMethodDesc, callerMethodModifiers,
115             calleeClassName, calleeMemberName, calleeMemberDesc, calleeMemberModifiers,
116             joinPointHash, joinPointClassName, NO_LINE_NUMBER
117     );
118   }
119
120   public int getJoinPointType() {
121     return joinPointType;
122   }
123
124   public String JavaDoc getCallerClassName() {
125     return callerClassName;
126   }
127
128   public String JavaDoc getCallerMethodName() {
129     return callerMethodName;
130   }
131
132   public String JavaDoc getCallerMethodDesc() {
133     return callerMethodDesc;
134   }
135
136   public int getCallerMethodModifiers() {
137     return callerMethodModifiers;
138   }
139
140   public String JavaDoc getCalleeClassName() {
141     return calleeClassName;
142   }
143
144   public String JavaDoc getCalleeMemberName() {
145     return calleeMemberName;
146   }
147
148   public String JavaDoc getCalleeMemberDesc() {
149     return calleeMemberDesc;
150   }
151
152   public int getCalleeMemberModifiers() {
153     return calleeMemberModifiers;
154   }
155
156   public int getJoinPointHash() {
157     return joinPointHash;
158   }
159
160   public String JavaDoc getJoinPointClassName() {
161     return joinPointClassName;
162   }
163
164   public int getLineNumber() {
165     return lineNumber;
166   }
167
168   public void resolveLineNumber(InstrumentationContext context) {
169     lineNumber = context.resolveLineNumberInfo(lineNumberLabel);
170   }
171
172   public boolean equals(Object JavaDoc o) {
173     if (this == o) {
174       return true;
175     }
176     if (!(o instanceof EmittedJoinPoint)) {
177       return false;
178     }
179
180     final EmittedJoinPoint emittedJoinPoint = (EmittedJoinPoint) o;
181
182     if (calleeMemberModifiers != emittedJoinPoint.calleeMemberModifiers) {
183       return false;
184     }
185     if (callerMethodModifiers != emittedJoinPoint.callerMethodModifiers) {
186       return false;
187     }
188     if (joinPointHash != emittedJoinPoint.joinPointHash) {
189       return false;
190     }
191     if (joinPointType != emittedJoinPoint.joinPointType) {
192       return false;
193     }
194     if (!calleeClassName.equals(emittedJoinPoint.calleeClassName)) {
195       return false;
196     }
197     if (!calleeMemberDesc.equals(emittedJoinPoint.calleeMemberDesc)) {
198       return false;
199     }
200     if (!calleeMemberName.equals(emittedJoinPoint.calleeMemberName)) {
201       return false;
202     }
203     if (!callerClassName.equals(emittedJoinPoint.callerClassName)) {
204       return false;
205     }
206     if (!callerMethodDesc.equals(emittedJoinPoint.callerMethodDesc)) {
207       return false;
208     }
209     if (!callerMethodName.equals(emittedJoinPoint.callerMethodName)) {
210       return false;
211     }
212     if (!joinPointClassName.equals(emittedJoinPoint.joinPointClassName)) {
213       return false;
214     }
215
216     return true;
217   }
218
219   public int hashCode() {
220     int result;
221     result = joinPointType;
222     result = 29 * result + callerClassName.hashCode();
223     result = 29 * result + callerMethodName.hashCode();
224     result = 29 * result + callerMethodDesc.hashCode();
225     result = 29 * result + callerMethodModifiers;
226     result = 29 * result + calleeClassName.hashCode();
227     result = 29 * result + calleeMemberName.hashCode();
228     result = 29 * result + calleeMemberDesc.hashCode();
229     result = 29 * result + calleeMemberModifiers;
230     result = 29 * result + joinPointHash;
231     result = 29 * result + joinPointClassName.hashCode();
232     return result;
233   }
234
235   public String JavaDoc toString() {
236     StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
237     sb.append(JoinPointType.fromInt(getJoinPointType()).toString());
238     sb.append(" , caller ");
239     sb.append(getCallerClassName());
240     sb.append('.').append(getCallerMethodName());
241     sb.append(getCallerMethodDesc());
242     sb.append(" , callee ");
243     sb.append(getCalleeClassName());
244     sb.append('.').append(getCalleeMemberName());
245     sb.append(' ').append(getCalleeMemberDesc());
246     sb.append(" , line ").append(getLineNumber());
247     return sb.toString();
248   }
249 }
Popular Tags