752
|
1 |
"
|
877
|
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 |
|
752
|
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.
|
877
|
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
|
752
|
20 |
"
|
|
21 |
"{ Package: 'stx:libjava' }"
|
|
22 |
|
|
23 |
JavaUnresolvedConstant subclass:#JavaUnresolvedClassConstant
|
|
24 |
instanceVariableNames:'nameIndex fullName'
|
|
25 |
classVariableNames:''
|
|
26 |
poolDictionaries:''
|
|
27 |
category:'Languages-Java-Reader-Support'
|
|
28 |
!
|
|
29 |
|
|
30 |
!JavaUnresolvedClassConstant class methodsFor:'documentation'!
|
|
31 |
|
|
32 |
copyright
|
|
33 |
"
|
877
|
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 |
|
752
|
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.
|
877
|
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 |
"
|
752
|
54 |
! !
|
|
55 |
|
|
56 |
!JavaUnresolvedClassConstant class methodsFor:'instance creation'!
|
|
57 |
|
|
58 |
fullName:nm
|
|
59 |
|ref|
|
|
60 |
|
|
61 |
ref := Java unresolvedClassRefFor:nm.
|
|
62 |
ref notNil ifTrue:[^ ref].
|
|
63 |
|
|
64 |
ref := self new setFullName:nm.
|
|
65 |
Java rememberUnresolved:ref.
|
|
66 |
^ ref
|
|
67 |
|
|
68 |
"Modified: / 19.10.1998 / 20:18:13 / cg"
|
|
69 |
!
|
|
70 |
|
|
71 |
pool:aPool poolIndex:slotIndex fullName:aString
|
|
72 |
^ self new
|
|
73 |
pool:aPool poolIndex:slotIndex fullName:aString
|
|
74 |
|
|
75 |
"Created: / 4.2.1998 / 22:13:13 / cg"
|
|
76 |
"Modified: / 4.2.1998 / 22:13:28 / cg"
|
|
77 |
!
|
|
78 |
|
|
79 |
pool:aPool poolIndex:slotIndex nameIndex:index
|
|
80 |
^ self new
|
|
81 |
pool:aPool poolIndex:slotIndex nameIndex:index
|
|
82 |
|
|
83 |
"Modified: / 4.2.1998 / 22:13:38 / cg"
|
|
84 |
! !
|
|
85 |
|
|
86 |
!JavaUnresolvedClassConstant methodsFor:'* As yet uncategorized *'!
|
|
87 |
|
|
88 |
javaClassForNew
|
|
89 |
|
|
90 |
^self javaClass
|
|
91 |
|
|
92 |
"Created: / 16-03-2011 / 16:09:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
93 |
! !
|
|
94 |
|
|
95 |
!JavaUnresolvedClassConstant methodsFor:'accessing'!
|
|
96 |
|
|
97 |
className
|
|
98 |
|s nm|
|
|
99 |
|
|
100 |
(fullName startsWith:$[) ifTrue:[
|
|
101 |
"/ a ref for newarray or new or checkCast
|
|
102 |
|
|
103 |
s := fullName readStream.
|
|
104 |
[ s peek == $[ ] whileTrue:[
|
|
105 |
s next.
|
|
106 |
].
|
|
107 |
nm := JavaMethod retvalSpecFromStream:s in:nil.
|
|
108 |
^ nm
|
|
109 |
].
|
|
110 |
^ fullName
|
|
111 |
|
|
112 |
"Modified: / 8.1.1998 / 19:11:37 / cg"
|
|
113 |
!
|
|
114 |
|
|
115 |
deref
|
|
116 |
|refClassName cls|
|
|
117 |
|
|
118 |
(fullName startsWith:'[L') ifTrue:[
|
|
119 |
refClassName := fullName copyFrom:3 to:(fullName indexOf:$;)-1.
|
|
120 |
cls := Java at:refClassName.
|
|
121 |
cls notNil ifTrue:[
|
|
122 |
^ cls
|
|
123 |
].
|
|
124 |
^ JavaUnresolvedClassConstant basicNew setFullName:refClassName
|
|
125 |
].
|
|
126 |
(fullName startsWith:'[[C') ifTrue:[
|
|
127 |
^ JavaBuiltInClassPointerRef new nameandType:'[C'.
|
|
128 |
].
|
|
129 |
|
|
130 |
"Created: / 7.4.1997 / 13:38:07 / cg"
|
|
131 |
"Modified: / 6.2.1998 / 01:21:01 / cg"
|
|
132 |
!
|
|
133 |
|
|
134 |
fullName
|
|
135 |
^ fullName
|
|
136 |
|
|
137 |
!
|
|
138 |
|
|
139 |
javaClass
|
1033
|
140 |
| cls clsName |
|
752
|
141 |
|
|
142 |
"/fullName first == $[ ifTrue:[self halt].
|
1033
|
143 |
fullName isNil ifTrue: [
|
752
|
144 |
self preResolve.
|
1033
|
145 |
fullName isNil ifTrue: [ self halt. ]
|
752
|
146 |
].
|
1033
|
147 |
(fullName first = $[) ifTrue: [
|
|
148 |
cls := (JavaDescriptor fromString: fullName) javaClass
|
|
149 |
] ifFalse: [ cls := JavaVM classForName: fullName ].
|
752
|
150 |
constantPool at: constantPoolIndex put: cls.
|
1033
|
151 |
^ cls
|
752
|
152 |
|
|
153 |
"old code:"
|
|
154 |
"
|
1033
|
155 |
(fullName startsWith:$[) ifTrue:[
|
752
|
156 |
self halt.
|
|
157 |
clsName := self className.
|
|
158 |
(Java classForName:clsName) ifNil:
|
|
159 |
[self error: 'Cannot resolve class ' , clsName].
|
|
160 |
cls := (JavaDescriptor fromString: fullName) javaClass.
|
1033
|
161 |
] ifFalse:[
|
752
|
162 |
clsName := fullName
|
1033
|
163 |
].
|
|
164 |
cls := Java classForName:clsName.
|
|
165 |
constantPool at: constantPoolIndex put: cls.
|
|
166 |
^cls"
|
752
|
167 |
"Modified: / 10-11-1998 / 19:29:28 / cg"
|
|
168 |
"Modified: / 11-02-2011 / 07:53:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
169 |
!
|
|
170 |
|
|
171 |
lastName
|
|
172 |
|
|
173 |
| idx |
|
|
174 |
idx := fullName lastIndexOf: $/.
|
|
175 |
^idx ifNil:[fullName] ifNotNil:[fullName copyFrom: idx + 1].
|
|
176 |
|
|
177 |
"Created: / 18-10-2010 / 22:20:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
178 |
!
|
|
179 |
|
|
180 |
name
|
|
181 |
^ fullName copyReplaceAll:$/ with:$.
|
|
182 |
|
|
183 |
"Created: / 7.2.1997 / 23:44:47 / cg"
|
|
184 |
"Modified: / 18.7.1998 / 22:57:47 / cg"
|
|
185 |
!
|
|
186 |
|
|
187 |
pool:aPool poolIndex:slotIndex fullName:aString
|
|
188 |
constantPool := aPool.
|
|
189 |
constantPoolIndex := slotIndex.
|
|
190 |
fullName := aString.
|
|
191 |
|
|
192 |
"Created: / 4.2.1998 / 22:15:22 / cg"
|
|
193 |
!
|
|
194 |
|
|
195 |
pool:aPool poolIndex:slotIndex nameIndex:name_index
|
|
196 |
constantPool := aPool.
|
|
197 |
constantPoolIndex := slotIndex.
|
|
198 |
nameIndex := name_index.
|
|
199 |
|
|
200 |
!
|
|
201 |
|
|
202 |
setFullName:aNameString
|
|
203 |
fullName := aNameString
|
|
204 |
|
|
205 |
"Created: 7.4.1997 / 13:37:45 / cg"
|
|
206 |
!
|
|
207 |
|
|
208 |
smalltalkArrayClass
|
|
209 |
(fullName startsWith:'[[') ifTrue:[
|
|
210 |
^ Array
|
|
211 |
].
|
|
212 |
(fullName startsWith:'[F') ifTrue:[
|
|
213 |
^ FloatArray
|
|
214 |
].
|
|
215 |
(fullName startsWith:'[B') ifTrue:[
|
|
216 |
^ ByteArray
|
|
217 |
].
|
|
218 |
self halt.
|
|
219 |
|
|
220 |
"Created: 7.4.1997 / 13:35:25 / cg"
|
|
221 |
! !
|
|
222 |
|
|
223 |
!JavaUnresolvedClassConstant methodsFor:'converting'!
|
|
224 |
|
|
225 |
asClassPointerRef
|
|
226 |
(fullName startsWith:'[[') ifTrue:[
|
|
227 |
^ JavaClassPointerRef class:Array nameandType:fullName
|
|
228 |
].
|
|
229 |
(fullName startsWith:'[F') ifTrue:[
|
|
230 |
^ JavaClassPointerRef class:FloatArray nameandType:fullName
|
|
231 |
].
|
|
232 |
(fullName startsWith:'[B') ifTrue:[
|
|
233 |
^ JavaClassPointerRef class:ByteArray nameandType:fullName
|
|
234 |
].
|
|
235 |
(fullName startsWith:'[C') ifTrue:[
|
|
236 |
^ JavaClassPointerRef class:String nameandType:fullName
|
|
237 |
].
|
|
238 |
self halt.
|
|
239 |
|
|
240 |
"Created: / 7.4.1997 / 13:40:29 / cg"
|
|
241 |
"Modified: / 25.1.1998 / 19:56:54 / cg"
|
|
242 |
! !
|
|
243 |
|
|
244 |
!JavaUnresolvedClassConstant methodsFor:'printing & storing'!
|
|
245 |
|
|
246 |
displayString
|
|
247 |
fullName isNil ifTrue:[
|
|
248 |
^ 'UnresolvedClass(** nil **)'
|
|
249 |
].
|
|
250 |
^ 'UnresolvedClass(' , (fullName copyReplaceAll:$/ with:$.) , ')'
|
|
251 |
|
|
252 |
"Modified: / 18.7.1998 / 22:57:36 / cg"
|
|
253 |
! !
|
|
254 |
|
|
255 |
!JavaUnresolvedClassConstant methodsFor:'queries'!
|
|
256 |
|
|
257 |
isJavaClassRef
|
|
258 |
^ true
|
|
259 |
|
|
260 |
"Created: / 9.11.1999 / 17:07:15 / cg"
|
|
261 |
!
|
|
262 |
|
|
263 |
isUnresolvedClass
|
|
264 |
^ true
|
|
265 |
|
|
266 |
"Created: / 20.10.1998 / 17:43:36 / cg"
|
|
267 |
!
|
|
268 |
|
|
269 |
package
|
|
270 |
"extract from the fullName"
|
|
271 |
|
|
272 |
|components|
|
|
273 |
|
|
274 |
components := fullName asCollectionOfSubstringsSeparatedBy:$/.
|
|
275 |
components size > 1 ifTrue:[
|
|
276 |
^ (components copyWithoutLast:1) asStringWith:$/
|
|
277 |
].
|
|
278 |
^ fullName
|
|
279 |
|
|
280 |
"Created: / 12.11.1998 / 21:11:30 / cg"
|
|
281 |
! !
|
|
282 |
|
|
283 |
!JavaUnresolvedClassConstant methodsFor:'resolving'!
|
|
284 |
|
|
285 |
preResolve
|
|
286 |
|clsName cls nm ref|
|
|
287 |
|
|
288 |
fullName isNil ifTrue:[
|
|
289 |
"/ first, resolve my name ...
|
|
290 |
|
|
291 |
clsName := constantPool at:nameIndex.
|
|
292 |
"/ DEBUGGING
|
|
293 |
clsName isString ifFalse:[
|
|
294 |
self halt:'oops - no class name string in const pool'.
|
|
295 |
].
|
|
296 |
fullName := clsName
|
|
297 |
].
|
|
298 |
|
|
299 |
"/ try to resolve the class
|
|
300 |
|
|
301 |
(fullName size == 1) ifTrue:[
|
|
302 |
"/ good - this is a primitive
|
|
303 |
ref := JavaBuiltInClassPointerRef class:(JavaDescriptor fromString: fullName) javaClass nameandType:fullName.
|
|
304 |
constantPool at:constantPoolIndex put:ref.
|
|
305 |
^ ref
|
|
306 |
].
|
|
307 |
|
|
308 |
(fullName includes:$[) ifFalse:[
|
|
309 |
cls := Java classNamed:fullName.
|
|
310 |
cls notNil ifTrue:[
|
|
311 |
"/ good - the class is already loaded.
|
|
312 |
constantPool at:constantPoolIndex put:cls.
|
|
313 |
^ cls
|
|
314 |
].
|
|
315 |
] ifTrue:[
|
|
316 |
"
|
|
317 |
Deal with Sun's malformed class refs generated by
|
|
318 |
sun.misc.ProxyGenerator - it generates
|
|
319 |
java/lang/annotation/ElementType[] instead of
|
|
320 |
[Ljava/lang/annotation/ElementType[];
|
|
321 |
as the spec requires!!
|
|
322 |
"
|
|
323 |
(fullName last == $] and:[(fullName at: fullName size - 1) == $[]) ifTrue:
|
|
324 |
[fullName := '[L', (fullName copyTo: fullName size - 2) , ';'].
|
|
325 |
|
|
326 |
(fullName includes: $L) ifFalse:[
|
|
327 |
"/ good - this is a primitive array
|
|
328 |
ref := JavaBuiltInClassPointerRef class:(JavaDescriptor fromString: fullName) javaClass nameandType:fullName.
|
|
329 |
constantPool at:constantPoolIndex put:ref.
|
|
330 |
^ ref
|
|
331 |
].
|
|
332 |
].
|
|
333 |
|
|
334 |
|
|
335 |
(fullName startsWith:$[) ifFalse:[
|
|
336 |
nm := self className.
|
|
337 |
self rememberForResolveWith:nm.
|
|
338 |
].
|
|
339 |
^ self
|
|
340 |
|
|
341 |
"Created: / 15-04-1996 / 15:51:42 / cg"
|
|
342 |
"Modified: / 06-07-1999 / 23:41:04 / cg"
|
|
343 |
"Modified: / 11-02-2011 / 10:41:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
344 |
! !
|
|
345 |
|
|
346 |
!JavaUnresolvedClassConstant class methodsFor:'documentation'!
|
|
347 |
|
|
348 |
version
|
1022
|
349 |
^ '$Id$'
|
752
|
350 |
!
|
|
351 |
|
|
352 |
version_SVN
|
1022
|
353 |
^ '$Id$'
|
1033
|
354 |
! !
|