author | hlopkmar |
Wed, 02 Nov 2011 21:40:47 +0000 | |
branch | jk_new_structure |
changeset 1073 | e842ab17fe16 |
parent 1000 | cfa982260238 |
child 1152 | 040cba55a7d2 |
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. |
|
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1000
diff
changeset
|
125 |
self breakPoint:#mh. |
761 | 126 |
^ self basicNew initialize. |
752 | 127 |
|
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1000
diff
changeset
|
128 |
"Modified: / 01-11-2011 / 13:35:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 129 |
! ! |
130 |
||
131 |
!JavaRef2 methodsFor:'accessing'! |
|
132 |
||
774 | 133 |
constantPool |
134 |
^constantPool. |
|
135 |
||
136 |
"Created: / 10-05-2011 / 17:16:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
137 |
! |
|
138 |
||
139 |
constantPool: aJavaConstantPool |
|
140 |
constantPool := aJavaConstantPool. |
|
141 |
||
142 |
"Created: / 10-05-2011 / 17:16:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
143 |
! |
|
144 |
||
752 | 145 |
isResolved |
758 | 146 |
^ valueCache isNil not. |
752 | 147 |
|
148 |
"Created: / 08-04-2011 / 11:36:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
758 | 149 |
"Modified: / 08-04-2011 / 17:39:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
150 |
! |
|
151 |
||
152 |
name |
|
153 |
^ self subclassResponsibility. |
|
154 |
||
155 |
"Created: / 08-04-2011 / 13:53:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
156 |
! |
|
157 |
||
774 | 158 |
owner |
777 | 159 |
^ constantPool owner. |
160 |
||
161 |
"Modified: / 12-05-2011 / 18:31:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
774 | 162 |
! |
163 |
||
777 | 164 |
owner: javaClass |
165 |
constantPool owner: javaClass. |
|
166 |
||
167 |
"Modified: / 12-05-2011 / 18:32:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
774 | 168 |
! |
169 |
||
752 | 170 |
valueCache |
171 |
^ valueCache. |
|
172 |
||
173 |
"Created: / 08-04-2011 / 11:37:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
174 |
! ! |
|
175 |
||
176 |
!JavaRef2 methodsFor:'comparing'! |
|
177 |
||
178 |
= anotherJavaRef |
|
179 |
^ self subclassResponsibility. |
|
180 |
||
181 |
"Created: / 08-04-2011 / 12:15:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
182 |
! |
|
183 |
||
184 |
hash |
|
185 |
||
186 |
^ self subclassResponsibility. |
|
187 |
||
188 |
"Created: / 08-04-2011 / 12:15:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
189 |
! ! |
|
190 |
||
191 |
!JavaRef2 methodsFor:'initialization'! |
|
192 |
||
193 |
initialize |
|
194 |
valueCache := nil. |
|
195 |
super initialize. |
|
196 |
||
758 | 197 |
"Modified: / 08-04-2011 / 17:39:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 198 |
! ! |
199 |
||
774 | 200 |
!JavaRef2 methodsFor:'logging'! |
201 |
||
1000 | 202 |
info: arg |
203 |
||
204 |
Logger log: arg severity: #info facility: 'JVM' |
|
774 | 205 |
|
206 |
"Created: / 10-05-2011 / 16:50:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1000 | 207 |
"Modified: / 14-09-2011 / 21:47:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
774 | 208 |
! |
209 |
||
210 |
warning: arg |
|
1000 | 211 |
|
212 |
Logger log: arg severity: #warn facility: 'JVM' |
|
774 | 213 |
|
214 |
"Created: / 10-05-2011 / 15:01:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1000 | 215 |
"Modified: / 14-09-2011 / 21:47:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
774 | 216 |
! ! |
217 |
||
915 | 218 |
!JavaRef2 methodsFor:'printing'! |
219 |
||
220 |
displayString |
|
221 |
||
222 |
^self subclassResponsibility |
|
223 |
||
224 |
"Created: / 14-08-2011 / 21:18:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
225 |
! ! |
|
226 |
||
774 | 227 |
!JavaRef2 methodsFor:'private - resolving'! |
228 |
||
229 |
findResolvedStaticValue |
|
230 |
"raise an error: must be redefined in concrete subclass(es)" |
|
231 |
||
232 |
^ self subclassResponsibility |
|
233 |
! |
|
234 |
||
235 |
findResolvedValue |
|
236 |
"raise an error: must be redefined in concrete subclass(es)" |
|
237 |
||
238 |
^ self subclassResponsibility |
|
239 |
! ! |
|
240 |
||
758 | 241 |
!JavaRef2 methodsFor:'queries'! |
242 |
||
243 |
isJavaRef |
|
244 |
"return true if object represents reference in java constant pool" |
|
245 |
^ true. |
|
246 |
||
247 |
"Created: / 08-04-2011 / 16:15:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
771 | 248 |
! |
249 |
||
250 |
isNewJavaRef |
|
251 |
"only temporary, to know if ref is old (claus' version) or new (m version)" |
|
252 |
||
253 |
^ true. |
|
254 |
||
255 |
"Created: / 10-05-2011 / 12:20:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
758 | 256 |
! ! |
257 |
||
752 | 258 |
!JavaRef2 methodsFor:'resolving'! |
259 |
||
260 |
invalidate |
|
758 | 261 |
"Invalidate reference. Cache will be cleared and next call to resolve will cause resolving from scratch." |
262 |
||
263 |
valueCache := nil. |
|
752 | 264 |
|
265 |
"Created: / 08-04-2011 / 11:42:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
758 | 266 |
"Modified: / 08-04-2011 / 17:39:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
267 |
! |
|
268 |
||
269 |
invalidateForClass: internalJavaClassName |
|
270 |
"Invalidate (means call invalidate) reference if it has something to do with given class (e.g Class named internalJavaClassName was unloaded). |
|
271 |
Return true, if reference was invalidated." |
|
272 |
||
273 |
^ self subclassResponsibility. |
|
274 |
||
275 |
"Created: / 08-04-2011 / 15:59:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 276 |
! |
277 |
||
278 |
resolve |
|
279 |
" |
|
280 |
Do it all method - resolves current reference and returns expected element (JavaMethod, JavaField etc.) |
|
281 |
Hides implementation details of the way of dealing with invalidation etc. User should not need to call anything |
|
282 |
else." |
|
283 |
||
284 |
self isResolved ifFalse: [ self findResolvedValue ]. |
|
285 |
^ valueCache. |
|
286 |
||
287 |
"Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
761 | 288 |
! |
289 |
||
290 |
resolveStatic |
|
291 |
" |
|
292 |
Do it all method - resolves current reference and returns expected element (JavaMethod, JavaField etc.) |
|
293 |
Hides implementation details of the way of dealing with invalidation etc. User should not need to call anything |
|
294 |
else." |
|
295 |
||
296 |
self isResolved ifFalse: [ self findResolvedStaticValue ]. |
|
297 |
^ valueCache. |
|
298 |
||
299 |
"Created: / 26-04-2011 / 13:19:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
774 | 300 |
! |
301 |
||
302 |
updateClassRefsFrom: oldOwner to: newOwner |
|
840
8d04bfac22da
removed annoying updating classRefs from to output
hlopkmar
parents:
814
diff
changeset
|
303 |
self owner = oldOwner ifTrue: [ |
8d04bfac22da
removed annoying updating classRefs from to output
hlopkmar
parents:
814
diff
changeset
|
304 |
self owner: newOwner. |
8d04bfac22da
removed annoying updating classRefs from to output
hlopkmar
parents:
814
diff
changeset
|
305 |
]. |
774 | 306 |
|
307 |
"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
|
308 |
"Modified: / 04-06-2011 / 17:54:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 309 |
! ! |
310 |
||
809 | 311 |
!JavaRef2 methodsFor:'testing'! |
312 |
||
313 |
isUnresolved |
|
314 |
||
315 |
^valueCache isNil |
|
316 |
||
317 |
"Created: / 22-05-2011 / 14:01:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
318 |
! ! |
|
319 |
||
752 | 320 |
!JavaRef2 class methodsFor:'documentation'! |
321 |
||
322 |
version_SVN |
|
323 |
^ '$Id$' |
|
324 |
! ! |