1
|
1 |
JavaUnresolvedConstant subclass:#JavaUnresolvedClassConstant
|
90
|
2 |
instanceVariableNames:'nameIndex fullName'
|
1
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Java-Reader-Support'
|
|
6 |
!
|
|
7 |
|
|
8 |
|
135
|
9 |
!JavaUnresolvedClassConstant class methodsFor:'instance creation'!
|
1
|
10 |
|
54
|
11 |
fullName:nm
|
90
|
12 |
|ref|
|
|
13 |
|
|
14 |
ref := Java unresolvedClassRefFor:nm.
|
|
15 |
ref notNil ifTrue:[^ ref].
|
|
16 |
|
392
|
17 |
ref := self new setFullName:nm.
|
90
|
18 |
Java rememberUnresolved:ref.
|
|
19 |
^ ref
|
392
|
20 |
|
|
21 |
"Modified: / 19.10.1998 / 20:18:13 / cg"
|
54
|
22 |
!
|
|
23 |
|
313
|
24 |
pool:aPool poolIndex:slotIndex fullName:aString
|
|
25 |
^ self new
|
|
26 |
pool:aPool poolIndex:slotIndex fullName:aString
|
|
27 |
|
|
28 |
"Created: / 4.2.1998 / 22:13:13 / cg"
|
|
29 |
"Modified: / 4.2.1998 / 22:13:28 / cg"
|
|
30 |
!
|
|
31 |
|
90
|
32 |
pool:aPool poolIndex:slotIndex nameIndex:index
|
313
|
33 |
^ self new
|
|
34 |
pool:aPool poolIndex:slotIndex nameIndex:index
|
|
35 |
|
|
36 |
"Modified: / 4.2.1998 / 22:13:38 / cg"
|
21
|
37 |
! !
|
|
38 |
|
|
39 |
!JavaUnresolvedClassConstant methodsFor:'accessing'!
|
|
40 |
|
67
|
41 |
className
|
|
42 |
|s nm|
|
|
43 |
|
|
44 |
(fullName startsWith:$[) ifTrue:[
|
|
45 |
"/ a ref for newarray or new or checkCast
|
|
46 |
|
|
47 |
s := fullName readStream.
|
|
48 |
s next.
|
255
|
49 |
nm := JavaMethod retvalSpecFromStream:s in:nil.
|
67
|
50 |
^ nm
|
|
51 |
].
|
|
52 |
^ fullName
|
|
53 |
|
255
|
54 |
"Modified: / 8.1.1998 / 19:11:37 / cg"
|
67
|
55 |
!
|
|
56 |
|
168
|
57 |
deref
|
271
|
58 |
|refClassName cls|
|
|
59 |
|
|
60 |
(fullName startsWith:'[L') ifTrue:[
|
|
61 |
refClassName := fullName copyFrom:3 to:(fullName indexOf:$;)-1.
|
|
62 |
cls := Java at:refClassName.
|
|
63 |
cls notNil ifTrue:[
|
|
64 |
^ cls
|
|
65 |
].
|
|
66 |
^ JavaUnresolvedClassConstant basicNew setFullName:refClassName
|
168
|
67 |
].
|
317
|
68 |
(fullName startsWith:'[[C') ifTrue:[
|
|
69 |
^ JavaBuiltInClassPointerRef new nameandType:'[C'.
|
|
70 |
].
|
168
|
71 |
|
271
|
72 |
"Created: / 7.4.1997 / 13:38:07 / cg"
|
317
|
73 |
"Modified: / 6.2.1998 / 01:21:01 / cg"
|
168
|
74 |
!
|
|
75 |
|
21
|
76 |
fullName
|
|
77 |
^ fullName
|
|
78 |
|
93
|
79 |
!
|
90
|
80 |
|
|
81 |
javaClass
|
|
82 |
|cls|
|
|
83 |
|
|
84 |
fullName isNil ifTrue:[
|
|
85 |
self halt.
|
|
86 |
].
|
148
|
87 |
^ Java classForName:fullName.
|
90
|
88 |
|
148
|
89 |
"Modified: 18.3.1997 / 16:47:22 / cg"
|
54
|
90 |
!
|
|
91 |
|
136
|
92 |
name
|
360
|
93 |
^ fullName copyReplaceAll:$/ with:$.
|
136
|
94 |
|
360
|
95 |
"Created: / 7.2.1997 / 23:44:47 / cg"
|
|
96 |
"Modified: / 18.7.1998 / 22:57:47 / cg"
|
136
|
97 |
!
|
|
98 |
|
313
|
99 |
pool:aPool poolIndex:slotIndex fullName:aString
|
|
100 |
constantPool := aPool.
|
|
101 |
constantPoolIndex := slotIndex.
|
|
102 |
fullName := aString.
|
|
103 |
|
|
104 |
"Created: / 4.2.1998 / 22:15:22 / cg"
|
|
105 |
!
|
|
106 |
|
90
|
107 |
pool:aPool poolIndex:slotIndex nameIndex:name_index
|
|
108 |
constantPool := aPool.
|
|
109 |
constantPoolIndex := slotIndex.
|
|
110 |
nameIndex := name_index.
|
21
|
111 |
|
168
|
112 |
!
|
|
113 |
|
|
114 |
setFullName:aNameString
|
|
115 |
fullName := aNameString
|
|
116 |
|
|
117 |
"Created: 7.4.1997 / 13:37:45 / cg"
|
|
118 |
!
|
|
119 |
|
|
120 |
smalltalkArrayClass
|
|
121 |
(fullName startsWith:'[[') ifTrue:[
|
|
122 |
^ Array
|
|
123 |
].
|
|
124 |
(fullName startsWith:'[F') ifTrue:[
|
|
125 |
^ FloatArray
|
|
126 |
].
|
|
127 |
(fullName startsWith:'[B') ifTrue:[
|
|
128 |
^ ByteArray
|
|
129 |
].
|
|
130 |
self halt.
|
|
131 |
|
|
132 |
"Created: 7.4.1997 / 13:35:25 / cg"
|
|
133 |
! !
|
|
134 |
|
|
135 |
!JavaUnresolvedClassConstant methodsFor:'converting'!
|
|
136 |
|
|
137 |
asClassPointerRef
|
|
138 |
(fullName startsWith:'[[') ifTrue:[
|
|
139 |
^ JavaClassPointerRef class:Array nameandType:fullName
|
|
140 |
].
|
|
141 |
(fullName startsWith:'[F') ifTrue:[
|
|
142 |
^ JavaClassPointerRef class:FloatArray nameandType:fullName
|
|
143 |
].
|
|
144 |
(fullName startsWith:'[B') ifTrue:[
|
|
145 |
^ JavaClassPointerRef class:ByteArray nameandType:fullName
|
|
146 |
].
|
271
|
147 |
(fullName startsWith:'[C') ifTrue:[
|
|
148 |
^ JavaClassPointerRef class:String nameandType:fullName
|
|
149 |
].
|
168
|
150 |
self halt.
|
|
151 |
|
271
|
152 |
"Created: / 7.4.1997 / 13:40:29 / cg"
|
|
153 |
"Modified: / 25.1.1998 / 19:56:54 / cg"
|
1
|
154 |
! !
|
|
155 |
|
41
|
156 |
!JavaUnresolvedClassConstant methodsFor:'printing & storing'!
|
|
157 |
|
|
158 |
displayString
|
52
|
159 |
fullName isNil ifTrue:[
|
83
|
160 |
^ 'UnresolvedClass(** nil **)'
|
52
|
161 |
].
|
360
|
162 |
^ 'UnresolvedClass(' , (fullName copyReplaceAll:$/ with:$.) , ')'
|
|
163 |
|
|
164 |
"Modified: / 18.7.1998 / 22:57:36 / cg"
|
41
|
165 |
! !
|
|
166 |
|
1
|
167 |
!JavaUnresolvedClassConstant methodsFor:'resolving'!
|
|
168 |
|
90
|
169 |
preResolve
|
|
170 |
|clsName cls nm s ref|
|
|
171 |
|
|
172 |
fullName isNil ifTrue:[
|
|
173 |
"/ first, resolve my name ...
|
|
174 |
|
|
175 |
clsName := constantPool at:nameIndex.
|
|
176 |
"/ DEBUGGING
|
|
177 |
clsName isString ifFalse:[
|
|
178 |
self halt:'oops - no class name string in const pool'.
|
|
179 |
].
|
|
180 |
|
|
181 |
fullName := clsName
|
|
182 |
].
|
|
183 |
|
|
184 |
"/ try to resolve the class
|
|
185 |
|
|
186 |
"/ 'resolve: ' print. fullName printCR.
|
50
|
187 |
|
|
188 |
cls := Java classNamed:fullName.
|
52
|
189 |
cls notNil ifTrue:[
|
90
|
190 |
"/ good - the class is already loaded.
|
|
191 |
|
|
192 |
constantPool at:constantPoolIndex put:cls.
|
|
193 |
^ cls
|
|
194 |
].
|
|
195 |
|
|
196 |
(fullName startsWith:$[) ifTrue:[
|
|
197 |
"/ a ref for newarray or new
|
|
198 |
|
255
|
199 |
nm := JavaMethod retvalSpecFromStream:(ReadStream on:fullName) in:nil.
|
90
|
200 |
[nm endsWith:'[]'] whileTrue:[
|
|
201 |
nm := nm copyWithoutLast:2
|
|
202 |
].
|
|
203 |
|
|
204 |
cls := Java classNamed:nm.
|
|
205 |
cls notNil ifTrue:[
|
|
206 |
ref := JavaClassPointerRef class:cls nameandType:fullName.
|
|
207 |
constantPool at:constantPoolIndex put:ref.
|
|
208 |
^ ref
|
52
|
209 |
].
|
107
|
210 |
|
|
211 |
"/ look for specials like byte[], int[] etc.
|
|
212 |
"/ there are only a few of them - forgive me nameing them here ...
|
|
213 |
fullName = '[B' ifTrue:[ "/ byte[]
|
|
214 |
ref := JavaBuiltInClassPointerRef class:ByteArray nameandType:fullName.
|
|
215 |
constantPool at:constantPoolIndex put:ref.
|
|
216 |
^ ref
|
|
217 |
].
|
252
|
218 |
fullName = '[Z' ifTrue:[ "/ boolean[]
|
|
219 |
ref := JavaBuiltInClassPointerRef class:ByteArray nameandType:fullName.
|
|
220 |
constantPool at:constantPoolIndex put:ref.
|
|
221 |
^ ref
|
|
222 |
].
|
107
|
223 |
fullName = '[I' ifTrue:[ "/ int[]
|
261
|
224 |
ref := JavaBuiltInClassPointerRef class:SignedIntegerArray nameandType:fullName.
|
107
|
225 |
constantPool at:constantPoolIndex put:ref.
|
|
226 |
^ ref
|
|
227 |
].
|
252
|
228 |
fullName = '[J' ifTrue:[ "/ long[]
|
|
229 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
230 |
constantPool at:constantPoolIndex put:ref.
|
|
231 |
^ ref
|
|
232 |
].
|
|
233 |
fullName = '[S' ifTrue:[ "/ short[]
|
261
|
234 |
ref := JavaBuiltInClassPointerRef class:SignedWordArray nameandType:fullName.
|
252
|
235 |
constantPool at:constantPoolIndex put:ref.
|
|
236 |
^ ref
|
|
237 |
].
|
|
238 |
fullName = '[C' ifTrue:[ "/ char[]
|
|
239 |
"/ should be TwoByteString ...
|
|
240 |
ref := JavaBuiltInClassPointerRef class:String nameandType:fullName.
|
|
241 |
constantPool at:constantPoolIndex put:ref.
|
|
242 |
^ ref
|
|
243 |
].
|
|
244 |
fullName = '[F' ifTrue:[ "/ float[]
|
|
245 |
ref := JavaBuiltInClassPointerRef class:FloatArray nameandType:fullName.
|
|
246 |
constantPool at:constantPoolIndex put:ref.
|
|
247 |
^ ref
|
|
248 |
].
|
107
|
249 |
fullName = '[D' ifTrue:[ "/ double[]
|
|
250 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
251 |
constantPool at:constantPoolIndex put:ref.
|
|
252 |
^ ref
|
|
253 |
].
|
|
254 |
fullName = '[[D' ifTrue:[ "/ double[][]
|
|
255 |
ref := JavaBuiltInClassPointerRef class:DoubleArray nameandType:fullName.
|
|
256 |
constantPool at:constantPoolIndex put:ref.
|
|
257 |
^ ref
|
|
258 |
].
|
|
259 |
fullName = '[[I' ifTrue:[ "/ int[][]
|
|
260 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
261 |
constantPool at:constantPoolIndex put:ref.
|
|
262 |
^ ref
|
|
263 |
].
|
|
264 |
(fullName startsWith:'[L') ifFalse:[
|
|
265 |
('JAVA: oops - unresolvable funny class: ' , fullName) errorPrintCR.
|
|
266 |
]
|
52
|
267 |
] ifFalse:[
|
90
|
268 |
nm := self className.
|
50
|
269 |
].
|
90
|
270 |
|
|
271 |
self rememberForResolveWith:nm.
|
|
272 |
^ self
|
|
273 |
|
252
|
274 |
"Created: / 15.4.1996 / 15:51:42 / cg"
|
255
|
275 |
"Modified: / 8.1.1998 / 19:11:43 / cg"
|
90
|
276 |
! !
|
|
277 |
|
135
|
278 |
!JavaUnresolvedClassConstant class methodsFor:'documentation'!
|
1
|
279 |
|
|
280 |
version
|
392
|
281 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedClassConstant.st,v 1.30 1998/10/19 22:40:19 cg Exp $'
|
1
|
282 |
! !
|