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