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