author | vranyj1 |
Wed, 14 Sep 2011 21:29:11 +0000 | |
branch | jk_new_structure |
changeset 1000 | cfa982260238 |
parent 915 | cf0d328465c2 |
child 1073 | e842ab17fe16 |
permissions | -rw-r--r-- |
877 | 1 |
" |
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
3 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
|
4 |
SWING Research Group, Czech Technical University in Prague |
|
5 |
||
6 |
Parts of the code written by Claus Gittinger are under following |
|
7 |
license: |
|
8 |
||
9 |
This software is furnished under a license and may be used |
|
10 |
only in accordance with the terms of that license and with the |
|
11 |
inclusion of the above copyright notice. This software may not |
|
12 |
be provided or otherwise made available to, or used by, any |
|
13 |
other person. No title to or ownership of the software is |
|
14 |
hereby transferred. |
|
15 |
||
16 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed: |
|
17 |
||
18 |
Permission is hereby granted, free of charge, to any person |
|
19 |
obtaining a copy of this software and associated documentation |
|
20 |
files (the 'Software'), to deal in the Software without |
|
21 |
restriction, including without limitation the rights to use, |
|
22 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
23 |
copies of the Software, and to permit persons to whom the |
|
24 |
Software is furnished to do so, subject to the following |
|
25 |
conditions: |
|
26 |
||
27 |
The above copyright notice and this permission notice shall be |
|
28 |
included in all copies or substantial portions of the Software. |
|
29 |
||
30 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
31 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
32 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
33 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
34 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
35 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
36 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
37 |
OTHER DEALINGS IN THE SOFTWARE. |
|
38 |
||
39 |
[1] Code written at SWING Research Group contain a signature |
|
40 |
of one of the above copright owners. |
|
41 |
" |
|
752 | 42 |
"{ Package: 'stx:libjava' }" |
43 |
||
774 | 44 |
Object subclass:#JavaRef2 |
777 | 45 |
instanceVariableNames:'valueCache constantPool' |
752 | 46 |
classVariableNames:'' |
47 |
poolDictionaries:'' |
|
48 |
category:'Languages-Java-Reader-Support-new' |
|
49 |
! |
|
50 |
||
758 | 51 |
!JavaRef2 class methodsFor:'documentation'! |
52 |
||
877 | 53 |
copyright |
54 |
" |
|
55 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
56 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
|
57 |
SWING Research Group, Czech Technical University in Prague |
|
58 |
||
59 |
Parts of the code written by Claus Gittinger are under following |
|
60 |
license: |
|
61 |
||
62 |
This software is furnished under a license and may be used |
|
63 |
only in accordance with the terms of that license and with the |
|
64 |
inclusion of the above copyright notice. This software may not |
|
65 |
be provided or otherwise made available to, or used by, any |
|
66 |
other person. No title to or ownership of the software is |
|
67 |
hereby transferred. |
|
68 |
||
69 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed: |
|
70 |
||
71 |
Permission is hereby granted, free of charge, to any person |
|
72 |
obtaining a copy of this software and associated documentation |
|
73 |
files (the 'Software'), to deal in the Software without |
|
74 |
restriction, including without limitation the rights to use, |
|
75 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
76 |
copies of the Software, and to permit persons to whom the |
|
77 |
Software is furnished to do so, subject to the following |
|
78 |
conditions: |
|
79 |
||
80 |
The above copyright notice and this permission notice shall be |
|
81 |
included in all copies or substantial portions of the Software. |
|
82 |
||
83 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
84 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
85 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
86 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
87 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
88 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
89 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
90 |
OTHER DEALINGS IN THE SOFTWARE. |
|
91 |
||
92 |
[1] Code written at SWING Research Group contain a signature |
|
93 |
of one of the above copright owners. |
|
94 |
||
95 |
" |
|
96 |
! |
|
97 |
||
758 | 98 |
documentation |
99 |
" |
|
100 |
I am parent of all reference types found in runtime constant pool. I define basic api - resolve and invalidate. |
|
101 |
Basic use case is to call resolve on my instance to get resolved thing, or to call invalidate to tell me, |
|
102 |
that world has changed and my cache is no longer valid. |
|
103 |
||
104 |
[author:] |
|
105 |
Marcel Hlopko <hlopkmar@fel.cvut.cz> |
|
106 |
||
107 |
[instance variables:] |
|
108 |
isResolved - flag telling whether instance is resolved |
|
109 |
valueCache - field holding resolved object |
|
110 |
owner - java class owning constant pool |
|
111 |
[class variables:] |
|
112 |
||
113 |
[see also:] |
|
114 |
||
115 |
" |
|
116 |
! ! |
|
752 | 117 |
|
118 |
!JavaRef2 class methodsFor:'instance creation'! |
|
119 |
||
120 |
new |
|
758 | 121 |
"Don't call me directly" |
122 |
||
761 | 123 |
'[JavaRef] Dont instantiate me with new. Call my custom overriden object creation method' |
124 |
infoPrintCR. |
|
125 |
^ self basicNew initialize. |
|
752 | 126 |
|
761 | 127 |
"Modified: / 11-04-2011 / 19:44:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 128 |
! ! |
129 |
||
130 |
!JavaRef2 methodsFor:'accessing'! |
|
131 |
||
774 | 132 |
constantPool |
133 |
^constantPool. |
|
134 |
||
135 |
"Created: / 10-05-2011 / 17:16:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
136 |
! |
|
137 |
||
138 |
constantPool: aJavaConstantPool |
|
139 |
constantPool := aJavaConstantPool. |
|
140 |
||
141 |
"Created: / 10-05-2011 / 17:16:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
142 |
! |
|
143 |
||
752 | 144 |
isResolved |
758 | 145 |
^ valueCache isNil not. |
752 | 146 |
|
147 |
"Created: / 08-04-2011 / 11:36:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
758 | 148 |
"Modified: / 08-04-2011 / 17:39:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
149 |
! |
|
150 |
||
151 |
name |
|
152 |
^ self subclassResponsibility. |
|
153 |
||
154 |
"Created: / 08-04-2011 / 13:53:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
155 |
! |
|
156 |
||
774 | 157 |
owner |
777 | 158 |
^ constantPool owner. |
159 |
||
160 |
"Modified: / 12-05-2011 / 18:31:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
774 | 161 |
! |
162 |
||
777 | 163 |
owner: javaClass |
164 |
constantPool owner: javaClass. |
|
165 |
||
166 |
"Modified: / 12-05-2011 / 18:32:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
774 | 167 |
! |
168 |
||
752 | 169 |
valueCache |
170 |
^ valueCache. |
|
171 |
||
172 |
"Created: / 08-04-2011 / 11:37:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
173 |
! ! |
|
174 |
||
175 |
!JavaRef2 methodsFor:'comparing'! |
|
176 |
||
177 |
= anotherJavaRef |
|
178 |
^ self subclassResponsibility. |
|
179 |
||
180 |
"Created: / 08-04-2011 / 12:15:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
181 |
! |
|
182 |
||
183 |
hash |
|
184 |
||
185 |
^ self subclassResponsibility. |
|
186 |
||
187 |
"Created: / 08-04-2011 / 12:15:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
188 |
! ! |
|
189 |
||
190 |
!JavaRef2 methodsFor:'initialization'! |
|
191 |
||
192 |
initialize |
|
193 |
valueCache := nil. |
|
194 |
super initialize. |
|
195 |
||
758 | 196 |
"Modified: / 08-04-2011 / 17:39:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 197 |
! ! |
198 |
||
774 | 199 |
!JavaRef2 methodsFor:'logging'! |
200 |
||
1000 | 201 |
info: arg |
202 |
||
203 |
Logger log: arg severity: #info facility: 'JVM' |
|
774 | 204 |
|
205 |
"Created: / 10-05-2011 / 16:50:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1000 | 206 |
"Modified: / 14-09-2011 / 21:47:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
774 | 207 |
! |
208 |
||
209 |
warning: arg |
|
1000 | 210 |
|
211 |
Logger log: arg severity: #warn facility: 'JVM' |
|
774 | 212 |
|
213 |
"Created: / 10-05-2011 / 15:01:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1000 | 214 |
"Modified: / 14-09-2011 / 21:47:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
774 | 215 |
! ! |
216 |
||
915 | 217 |
!JavaRef2 methodsFor:'printing'! |
218 |
||
219 |
displayString |
|
220 |
||
221 |
^self subclassResponsibility |
|
222 |
||
223 |
"Created: / 14-08-2011 / 21:18:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
224 |
! ! |
|
225 |
||
774 | 226 |
!JavaRef2 methodsFor:'private - resolving'! |
227 |
||
228 |
findResolvedStaticValue |
|
229 |
"raise an error: must be redefined in concrete subclass(es)" |
|
230 |
||
231 |
^ self subclassResponsibility |
|
232 |
! |
|
233 |
||
234 |
findResolvedValue |
|
235 |
"raise an error: must be redefined in concrete subclass(es)" |
|
236 |
||
237 |
^ self subclassResponsibility |
|
238 |
! ! |
|
239 |
||
758 | 240 |
!JavaRef2 methodsFor:'queries'! |
241 |
||
242 |
isJavaRef |
|
243 |
"return true if object represents reference in java constant pool" |
|
244 |
^ true. |
|
245 |
||
246 |
"Created: / 08-04-2011 / 16:15:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
771 | 247 |
! |
248 |
||
249 |
isNewJavaRef |
|
250 |
"only temporary, to know if ref is old (claus' version) or new (m version)" |
|
251 |
||
252 |
^ true. |
|
253 |
||
254 |
"Created: / 10-05-2011 / 12:20:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
758 | 255 |
! ! |
256 |
||
752 | 257 |
!JavaRef2 methodsFor:'resolving'! |
258 |
||
259 |
invalidate |
|
758 | 260 |
"Invalidate reference. Cache will be cleared and next call to resolve will cause resolving from scratch." |
261 |
||
262 |
valueCache := nil. |
|
752 | 263 |
|
264 |
"Created: / 08-04-2011 / 11:42:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
758 | 265 |
"Modified: / 08-04-2011 / 17:39:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
266 |
! |
|
267 |
||
268 |
invalidateForClass: internalJavaClassName |
|
269 |
"Invalidate (means call invalidate) reference if it has something to do with given class (e.g Class named internalJavaClassName was unloaded). |
|
270 |
Return true, if reference was invalidated." |
|
271 |
||
272 |
^ self subclassResponsibility. |
|
273 |
||
274 |
"Created: / 08-04-2011 / 15:59:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 275 |
! |
276 |
||
277 |
resolve |
|
278 |
" |
|
279 |
Do it all method - resolves current reference and returns expected element (JavaMethod, JavaField etc.) |
|
280 |
Hides implementation details of the way of dealing with invalidation etc. User should not need to call anything |
|
281 |
else." |
|
282 |
||
283 |
self isResolved ifFalse: [ self findResolvedValue ]. |
|
284 |
^ valueCache. |
|
285 |
||
286 |
"Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
761 | 287 |
! |
288 |
||
289 |
resolveStatic |
|
290 |
" |
|
291 |
Do it all method - resolves current reference and returns expected element (JavaMethod, JavaField etc.) |
|
292 |
Hides implementation details of the way of dealing with invalidation etc. User should not need to call anything |
|
293 |
else." |
|
294 |
||
295 |
self isResolved ifFalse: [ self findResolvedStaticValue ]. |
|
296 |
^ valueCache. |
|
297 |
||
298 |
"Created: / 26-04-2011 / 13:19:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
774 | 299 |
! |
300 |
||
301 |
updateClassRefsFrom: oldOwner to: newOwner |
|
840
8d04bfac22da
removed annoying updating classRefs from to output
hlopkmar
parents:
814
diff
changeset
|
302 |
self owner = oldOwner ifTrue: [ |
8d04bfac22da
removed annoying updating classRefs from to output
hlopkmar
parents:
814
diff
changeset
|
303 |
self owner: newOwner. |
8d04bfac22da
removed annoying updating classRefs from to output
hlopkmar
parents:
814
diff
changeset
|
304 |
]. |
774 | 305 |
|
306 |
"Created: / 10-05-2011 / 16:50:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
840
8d04bfac22da
removed annoying updating classRefs from to output
hlopkmar
parents:
814
diff
changeset
|
307 |
"Modified: / 04-06-2011 / 17:54:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 308 |
! ! |
309 |
||
809 | 310 |
!JavaRef2 methodsFor:'testing'! |
311 |
||
312 |
isUnresolved |
|
313 |
||
314 |
^valueCache isNil |
|
315 |
||
316 |
"Created: / 22-05-2011 / 14:01:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
317 |
! ! |
|
318 |
||
752 | 319 |
!JavaRef2 class methodsFor:'documentation'! |
320 |
||
321 |
version_SVN |
|
322 |
^ '$Id$' |
|
323 |
! ! |