454
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
|
|
14 |
|
1
|
15 |
JavaUnresolvedConstant subclass:#JavaUnresolvedClassConstant
|
90
|
16 |
instanceVariableNames:'nameIndex fullName'
|
1
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Java-Reader-Support'
|
|
20 |
!
|
|
21 |
|
454
|
22 |
!JavaUnresolvedClassConstant class methodsFor:'documentation'!
|
|
23 |
|
|
24 |
copyright
|
|
25 |
"
|
|
26 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
27 |
All Rights Reserved
|
|
28 |
|
|
29 |
This software is furnished under a license and may be used
|
|
30 |
only in accordance with the terms of that license and with the
|
|
31 |
inclusion of the above copyright notice. This software may not
|
|
32 |
be provided or otherwise made available to, or used by, any
|
|
33 |
other person. No title to or ownership of the software is
|
|
34 |
hereby transferred.
|
|
35 |
"
|
|
36 |
|
|
37 |
|
|
38 |
! !
|
1
|
39 |
|
135
|
40 |
!JavaUnresolvedClassConstant class methodsFor:'instance creation'!
|
1
|
41 |
|
54
|
42 |
fullName:nm
|
90
|
43 |
|ref|
|
|
44 |
|
|
45 |
ref := Java unresolvedClassRefFor:nm.
|
|
46 |
ref notNil ifTrue:[^ ref].
|
|
47 |
|
392
|
48 |
ref := self new setFullName:nm.
|
90
|
49 |
Java rememberUnresolved:ref.
|
|
50 |
^ ref
|
392
|
51 |
|
|
52 |
"Modified: / 19.10.1998 / 20:18:13 / cg"
|
54
|
53 |
!
|
|
54 |
|
313
|
55 |
pool:aPool poolIndex:slotIndex fullName:aString
|
|
56 |
^ self new
|
|
57 |
pool:aPool poolIndex:slotIndex fullName:aString
|
|
58 |
|
|
59 |
"Created: / 4.2.1998 / 22:13:13 / cg"
|
|
60 |
"Modified: / 4.2.1998 / 22:13:28 / cg"
|
|
61 |
!
|
|
62 |
|
90
|
63 |
pool:aPool poolIndex:slotIndex nameIndex:index
|
313
|
64 |
^ self new
|
|
65 |
pool:aPool poolIndex:slotIndex nameIndex:index
|
|
66 |
|
|
67 |
"Modified: / 4.2.1998 / 22:13:38 / cg"
|
21
|
68 |
! !
|
|
69 |
|
|
70 |
!JavaUnresolvedClassConstant methodsFor:'accessing'!
|
|
71 |
|
67
|
72 |
className
|
|
73 |
|s nm|
|
|
74 |
|
|
75 |
(fullName startsWith:$[) ifTrue:[
|
|
76 |
"/ a ref for newarray or new or checkCast
|
|
77 |
|
|
78 |
s := fullName readStream.
|
560
|
79 |
[ s peek == $[ ] whileTrue:[
|
|
80 |
s next.
|
|
81 |
].
|
255
|
82 |
nm := JavaMethod retvalSpecFromStream:s in:nil.
|
67
|
83 |
^ nm
|
|
84 |
].
|
|
85 |
^ fullName
|
|
86 |
|
255
|
87 |
"Modified: / 8.1.1998 / 19:11:37 / cg"
|
67
|
88 |
!
|
|
89 |
|
168
|
90 |
deref
|
271
|
91 |
|refClassName cls|
|
|
92 |
|
|
93 |
(fullName startsWith:'[L') ifTrue:[
|
|
94 |
refClassName := fullName copyFrom:3 to:(fullName indexOf:$;)-1.
|
|
95 |
cls := Java at:refClassName.
|
|
96 |
cls notNil ifTrue:[
|
|
97 |
^ cls
|
|
98 |
].
|
|
99 |
^ JavaUnresolvedClassConstant basicNew setFullName:refClassName
|
168
|
100 |
].
|
317
|
101 |
(fullName startsWith:'[[C') ifTrue:[
|
|
102 |
^ JavaBuiltInClassPointerRef new nameandType:'[C'.
|
|
103 |
].
|
168
|
104 |
|
271
|
105 |
"Created: / 7.4.1997 / 13:38:07 / cg"
|
317
|
106 |
"Modified: / 6.2.1998 / 01:21:01 / cg"
|
168
|
107 |
!
|
|
108 |
|
21
|
109 |
fullName
|
|
110 |
^ fullName
|
|
111 |
|
93
|
112 |
!
|
90
|
113 |
|
|
114 |
javaClass
|
431
|
115 |
|clsName|
|
90
|
116 |
|
|
117 |
fullName isNil ifTrue:[
|
399
|
118 |
self preResolve.
|
|
119 |
fullName isNil ifTrue:[
|
|
120 |
self halt.
|
|
121 |
]
|
90
|
122 |
].
|
431
|
123 |
(fullName startsWith:$[) ifTrue:[
|
|
124 |
clsName := self className
|
|
125 |
] ifFalse:[
|
|
126 |
clsName := fullName
|
|
127 |
].
|
|
128 |
^ Java classForName:clsName.
|
90
|
129 |
|
431
|
130 |
"Modified: / 10.11.1998 / 19:29:28 / cg"
|
54
|
131 |
!
|
|
132 |
|
136
|
133 |
name
|
360
|
134 |
^ fullName copyReplaceAll:$/ with:$.
|
136
|
135 |
|
360
|
136 |
"Created: / 7.2.1997 / 23:44:47 / cg"
|
|
137 |
"Modified: / 18.7.1998 / 22:57:47 / cg"
|
136
|
138 |
!
|
|
139 |
|
313
|
140 |
pool:aPool poolIndex:slotIndex fullName:aString
|
|
141 |
constantPool := aPool.
|
|
142 |
constantPoolIndex := slotIndex.
|
|
143 |
fullName := aString.
|
|
144 |
|
|
145 |
"Created: / 4.2.1998 / 22:15:22 / cg"
|
|
146 |
!
|
|
147 |
|
90
|
148 |
pool:aPool poolIndex:slotIndex nameIndex:name_index
|
|
149 |
constantPool := aPool.
|
|
150 |
constantPoolIndex := slotIndex.
|
|
151 |
nameIndex := name_index.
|
21
|
152 |
|
168
|
153 |
!
|
|
154 |
|
|
155 |
setFullName:aNameString
|
|
156 |
fullName := aNameString
|
|
157 |
|
|
158 |
"Created: 7.4.1997 / 13:37:45 / cg"
|
|
159 |
!
|
|
160 |
|
|
161 |
smalltalkArrayClass
|
|
162 |
(fullName startsWith:'[[') ifTrue:[
|
|
163 |
^ Array
|
|
164 |
].
|
|
165 |
(fullName startsWith:'[F') ifTrue:[
|
|
166 |
^ FloatArray
|
|
167 |
].
|
|
168 |
(fullName startsWith:'[B') ifTrue:[
|
|
169 |
^ ByteArray
|
|
170 |
].
|
|
171 |
self halt.
|
|
172 |
|
|
173 |
"Created: 7.4.1997 / 13:35:25 / cg"
|
|
174 |
! !
|
|
175 |
|
|
176 |
!JavaUnresolvedClassConstant methodsFor:'converting'!
|
|
177 |
|
|
178 |
asClassPointerRef
|
|
179 |
(fullName startsWith:'[[') ifTrue:[
|
|
180 |
^ JavaClassPointerRef class:Array nameandType:fullName
|
|
181 |
].
|
|
182 |
(fullName startsWith:'[F') ifTrue:[
|
|
183 |
^ JavaClassPointerRef class:FloatArray nameandType:fullName
|
|
184 |
].
|
|
185 |
(fullName startsWith:'[B') ifTrue:[
|
|
186 |
^ JavaClassPointerRef class:ByteArray nameandType:fullName
|
|
187 |
].
|
271
|
188 |
(fullName startsWith:'[C') ifTrue:[
|
|
189 |
^ JavaClassPointerRef class:String nameandType:fullName
|
|
190 |
].
|
168
|
191 |
self halt.
|
|
192 |
|
271
|
193 |
"Created: / 7.4.1997 / 13:40:29 / cg"
|
|
194 |
"Modified: / 25.1.1998 / 19:56:54 / cg"
|
1
|
195 |
! !
|
|
196 |
|
41
|
197 |
!JavaUnresolvedClassConstant methodsFor:'printing & storing'!
|
|
198 |
|
|
199 |
displayString
|
52
|
200 |
fullName isNil ifTrue:[
|
83
|
201 |
^ 'UnresolvedClass(** nil **)'
|
52
|
202 |
].
|
360
|
203 |
^ 'UnresolvedClass(' , (fullName copyReplaceAll:$/ with:$.) , ')'
|
|
204 |
|
|
205 |
"Modified: / 18.7.1998 / 22:57:36 / cg"
|
41
|
206 |
! !
|
|
207 |
|
399
|
208 |
!JavaUnresolvedClassConstant methodsFor:'queries'!
|
|
209 |
|
|
210 |
isUnresolvedClass
|
|
211 |
^ true
|
|
212 |
|
|
213 |
"Created: / 20.10.1998 / 17:43:36 / cg"
|
443
|
214 |
!
|
|
215 |
|
|
216 |
package
|
|
217 |
"extract from the fullName"
|
|
218 |
|
|
219 |
|components|
|
|
220 |
|
|
221 |
components := fullName asCollectionOfSubstringsSeparatedBy:$/.
|
|
222 |
components size > 1 ifTrue:[
|
|
223 |
^ (components copyWithoutLast:1) asStringWith:$/
|
|
224 |
].
|
|
225 |
^ fullName
|
|
226 |
|
|
227 |
"Created: / 12.11.1998 / 21:11:30 / cg"
|
399
|
228 |
! !
|
|
229 |
|
1
|
230 |
!JavaUnresolvedClassConstant methodsFor:'resolving'!
|
|
231 |
|
90
|
232 |
preResolve
|
|
233 |
|clsName cls nm s ref|
|
|
234 |
|
|
235 |
fullName isNil ifTrue:[
|
|
236 |
"/ first, resolve my name ...
|
|
237 |
|
|
238 |
clsName := constantPool at:nameIndex.
|
|
239 |
"/ DEBUGGING
|
|
240 |
clsName isString ifFalse:[
|
|
241 |
self halt:'oops - no class name string in const pool'.
|
|
242 |
].
|
|
243 |
|
|
244 |
fullName := clsName
|
|
245 |
].
|
|
246 |
|
|
247 |
"/ try to resolve the class
|
|
248 |
|
|
249 |
"/ 'resolve: ' print. fullName printCR.
|
50
|
250 |
|
|
251 |
cls := Java classNamed:fullName.
|
52
|
252 |
cls notNil ifTrue:[
|
90
|
253 |
"/ good - the class is already loaded.
|
|
254 |
|
|
255 |
constantPool at:constantPoolIndex put:cls.
|
|
256 |
^ cls
|
|
257 |
].
|
|
258 |
|
565
|
259 |
fullName size == 2 ifTrue:[
|
107
|
260 |
"/ look for specials like byte[], int[] etc.
|
|
261 |
"/ there are only a few of them - forgive me nameing them here ...
|
|
262 |
fullName = '[B' ifTrue:[ "/ byte[]
|
|
263 |
ref := JavaBuiltInClassPointerRef class:ByteArray nameandType:fullName.
|
|
264 |
constantPool at:constantPoolIndex put:ref.
|
|
265 |
^ ref
|
|
266 |
].
|
252
|
267 |
fullName = '[Z' ifTrue:[ "/ boolean[]
|
|
268 |
ref := JavaBuiltInClassPointerRef class:ByteArray nameandType:fullName.
|
|
269 |
constantPool at:constantPoolIndex put:ref.
|
|
270 |
^ ref
|
|
271 |
].
|
107
|
272 |
fullName = '[I' ifTrue:[ "/ int[]
|
261
|
273 |
ref := JavaBuiltInClassPointerRef class:SignedIntegerArray nameandType:fullName.
|
107
|
274 |
constantPool at:constantPoolIndex put:ref.
|
|
275 |
^ ref
|
|
276 |
].
|
252
|
277 |
fullName = '[J' ifTrue:[ "/ long[]
|
|
278 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
279 |
constantPool at:constantPoolIndex put:ref.
|
|
280 |
^ ref
|
|
281 |
].
|
|
282 |
fullName = '[S' ifTrue:[ "/ short[]
|
261
|
283 |
ref := JavaBuiltInClassPointerRef class:SignedWordArray nameandType:fullName.
|
252
|
284 |
constantPool at:constantPoolIndex put:ref.
|
|
285 |
^ ref
|
|
286 |
].
|
|
287 |
fullName = '[C' ifTrue:[ "/ char[]
|
|
288 |
"/ should be TwoByteString ...
|
|
289 |
ref := JavaBuiltInClassPointerRef class:String nameandType:fullName.
|
|
290 |
constantPool at:constantPoolIndex put:ref.
|
|
291 |
^ ref
|
|
292 |
].
|
|
293 |
fullName = '[F' ifTrue:[ "/ float[]
|
|
294 |
ref := JavaBuiltInClassPointerRef class:FloatArray nameandType:fullName.
|
|
295 |
constantPool at:constantPoolIndex put:ref.
|
|
296 |
^ ref
|
|
297 |
].
|
107
|
298 |
fullName = '[D' ifTrue:[ "/ double[]
|
538
|
299 |
ref := JavaBuiltInClassPointerRef class:DoubleArray nameandType:fullName.
|
107
|
300 |
constantPool at:constantPoolIndex put:ref.
|
|
301 |
^ ref
|
|
302 |
].
|
565
|
303 |
].
|
|
304 |
|
|
305 |
(fullName startsWith:$[) ifTrue:[
|
|
306 |
"/ a ref for newarray or new
|
|
307 |
|
|
308 |
s := fullName readStream.
|
|
309 |
[s peek == $[ ] whileTrue:[
|
|
310 |
s next
|
|
311 |
].
|
|
312 |
nm := s upToEnd.
|
|
313 |
|
|
314 |
(nm startsWith:$L) ifFalse:[
|
|
315 |
nm = 'F' ifTrue:[ "/ float[][]
|
|
316 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
317 |
constantPool at:constantPoolIndex put:ref.
|
|
318 |
^ ref
|
|
319 |
].
|
|
320 |
nm = 'D' ifTrue:[ "/ double[][]
|
|
321 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
322 |
constantPool at:constantPoolIndex put:ref.
|
|
323 |
^ ref
|
|
324 |
].
|
|
325 |
nm = 'I' ifTrue:[ "/ int[][]
|
|
326 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
327 |
constantPool at:constantPoolIndex put:ref.
|
|
328 |
^ ref
|
|
329 |
].
|
|
330 |
nm = 'C' ifTrue:[ "/ char[][]
|
|
331 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
332 |
constantPool at:constantPoolIndex put:ref.
|
|
333 |
^ ref
|
|
334 |
].
|
|
335 |
nm = 'B' ifTrue:[ "/ byte[][]
|
|
336 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
337 |
constantPool at:constantPoolIndex put:ref.
|
|
338 |
^ ref
|
|
339 |
].
|
|
340 |
nm = 'Z' ifTrue:[ "/ bool[][]
|
|
341 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
342 |
constantPool at:constantPoolIndex put:ref.
|
|
343 |
^ ref
|
|
344 |
].
|
|
345 |
nm = 'S' ifTrue:[ "/ short[][]
|
|
346 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
347 |
constantPool at:constantPoolIndex put:ref.
|
|
348 |
^ ref
|
|
349 |
].
|
|
350 |
self halt.
|
|
351 |
].
|
|
352 |
nm := nm copyFrom:2.
|
|
353 |
(nm endsWith:$;) ifFalse:[
|
|
354 |
self halt.
|
|
355 |
].
|
|
356 |
nm := nm copyWithoutLast:1.
|
|
357 |
|
|
358 |
cls := Java classNamed:nm.
|
|
359 |
cls notNil ifTrue:[
|
|
360 |
ref := JavaClassPointerRef class:cls nameandType:fullName.
|
|
361 |
constantPool at:constantPoolIndex put:ref.
|
|
362 |
^ ref
|
|
363 |
].
|
|
364 |
self rememberForResolveWith:nm.
|
|
365 |
^ self.
|
|
366 |
|
|
367 |
nm := JavaMethod retvalSpecFromStream:(ReadStream on:fullName) in:nil.
|
|
368 |
[nm endsWith:'[]'] whileTrue:[
|
|
369 |
nm := nm copyWithoutLast:2
|
|
370 |
].
|
|
371 |
|
|
372 |
cls := Java classNamed:nm.
|
|
373 |
cls notNil ifTrue:[
|
|
374 |
ref := JavaClassPointerRef class:cls nameandType:fullName.
|
|
375 |
constantPool at:constantPoolIndex put:ref.
|
|
376 |
^ ref
|
|
377 |
].
|
|
378 |
|
554
|
379 |
(fullName startsWith:'[[') ifTrue:[
|
|
380 |
fullName = '[[F' ifTrue:[ "/ float[][]
|
|
381 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
382 |
constantPool at:constantPoolIndex put:ref.
|
|
383 |
^ ref
|
|
384 |
].
|
|
385 |
fullName = '[[D' ifTrue:[ "/ double[][]
|
|
386 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
387 |
constantPool at:constantPoolIndex put:ref.
|
|
388 |
^ ref
|
|
389 |
].
|
|
390 |
fullName = '[[I' ifTrue:[ "/ int[][]
|
|
391 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
392 |
constantPool at:constantPoolIndex put:ref.
|
|
393 |
^ ref
|
|
394 |
].
|
|
395 |
fullName = '[[C' ifTrue:[ "/ char[][]
|
|
396 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
397 |
constantPool at:constantPoolIndex put:ref.
|
|
398 |
^ ref
|
|
399 |
].
|
|
400 |
fullName = '[[B' ifTrue:[ "/ byte[][]
|
|
401 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
402 |
constantPool at:constantPoolIndex put:ref.
|
|
403 |
^ ref
|
|
404 |
].
|
|
405 |
fullName = '[[Z' ifTrue:[ "/ bool[][]
|
|
406 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
407 |
constantPool at:constantPoolIndex put:ref.
|
|
408 |
^ ref
|
|
409 |
].
|
|
410 |
fullName = '[[S' ifTrue:[ "/ short[][]
|
|
411 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
412 |
constantPool at:constantPoolIndex put:ref.
|
|
413 |
^ ref
|
|
414 |
].
|
552
|
415 |
].
|
107
|
416 |
(fullName startsWith:'[L') ifFalse:[
|
538
|
417 |
(fullName startsWith:'[[L') ifFalse:[
|
|
418 |
('JAVA: oops - unresolvable funny class: ' , fullName) errorPrintCR.
|
|
419 |
self halt.
|
|
420 |
]
|
107
|
421 |
]
|
52
|
422 |
] ifFalse:[
|
90
|
423 |
nm := self className.
|
50
|
424 |
].
|
90
|
425 |
|
|
426 |
self rememberForResolveWith:nm.
|
|
427 |
^ self
|
|
428 |
|
252
|
429 |
"Created: / 15.4.1996 / 15:51:42 / cg"
|
568
|
430 |
"Modified: / 6.7.1999 / 23:41:04 / cg"
|
90
|
431 |
! !
|
|
432 |
|
135
|
433 |
!JavaUnresolvedClassConstant class methodsFor:'documentation'!
|
1
|
434 |
|
|
435 |
version
|
568
|
436 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedClassConstant.st,v 1.41 1999/07/06 21:40:01 cg Exp $'
|
1
|
437 |
! !
|