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.
|
|
79 |
s next.
|
255
|
80 |
nm := JavaMethod retvalSpecFromStream:s in:nil.
|
67
|
81 |
^ nm
|
|
82 |
].
|
|
83 |
^ fullName
|
|
84 |
|
255
|
85 |
"Modified: / 8.1.1998 / 19:11:37 / cg"
|
67
|
86 |
!
|
|
87 |
|
168
|
88 |
deref
|
271
|
89 |
|refClassName cls|
|
|
90 |
|
|
91 |
(fullName startsWith:'[L') ifTrue:[
|
|
92 |
refClassName := fullName copyFrom:3 to:(fullName indexOf:$;)-1.
|
|
93 |
cls := Java at:refClassName.
|
|
94 |
cls notNil ifTrue:[
|
|
95 |
^ cls
|
|
96 |
].
|
|
97 |
^ JavaUnresolvedClassConstant basicNew setFullName:refClassName
|
168
|
98 |
].
|
317
|
99 |
(fullName startsWith:'[[C') ifTrue:[
|
|
100 |
^ JavaBuiltInClassPointerRef new nameandType:'[C'.
|
|
101 |
].
|
168
|
102 |
|
271
|
103 |
"Created: / 7.4.1997 / 13:38:07 / cg"
|
317
|
104 |
"Modified: / 6.2.1998 / 01:21:01 / cg"
|
168
|
105 |
!
|
|
106 |
|
21
|
107 |
fullName
|
|
108 |
^ fullName
|
|
109 |
|
93
|
110 |
!
|
90
|
111 |
|
|
112 |
javaClass
|
431
|
113 |
|clsName|
|
90
|
114 |
|
|
115 |
fullName isNil ifTrue:[
|
399
|
116 |
self preResolve.
|
|
117 |
fullName isNil ifTrue:[
|
|
118 |
self halt.
|
|
119 |
]
|
90
|
120 |
].
|
431
|
121 |
(fullName startsWith:$[) ifTrue:[
|
|
122 |
clsName := self className
|
|
123 |
] ifFalse:[
|
|
124 |
clsName := fullName
|
|
125 |
].
|
|
126 |
^ Java classForName:clsName.
|
90
|
127 |
|
431
|
128 |
"Modified: / 10.11.1998 / 19:29:28 / cg"
|
54
|
129 |
!
|
|
130 |
|
136
|
131 |
name
|
360
|
132 |
^ fullName copyReplaceAll:$/ with:$.
|
136
|
133 |
|
360
|
134 |
"Created: / 7.2.1997 / 23:44:47 / cg"
|
|
135 |
"Modified: / 18.7.1998 / 22:57:47 / cg"
|
136
|
136 |
!
|
|
137 |
|
313
|
138 |
pool:aPool poolIndex:slotIndex fullName:aString
|
|
139 |
constantPool := aPool.
|
|
140 |
constantPoolIndex := slotIndex.
|
|
141 |
fullName := aString.
|
|
142 |
|
|
143 |
"Created: / 4.2.1998 / 22:15:22 / cg"
|
|
144 |
!
|
|
145 |
|
90
|
146 |
pool:aPool poolIndex:slotIndex nameIndex:name_index
|
|
147 |
constantPool := aPool.
|
|
148 |
constantPoolIndex := slotIndex.
|
|
149 |
nameIndex := name_index.
|
21
|
150 |
|
168
|
151 |
!
|
|
152 |
|
|
153 |
setFullName:aNameString
|
|
154 |
fullName := aNameString
|
|
155 |
|
|
156 |
"Created: 7.4.1997 / 13:37:45 / cg"
|
|
157 |
!
|
|
158 |
|
|
159 |
smalltalkArrayClass
|
|
160 |
(fullName startsWith:'[[') ifTrue:[
|
|
161 |
^ Array
|
|
162 |
].
|
|
163 |
(fullName startsWith:'[F') ifTrue:[
|
|
164 |
^ FloatArray
|
|
165 |
].
|
|
166 |
(fullName startsWith:'[B') ifTrue:[
|
|
167 |
^ ByteArray
|
|
168 |
].
|
|
169 |
self halt.
|
|
170 |
|
|
171 |
"Created: 7.4.1997 / 13:35:25 / cg"
|
|
172 |
! !
|
|
173 |
|
|
174 |
!JavaUnresolvedClassConstant methodsFor:'converting'!
|
|
175 |
|
|
176 |
asClassPointerRef
|
|
177 |
(fullName startsWith:'[[') ifTrue:[
|
|
178 |
^ JavaClassPointerRef class:Array nameandType:fullName
|
|
179 |
].
|
|
180 |
(fullName startsWith:'[F') ifTrue:[
|
|
181 |
^ JavaClassPointerRef class:FloatArray nameandType:fullName
|
|
182 |
].
|
|
183 |
(fullName startsWith:'[B') ifTrue:[
|
|
184 |
^ JavaClassPointerRef class:ByteArray nameandType:fullName
|
|
185 |
].
|
271
|
186 |
(fullName startsWith:'[C') ifTrue:[
|
|
187 |
^ JavaClassPointerRef class:String nameandType:fullName
|
|
188 |
].
|
168
|
189 |
self halt.
|
|
190 |
|
271
|
191 |
"Created: / 7.4.1997 / 13:40:29 / cg"
|
|
192 |
"Modified: / 25.1.1998 / 19:56:54 / cg"
|
1
|
193 |
! !
|
|
194 |
|
41
|
195 |
!JavaUnresolvedClassConstant methodsFor:'printing & storing'!
|
|
196 |
|
|
197 |
displayString
|
52
|
198 |
fullName isNil ifTrue:[
|
83
|
199 |
^ 'UnresolvedClass(** nil **)'
|
52
|
200 |
].
|
360
|
201 |
^ 'UnresolvedClass(' , (fullName copyReplaceAll:$/ with:$.) , ')'
|
|
202 |
|
|
203 |
"Modified: / 18.7.1998 / 22:57:36 / cg"
|
41
|
204 |
! !
|
|
205 |
|
399
|
206 |
!JavaUnresolvedClassConstant methodsFor:'queries'!
|
|
207 |
|
|
208 |
isUnresolvedClass
|
|
209 |
^ true
|
|
210 |
|
|
211 |
"Created: / 20.10.1998 / 17:43:36 / cg"
|
443
|
212 |
!
|
|
213 |
|
|
214 |
package
|
|
215 |
"extract from the fullName"
|
|
216 |
|
|
217 |
|components|
|
|
218 |
|
|
219 |
components := fullName asCollectionOfSubstringsSeparatedBy:$/.
|
|
220 |
components size > 1 ifTrue:[
|
|
221 |
^ (components copyWithoutLast:1) asStringWith:$/
|
|
222 |
].
|
|
223 |
^ fullName
|
|
224 |
|
|
225 |
"Created: / 12.11.1998 / 21:11:30 / cg"
|
399
|
226 |
! !
|
|
227 |
|
1
|
228 |
!JavaUnresolvedClassConstant methodsFor:'resolving'!
|
|
229 |
|
90
|
230 |
preResolve
|
|
231 |
|clsName cls nm s ref|
|
|
232 |
|
|
233 |
fullName isNil ifTrue:[
|
|
234 |
"/ first, resolve my name ...
|
|
235 |
|
|
236 |
clsName := constantPool at:nameIndex.
|
|
237 |
"/ DEBUGGING
|
|
238 |
clsName isString ifFalse:[
|
|
239 |
self halt:'oops - no class name string in const pool'.
|
|
240 |
].
|
|
241 |
|
|
242 |
fullName := clsName
|
|
243 |
].
|
|
244 |
|
|
245 |
"/ try to resolve the class
|
|
246 |
|
|
247 |
"/ 'resolve: ' print. fullName printCR.
|
50
|
248 |
|
|
249 |
cls := Java classNamed:fullName.
|
52
|
250 |
cls notNil ifTrue:[
|
90
|
251 |
"/ good - the class is already loaded.
|
|
252 |
|
|
253 |
constantPool at:constantPoolIndex put:cls.
|
|
254 |
^ cls
|
|
255 |
].
|
|
256 |
|
|
257 |
(fullName startsWith:$[) ifTrue:[
|
|
258 |
"/ a ref for newarray or new
|
|
259 |
|
255
|
260 |
nm := JavaMethod retvalSpecFromStream:(ReadStream on:fullName) in:nil.
|
90
|
261 |
[nm endsWith:'[]'] whileTrue:[
|
|
262 |
nm := nm copyWithoutLast:2
|
|
263 |
].
|
|
264 |
|
|
265 |
cls := Java classNamed:nm.
|
|
266 |
cls notNil ifTrue:[
|
|
267 |
ref := JavaClassPointerRef class:cls nameandType:fullName.
|
|
268 |
constantPool at:constantPoolIndex put:ref.
|
|
269 |
^ ref
|
52
|
270 |
].
|
107
|
271 |
|
|
272 |
"/ look for specials like byte[], int[] etc.
|
|
273 |
"/ there are only a few of them - forgive me nameing them here ...
|
|
274 |
fullName = '[B' ifTrue:[ "/ byte[]
|
|
275 |
ref := JavaBuiltInClassPointerRef class:ByteArray nameandType:fullName.
|
|
276 |
constantPool at:constantPoolIndex put:ref.
|
|
277 |
^ ref
|
|
278 |
].
|
252
|
279 |
fullName = '[Z' ifTrue:[ "/ boolean[]
|
|
280 |
ref := JavaBuiltInClassPointerRef class:ByteArray nameandType:fullName.
|
|
281 |
constantPool at:constantPoolIndex put:ref.
|
|
282 |
^ ref
|
|
283 |
].
|
107
|
284 |
fullName = '[I' ifTrue:[ "/ int[]
|
261
|
285 |
ref := JavaBuiltInClassPointerRef class:SignedIntegerArray nameandType:fullName.
|
107
|
286 |
constantPool at:constantPoolIndex put:ref.
|
|
287 |
^ ref
|
|
288 |
].
|
252
|
289 |
fullName = '[J' ifTrue:[ "/ long[]
|
|
290 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
291 |
constantPool at:constantPoolIndex put:ref.
|
|
292 |
^ ref
|
|
293 |
].
|
|
294 |
fullName = '[S' ifTrue:[ "/ short[]
|
261
|
295 |
ref := JavaBuiltInClassPointerRef class:SignedWordArray nameandType:fullName.
|
252
|
296 |
constantPool at:constantPoolIndex put:ref.
|
|
297 |
^ ref
|
|
298 |
].
|
|
299 |
fullName = '[C' ifTrue:[ "/ char[]
|
|
300 |
"/ should be TwoByteString ...
|
|
301 |
ref := JavaBuiltInClassPointerRef class:String nameandType:fullName.
|
|
302 |
constantPool at:constantPoolIndex put:ref.
|
|
303 |
^ ref
|
|
304 |
].
|
|
305 |
fullName = '[F' ifTrue:[ "/ float[]
|
|
306 |
ref := JavaBuiltInClassPointerRef class:FloatArray nameandType:fullName.
|
|
307 |
constantPool at:constantPoolIndex put:ref.
|
|
308 |
^ ref
|
|
309 |
].
|
107
|
310 |
fullName = '[D' ifTrue:[ "/ double[]
|
538
|
311 |
ref := JavaBuiltInClassPointerRef class:DoubleArray nameandType:fullName.
|
107
|
312 |
constantPool at:constantPoolIndex put:ref.
|
|
313 |
^ ref
|
|
314 |
].
|
|
315 |
fullName = '[[D' ifTrue:[ "/ double[][]
|
538
|
316 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
107
|
317 |
constantPool at:constantPoolIndex put:ref.
|
|
318 |
^ ref
|
|
319 |
].
|
|
320 |
fullName = '[[I' ifTrue:[ "/ int[][]
|
|
321 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
322 |
constantPool at:constantPoolIndex put:ref.
|
|
323 |
^ ref
|
|
324 |
].
|
495
|
325 |
fullName = '[[C' ifTrue:[ "/ char[][]
|
|
326 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
327 |
constantPool at:constantPoolIndex put:ref.
|
|
328 |
^ ref
|
|
329 |
].
|
538
|
330 |
fullName = '[[Z' ifTrue:[ "/ bool[][]
|
|
331 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
332 |
constantPool at:constantPoolIndex put:ref.
|
|
333 |
^ ref
|
|
334 |
].
|
107
|
335 |
(fullName startsWith:'[L') ifFalse:[
|
538
|
336 |
(fullName startsWith:'[[L') ifFalse:[
|
|
337 |
('JAVA: oops - unresolvable funny class: ' , fullName) errorPrintCR.
|
|
338 |
self halt.
|
|
339 |
]
|
107
|
340 |
]
|
52
|
341 |
] ifFalse:[
|
90
|
342 |
nm := self className.
|
50
|
343 |
].
|
90
|
344 |
|
|
345 |
self rememberForResolveWith:nm.
|
|
346 |
^ self
|
|
347 |
|
252
|
348 |
"Created: / 15.4.1996 / 15:51:42 / cg"
|
538
|
349 |
"Modified: / 9.1.1999 / 15:00:30 / cg"
|
90
|
350 |
! !
|
|
351 |
|
135
|
352 |
!JavaUnresolvedClassConstant class methodsFor:'documentation'!
|
1
|
353 |
|
|
354 |
version
|
538
|
355 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedClassConstant.st,v 1.36 1999/01/10 17:20:37 cg Exp $'
|
1
|
356 |
! !
|