author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 15 Dec 2012 23:25:19 +0100 | |
branch | development |
changeset 1883 | b36e52129040 |
parent 1864 | 60a8dc26c8c6 |
child 2069 | 75d40b7b986f |
permissions | -rw-r--r-- |
877 | 1 |
" |
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 3 |
|
1155 | 4 |
New code and modifications done at SWING Research Group [1]: |
1152 | 5 |
|
877 | 6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
7 |
SWING Research Group, Czech Technical University in Prague |
|
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 |
||
1155 | 16 |
[1] Code written at SWING Research Group contains a signature |
17 |
of one of the above copright owners. For exact set of such code, |
|
18 |
see the differences between this version and version stx:libjava |
|
1152 | 19 |
as of 1.9.2010 |
877 | 20 |
" |
752 | 21 |
"{ Package: 'stx:libjava' }" |
22 |
||
774 | 23 |
Object subclass:#JavaRef2 |
777 | 24 |
instanceVariableNames:'valueCache constantPool' |
752 | 25 |
classVariableNames:'' |
26 |
poolDictionaries:'' |
|
27 |
category:'Languages-Java-Reader-Support-new' |
|
28 |
! |
|
29 |
||
758 | 30 |
!JavaRef2 class methodsFor:'documentation'! |
31 |
||
877 | 32 |
copyright |
33 |
" |
|
34 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 35 |
|
1155 | 36 |
New code and modifications done at SWING Research Group [1]: |
1152 | 37 |
|
877 | 38 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
39 |
SWING Research Group, Czech Technical University in Prague |
|
40 |
||
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
||
1155 | 48 |
[1] Code written at SWING Research Group contains a signature |
49 |
of one of the above copright owners. For exact set of such code, |
|
50 |
see the differences between this version and version stx:libjava |
|
1152 | 51 |
as of 1.9.2010 |
877 | 52 |
|
53 |
" |
|
758 | 54 |
! ! |
752 | 55 |
|
56 |
!JavaRef2 class methodsFor:'instance creation'! |
|
57 |
||
58 |
new |
|
758 | 59 |
"Don't call me directly" |
60 |
||
761 | 61 |
'[JavaRef] Dont instantiate me with new. Call my custom overriden object creation method' |
62 |
infoPrintCR. |
|
1226 | 63 |
|
761 | 64 |
^ self basicNew initialize. |
752 | 65 |
|
1226 | 66 |
"Modified: / 06-12-2011 / 17:02:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 67 |
! ! |
68 |
||
69 |
!JavaRef2 methodsFor:'accessing'! |
|
70 |
||
774 | 71 |
constantPool |
72 |
^constantPool. |
|
73 |
||
74 |
"Created: / 10-05-2011 / 17:16:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
75 |
! |
|
76 |
||
77 |
constantPool: aJavaConstantPool |
|
78 |
constantPool := aJavaConstantPool. |
|
79 |
||
80 |
"Created: / 10-05-2011 / 17:16:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
81 |
! |
|
82 |
||
752 | 83 |
isResolved |
758 | 84 |
^ valueCache isNil not. |
752 | 85 |
|
86 |
"Created: / 08-04-2011 / 11:36:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
758 | 87 |
"Modified: / 08-04-2011 / 17:39:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
88 |
! |
|
89 |
||
90 |
name |
|
91 |
^ self subclassResponsibility. |
|
92 |
||
93 |
"Created: / 08-04-2011 / 13:53:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
94 |
! |
|
95 |
||
774 | 96 |
owner |
777 | 97 |
^ constantPool owner. |
98 |
||
99 |
"Modified: / 12-05-2011 / 18:31:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
774 | 100 |
! |
101 |
||
777 | 102 |
owner: javaClass |
103 |
constantPool owner: javaClass. |
|
104 |
||
105 |
"Modified: / 12-05-2011 / 18:32:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
774 | 106 |
! |
107 |
||
752 | 108 |
valueCache |
109 |
^ valueCache. |
|
110 |
||
111 |
"Created: / 08-04-2011 / 11:37:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
112 |
! ! |
|
113 |
||
114 |
!JavaRef2 methodsFor:'comparing'! |
|
115 |
||
116 |
= anotherJavaRef |
|
117 |
^ self subclassResponsibility. |
|
118 |
||
119 |
"Created: / 08-04-2011 / 12:15:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
120 |
! |
|
121 |
||
122 |
hash |
|
123 |
||
124 |
^ self subclassResponsibility. |
|
125 |
||
126 |
"Created: / 08-04-2011 / 12:15:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
127 |
! ! |
|
128 |
||
129 |
!JavaRef2 methodsFor:'initialization'! |
|
130 |
||
131 |
initialize |
|
132 |
valueCache := nil. |
|
133 |
super initialize. |
|
134 |
||
758 | 135 |
"Modified: / 08-04-2011 / 17:39:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 136 |
! ! |
137 |
||
774 | 138 |
!JavaRef2 methodsFor:'logging'! |
139 |
||
1000 | 140 |
info: arg |
141 |
||
142 |
Logger log: arg severity: #info facility: 'JVM' |
|
774 | 143 |
|
144 |
"Created: / 10-05-2011 / 16:50:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1000 | 145 |
"Modified: / 14-09-2011 / 21:47:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
774 | 146 |
! |
147 |
||
148 |
warning: arg |
|
1000 | 149 |
|
150 |
Logger log: arg severity: #warn facility: 'JVM' |
|
774 | 151 |
|
152 |
"Created: / 10-05-2011 / 15:01:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1000 | 153 |
"Modified: / 14-09-2011 / 21:47:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
774 | 154 |
! ! |
155 |
||
915 | 156 |
!JavaRef2 methodsFor:'printing'! |
157 |
||
158 |
displayString |
|
159 |
||
160 |
^self subclassResponsibility |
|
161 |
||
162 |
"Created: / 14-08-2011 / 21:18:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
163 |
! ! |
|
164 |
||
774 | 165 |
!JavaRef2 methodsFor:'private - resolving'! |
166 |
||
167 |
findResolvedValue |
|
1353 | 168 |
self findResolvedValue: true. |
169 |
||
170 |
"Modified: / 09-02-2012 / 23:10:09 / mh <hlopik@gmail.com>" |
|
171 |
! |
|
774 | 172 |
|
1461 | 173 |
findResolvedValue: doInit |
174 |
"Resolves reference. If doInit is true, then eventually |
|
175 |
initialize the class" |
|
176 |
||
177 |
self subclassResponsibility |
|
1353 | 178 |
|
179 |
"Created: / 09-02-2012 / 23:08:15 / mh <hlopik@gmail.com>" |
|
1461 | 180 |
"Modified: / 10-04-2012 / 09:31:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
774 | 181 |
! ! |
182 |
||
758 | 183 |
!JavaRef2 methodsFor:'queries'! |
184 |
||
185 |
isJavaRef |
|
186 |
"return true if object represents reference in java constant pool" |
|
187 |
^ true. |
|
188 |
||
189 |
"Created: / 08-04-2011 / 16:15:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
771 | 190 |
! |
191 |
||
192 |
isNewJavaRef |
|
193 |
"only temporary, to know if ref is old (claus' version) or new (m version)" |
|
194 |
||
195 |
^ true. |
|
196 |
||
197 |
"Created: / 10-05-2011 / 12:20:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
758 | 198 |
! ! |
199 |
||
752 | 200 |
!JavaRef2 methodsFor:'resolving'! |
201 |
||
202 |
invalidate |
|
758 | 203 |
"Invalidate reference. Cache will be cleared and next call to resolve will cause resolving from scratch." |
204 |
||
205 |
valueCache := nil. |
|
752 | 206 |
|
207 |
"Created: / 08-04-2011 / 11:42:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
758 | 208 |
"Modified: / 08-04-2011 / 17:39:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
209 |
! |
|
210 |
||
211 |
invalidateForClass: internalJavaClassName |
|
1372
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1353
diff
changeset
|
212 |
"Invalidates receiver iff it refers (even indirectly) |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1353
diff
changeset
|
213 |
to a class ref that has been resolved to given class. |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1353
diff
changeset
|
214 |
Returns true, if the receiver has been invalidated, |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1353
diff
changeset
|
215 |
false otherwise" |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1353
diff
changeset
|
216 |
|
758 | 217 |
^ self subclassResponsibility. |
218 |
||
219 |
"Created: / 08-04-2011 / 15:59:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1372
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1353
diff
changeset
|
220 |
"Modified (comment): / 21-02-2012 / 10:20:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 221 |
! |
222 |
||
1728 | 223 |
preResolve |
224 |
"Pre-resolve some caches. Called when the constant pool |
|
225 |
is loaded. MUST NOT load new nor modify any existing class!!!!!! |
|
226 |
Ask JV for what this is needed" |
|
227 |
||
228 |
"Nothing by default" |
|
229 |
||
230 |
"Created: / 15-10-2012 / 23:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
231 |
! |
|
232 |
||
233 |
preresolve |
|
234 |
"Pre-resolve some caches. Called when the constant pool |
|
235 |
is loaded. MUST NOT load new nor modify any existing class!!!!!! |
|
236 |
Ask JV for what this is needed" |
|
237 |
||
238 |
"Nothing by default" |
|
239 |
||
240 |
"Created: / 15-10-2012 / 23:08:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
241 |
! |
|
242 |
||
752 | 243 |
resolve |
244 |
" |
|
245 |
Do it all method - resolves current reference and returns expected element (JavaMethod, JavaField etc.) |
|
246 |
Hides implementation details of the way of dealing with invalidation etc. User should not need to call anything |
|
247 |
else." |
|
248 |
||
1378 | 249 |
self resolve: true. |
752 | 250 |
^ valueCache. |
251 |
||
252 |
"Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1378 | 253 |
"Modified: / 23-02-2012 / 17:21:39 / Marcel Hlopko <hlopik@gmail.com>" |
761 | 254 |
! |
255 |
||
1353 | 256 |
resolve: doClassInit |
1391 | 257 |
"Do it all method - resolves current reference and returns expected element (JavaMethod, JavaField etc.) |
258 |
If doClassInit is true, resolved class is initialized (if not already) |
|
1353 | 259 |
Hides implementation details of the way of dealing with invalidation etc. User should not need to call anything |
260 |
else." |
|
261 |
||
1711 | 262 |
self isResolved ifFalse: [ |
263 |
self findResolvedValue: doClassInit. |
|
1733 | 264 |
JavaVM flushCachesFor: constantPool owner. |
1711 | 265 |
]. |
1353 | 266 |
^ valueCache. |
267 |
||
268 |
"Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
269 |
"Created: / 09-02-2012 / 23:08:15 / mh <hlopik@gmail.com>" |
|
1733 | 270 |
"Modified: / 17-10-2012 / 20:24:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1353 | 271 |
! |
272 |
||
774 | 273 |
updateClassRefsFrom: oldOwner to: newOwner |
840
8d04bfac22da
removed annoying updating classRefs from to output
hlopkmar
parents:
814
diff
changeset
|
274 |
self owner = oldOwner ifTrue: [ |
8d04bfac22da
removed annoying updating classRefs from to output
hlopkmar
parents:
814
diff
changeset
|
275 |
self owner: newOwner. |
8d04bfac22da
removed annoying updating classRefs from to output
hlopkmar
parents:
814
diff
changeset
|
276 |
]. |
774 | 277 |
|
278 |
"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
|
279 |
"Modified: / 04-06-2011 / 17:54:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 280 |
! ! |
281 |
||
809 | 282 |
!JavaRef2 methodsFor:'testing'! |
283 |
||
284 |
isUnresolved |
|
285 |
||
286 |
^valueCache isNil |
|
287 |
||
288 |
"Created: / 22-05-2011 / 14:01:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
289 |
! ! |
|
290 |
||
752 | 291 |
!JavaRef2 class methodsFor:'documentation'! |
292 |
||
1864 | 293 |
version_HG |
294 |
||
295 |
^ '$Changeset: <not expanded> $' |
|
296 |
! |
|
297 |
||
752 | 298 |
version_SVN |
1864 | 299 |
^ '§Id§' |
752 | 300 |
! ! |