749
|
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 |
"
|
|
42 |
"{ Package: 'stx:libjava' }"
|
|
43 |
|
|
44 |
JavaRef2 subclass:#JavaClassRef2
|
|
45 |
instanceVariableNames:'nameIndex'
|
|
46 |
classVariableNames:''
|
|
47 |
poolDictionaries:''
|
|
48 |
category:'Languages-Java-Reader-Support-new'
|
|
49 |
!
|
|
50 |
|
|
51 |
!JavaClassRef2 class methodsFor:'documentation'!
|
|
52 |
|
|
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 |
|
|
98 |
!JavaClassRef2 class methodsFor:'instance creation'!
|
|
99 |
|
|
100 |
in: aJavaConstantPool withNameAt: nameIndex
|
|
101 |
|
|
102 |
|
|
103 |
^ self basicNew initializeIn: aJavaConstantPool withNameAt: nameIndex.
|
|
104 |
|
|
105 |
"Created: / 10-05-2011 / 14:56:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
106 |
! !
|
|
107 |
|
|
108 |
!JavaClassRef2 methodsFor:'accessing'!
|
|
109 |
|
|
110 |
classLoader
|
|
111 |
self owner ifNil: [ ^ nil ] ifNotNil: [ ^ self owner classLoader ].
|
|
112 |
|
|
113 |
"Created: / 11-04-2011 / 21:52:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
114 |
"Modified: / 12-05-2011 / 18:32:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
115 |
!
|
|
116 |
|
|
117 |
javaClass
|
|
118 |
|
|
119 |
valueCache ifNil:[self resolve].
|
|
120 |
^valueCache
|
|
121 |
|
|
122 |
"Created: / 22-05-2011 / 14:02:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
123 |
!
|
|
124 |
|
|
125 |
javaClassName
|
|
126 |
"return java class name as written in java programs e.g. java.util.String
|
|
127 |
in case of array, return class name without square brackets"
|
|
128 |
|
|
129 |
| tmp |
|
|
130 |
|
|
131 |
tmp := self name copy.
|
|
132 |
[ tmp startsWith: '[' ] whileTrue: [ tmp := tmp copyFrom: 2 ].
|
|
133 |
tmp := tmp replaceAll: $/ with: $..
|
|
134 |
(tmp startsWith: 'L') ifTrue: [ tmp := tmp copyFrom: 2 to: tmp size ].
|
|
135 |
(tmp endsWith: ';') ifTrue: [ tmp := tmp copyFrom: 1 to: tmp size - 1 ].
|
|
136 |
^ tmp.
|
|
137 |
|
|
138 |
"Created: / 08-04-2011 / 18:30:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
139 |
"Modified: / 23-05-2011 / 15:30:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
140 |
!
|
|
141 |
|
|
142 |
name
|
|
143 |
^constantPool at: nameIndex.
|
|
144 |
|
|
145 |
"Created: / 08-04-2011 / 13:48:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
146 |
"Modified: / 13-05-2011 / 09:59:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
147 |
! !
|
|
148 |
|
|
149 |
!JavaClassRef2 methodsFor:'array support'!
|
|
150 |
|
|
151 |
arrayDimensions
|
|
152 |
^ self name occurrencesOf: $[.
|
|
153 |
|
|
154 |
"Created: / 08-04-2011 / 18:42:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
155 |
"Modified: / 13-05-2011 / 10:00:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
156 |
!
|
|
157 |
|
|
158 |
isJavaArrayClassRef
|
|
159 |
^ self name startsWith: '['.
|
|
160 |
|
|
161 |
"Created: / 08-04-2011 / 18:40:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
162 |
"Modified: / 13-05-2011 / 10:00:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
163 |
! !
|
|
164 |
|
|
165 |
!JavaClassRef2 methodsFor:'comparing'!
|
|
166 |
|
|
167 |
= anotherJavaClassRef
|
|
168 |
"superclass JavaRef2 says that I am responsible to implement this method"
|
|
169 |
|
|
170 |
anotherJavaClassRef isJavaClassRef ifFalse: [ ^ false ].
|
|
171 |
^ self name = anotherJavaClassRef name.
|
|
172 |
|
|
173 |
"Modified: / 08-04-2011 / 13:48:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
174 |
!
|
|
175 |
|
|
176 |
hash
|
|
177 |
^ self name hash.
|
|
178 |
|
|
179 |
"Modified: / 13-05-2011 / 10:00:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
180 |
! !
|
|
181 |
|
|
182 |
!JavaClassRef2 methodsFor:'initialization'!
|
|
183 |
|
|
184 |
initializeIn: aJavaConstantPool withNameAt: nameCPIndex
|
|
185 |
nameIndex := nameCPIndex.
|
|
186 |
constantPool := aJavaConstantPool.
|
|
187 |
super initialize.
|
|
188 |
|
|
189 |
"Modified: / 10-05-2011 / 14:57:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
190 |
! !
|
|
191 |
|
|
192 |
!JavaClassRef2 methodsFor:'printing'!
|
|
193 |
|
|
194 |
displayString
|
|
195 |
|
|
196 |
^self name
|
|
197 |
|
|
198 |
"Created: / 14-08-2011 / 21:18:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
199 |
!
|
|
200 |
|
|
201 |
fullName
|
|
202 |
^ self name.
|
|
203 |
|
|
204 |
"Created: / 10-05-2011 / 14:19:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
205 |
!
|
|
206 |
|
|
207 |
printString
|
|
208 |
^ 'JavaClassRef for: ' , self name printString.
|
|
209 |
|
|
210 |
"Created: / 10-05-2011 / 14:16:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
211 |
"Modified: / 13-05-2011 / 10:00:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
212 |
! !
|
|
213 |
|
|
214 |
!JavaClassRef2 methodsFor:'private - resolving'!
|
|
215 |
|
|
216 |
findResolvedStaticValue
|
|
217 |
"Resolving static inner classes is not different from resolving any other class, it's only done in different circumstances"
|
|
218 |
|
|
219 |
^ self findResolvedValue.
|
|
220 |
|
|
221 |
"Created: / 28-04-2011 / 21:57:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
222 |
!
|
|
223 |
|
|
224 |
findResolvedValue
|
|
225 |
"Resolve reference and set valueCache."
|
|
226 |
|
|
227 |
valueCache := JavaResolver uniqueInstance
|
|
228 |
resolveClassIndentifiedByRef: self.
|
|
229 |
|
|
230 |
"Modified: / 08-04-2011 / 17:39:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
231 |
!
|
|
232 |
|
|
233 |
findResolvedValue: doInit
|
|
234 |
"Resolve reference and set valueCache."
|
|
235 |
|
|
236 |
valueCache := JavaResolver uniqueInstance
|
|
237 |
resolveClassIndentifiedByRef: self init: doInit.
|
|
238 |
|
|
239 |
"Modified: / 08-04-2011 / 17:39:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
240 |
"Created: / 12-08-2011 / 22:19:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
241 |
! !
|
|
242 |
|
|
243 |
!JavaClassRef2 methodsFor:'queries'!
|
|
244 |
|
|
245 |
isJavaClassRef
|
|
246 |
^true.
|
|
247 |
|
|
248 |
"Created: / 11-04-2011 / 19:10:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
249 |
! !
|
|
250 |
|
|
251 |
!JavaClassRef2 methodsFor:'resolving'!
|
|
252 |
|
|
253 |
invalidateForClass: internalJavaClassName
|
|
254 |
"Invalidate (means call invalidate) reference if it has something to do with given class (e.g Class named internalJavaClassName was unloaded).
|
|
255 |
Return true, if reference was invalidated."
|
|
256 |
|
|
257 |
self name = internalJavaClassName
|
|
258 |
ifTrue:
|
|
259 |
[
|
|
260 |
self invalidate.
|
|
261 |
^ true ].
|
|
262 |
^ false.
|
|
263 |
|
|
264 |
"Modified: / 23-05-2011 / 15:21:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
265 |
!
|
|
266 |
|
|
267 |
resolve
|
|
268 |
|
|
269 |
^self resolve: true
|
|
270 |
|
|
271 |
"Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
272 |
"Created: / 12-08-2011 / 22:18:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
273 |
!
|
|
274 |
|
|
275 |
resolve: doInit
|
|
276 |
"
|
|
277 |
Resolves a class. If doInit is true, then the class is initialuzed,
|
|
278 |
otherwise not.
|
|
279 |
"
|
|
280 |
|
|
281 |
self isResolved ifFalse: [ self findResolvedValue: doInit ].
|
|
282 |
^ valueCache.
|
|
283 |
|
|
284 |
"Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
285 |
"Created: / 12-08-2011 / 22:18:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
286 |
! !
|
|
287 |
|
|
288 |
!JavaClassRef2 class methodsFor:'documentation'!
|
|
289 |
|
2226
|
290 |
version_CVS
|
|
291 |
^ '$Header: /cvs/stx/stx/libjava/JavaClassRef2.st,v 1.2 2011-11-24 11:24:14 cg Exp $'
|
|
292 |
!
|
|
293 |
|
749
|
294 |
version_SVN
|
2226
|
295 |
^ '§Id: JavaClassRef2.st,v 1.1 2011/08/18 19:06:53 vrany Exp §'
|
2152
|
296 |
! !
|