172
|
1 |
Class subclass:#JavaClass
|
73
|
2 |
instanceVariableNames:'fullName accessFlags constantPool sourceFile binaryFilePath
|
110
|
3 |
fields initialized initValues staticFields hasUnresolvedConstants
|
|
4 |
interfaces'
|
52
|
5 |
classVariableNames:'InitialValuePerType'
|
1
|
6 |
poolDictionaries:''
|
|
7 |
category:'Java-Classes'
|
|
8 |
!
|
|
9 |
|
133
|
10 |
!JavaClass class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
examples
|
|
13 |
"
|
|
14 |
(Java at:'java.util.Stack') new inspect
|
|
15 |
(Java at:'java.util.Vector') new inspect
|
|
16 |
"
|
|
17 |
! !
|
1
|
18 |
|
130
|
19 |
!JavaClass class methodsFor:'initialization'!
|
52
|
20 |
|
|
21 |
initialize
|
|
22 |
InitialValuePerType := IdentityDictionary new.
|
|
23 |
InitialValuePerType at:$B put:0.
|
|
24 |
InitialValuePerType at:$C put:0.
|
|
25 |
InitialValuePerType at:$D put:0.0.
|
|
26 |
InitialValuePerType at:$F put:0.0 asShortFloat.
|
|
27 |
InitialValuePerType at:$I put:0.
|
|
28 |
InitialValuePerType at:$J put:0.
|
|
29 |
InitialValuePerType at:$S put:0.
|
|
30 |
InitialValuePerType at:$Z put:0.
|
|
31 |
InitialValuePerType at:$L put:nil.
|
|
32 |
InitialValuePerType at:$[ put:nil.
|
|
33 |
|
|
34 |
"
|
|
35 |
JavaClass initialize
|
|
36 |
"
|
|
37 |
! !
|
|
38 |
|
130
|
39 |
!JavaClass class methodsFor:'instance creation'!
|
1
|
40 |
|
7
|
41 |
fullName:aString
|
90
|
42 |
self shouldNotImplement.
|
|
43 |
^ self new flags:0; setFullName:aString
|
7
|
44 |
|
|
45 |
!
|
|
46 |
|
38
|
47 |
fullName:aString numStatic:nStatic
|
181
|
48 |
|meta cls fullName parts s ns|
|
38
|
49 |
|
130
|
50 |
"/ check for a JAVA nameSpace to exist
|
|
51 |
JAVA isNil ifTrue:[
|
181
|
52 |
Namespace name:'JAVA'
|
130
|
53 |
].
|
|
54 |
|
38
|
55 |
"create the metaclass first"
|
|
56 |
|
40
|
57 |
meta := Metaclass new.
|
|
58 |
meta setSuperclass:(self).
|
130
|
59 |
meta instSize:(JavaClass instSize + nStatic).
|
172
|
60 |
"/ meta setName:(aString , 'class') asSymbol.
|
|
61 |
"/ meta setClassVariableString:''.
|
38
|
62 |
|
|
63 |
"then let the new meta create the class"
|
|
64 |
cls := meta new.
|
|
65 |
cls setSuperclass:JavaObject.
|
|
66 |
cls instSize:0.
|
130
|
67 |
cls setName:('JAVA::' , aString).
|
38
|
68 |
cls flags:0.
|
40
|
69 |
"/ cls setClassVariableString:''.
|
38
|
70 |
cls setInstanceVariableString:''.
|
|
71 |
cls category:#java.
|
40
|
72 |
|
|
73 |
cls setFullName:aString.
|
130
|
74 |
|
181
|
75 |
"/ break up the package and create nameSpaces
|
|
76 |
"/ for each package component.
|
|
77 |
"/ This allows java.foo.bar to be visible in ST/X
|
|
78 |
"/ under the name JAVA::java::foo::bar
|
|
79 |
|
|
80 |
ns := JAVA.
|
|
81 |
|
|
82 |
parts := aString asCollectionOfSubstringsSeparatedBy:$/.
|
|
83 |
parts size > 1 ifTrue:[
|
|
84 |
s := '' writeStream.
|
|
85 |
s nextPutAll:'JAVA'.
|
|
86 |
parts from:1 to:(parts size - 1) do:[:aPart |
|
|
87 |
s nextPutAll:'::'.
|
|
88 |
s nextPutAll:aPart
|
|
89 |
].
|
|
90 |
Metaclass confirmationQuerySignal answer:false do:[
|
|
91 |
Class updateChangeFileQuerySignal answer:false do:[
|
|
92 |
ns := Namespace fullName:(s contents).
|
|
93 |
]
|
|
94 |
]
|
|
95 |
].
|
197
|
96 |
ns isNamespace ifTrue:[
|
|
97 |
ns at:parts last asSymbol put:cls.
|
|
98 |
].
|
181
|
99 |
|
|
100 |
"/ for ST/X browsing
|
130
|
101 |
Smalltalk at:('JAVA::' , aString) asSymbol put:cls.
|
|
102 |
|
38
|
103 |
^ cls
|
|
104 |
|
|
105 |
"Created: 15.4.1996 / 15:52:55 / cg"
|
197
|
106 |
"Modified: 3.8.1997 / 17:01:15 / cg"
|
38
|
107 |
!
|
|
108 |
|
1
|
109 |
name:aString
|
7
|
110 |
self shouldNotImplement
|
1
|
111 |
|
|
112 |
"Created: 15.4.1996 / 15:52:55 / cg"
|
|
113 |
! !
|
|
114 |
|
130
|
115 |
!JavaClass class methodsFor:'signature parsing'!
|
52
|
116 |
|
|
117 |
initialValueFromSignature:aSignature
|
|
118 |
"given a signature, return an initializer value"
|
|
119 |
|
|
120 |
|s|
|
|
121 |
|
|
122 |
s := aSignature readStream.
|
|
123 |
^ self initialValueFromStream:s.
|
|
124 |
|
|
125 |
"
|
|
126 |
JavaClass initialValueFromSignature:'LObject;'
|
|
127 |
JavaClass initialValueFromSignature:'B'
|
|
128 |
JavaClass initialValueFromSignature:'I'
|
|
129 |
"
|
|
130 |
|
|
131 |
|
|
132 |
!
|
|
133 |
|
|
134 |
initialValueFromStream:s
|
|
135 |
"parse a fieldTypeSpec - see java doc"
|
|
136 |
|
|
137 |
|typeChar|
|
|
138 |
|
|
139 |
typeChar := s next.
|
|
140 |
^ InitialValuePerType at:typeChar ifAbsent:nil.
|
|
141 |
! !
|
|
142 |
|
130
|
143 |
!JavaClass class methodsFor:'special'!
|
40
|
144 |
|
|
145 |
setInstanceVariableStringFromFields:f in:aClass
|
|
146 |
|varNames|
|
|
147 |
|
|
148 |
varNames := ''.
|
|
149 |
f do:[:aField |
|
172
|
150 |
varNames := varNames , aField name , ' '
|
40
|
151 |
].
|
|
152 |
aClass setInstanceVariableString:varNames.
|
|
153 |
|
|
154 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
|
155 |
! !
|
|
156 |
|
5
|
157 |
!JavaClass methodsFor:'accessing'!
|
|
158 |
|
74
|
159 |
binaryFile
|
|
160 |
^ binaryFilePath
|
|
161 |
|
|
162 |
|
|
163 |
!
|
|
164 |
|
7
|
165 |
category
|
|
166 |
"java classes do not really hav a category;
|
|
167 |
simulate one by separating its name into individual components,
|
|
168 |
prepending 'java'"
|
|
169 |
|
|
170 |
|nameComponents|
|
|
171 |
|
|
172 |
nameComponents := fullName asCollectionOfSubstringsSeparatedBy:$/.
|
160
|
173 |
nameComponents size <= 1 ifTrue:[
|
175
|
174 |
^ 'java' "/ fullName
|
160
|
175 |
].
|
|
176 |
^ ((nameComponents asStringWith:$/ from:1 to:(nameComponents size - 1))) replaceAll:$/ by:$.
|
|
177 |
|
175
|
178 |
"Modified: 30.7.1997 / 15:35:22 / cg"
|
7
|
179 |
!
|
|
180 |
|
185
|
181 |
compiledMethodAt:name signature:sig
|
|
182 |
"lookup the classes methodDictionary"
|
|
183 |
|
|
184 |
methodDictionary keysAndValuesDo:[:mFullSelector :aMethod |
|
|
185 |
aMethod name == name ifTrue:[
|
|
186 |
aMethod signature == sig ifTrue:[
|
|
187 |
^ aMethod
|
|
188 |
]
|
|
189 |
]
|
|
190 |
].
|
|
191 |
^ nil
|
|
192 |
|
|
193 |
"Created: 1.8.1997 / 00:01:58 / cg"
|
|
194 |
!
|
|
195 |
|
5
|
196 |
constantPool
|
|
197 |
^ constantPool
|
7
|
198 |
!
|
|
199 |
|
83
|
200 |
fields
|
|
201 |
^ fields
|
|
202 |
!
|
|
203 |
|
7
|
204 |
fullName
|
|
205 |
^ fullName
|
8
|
206 |
!
|
|
207 |
|
110
|
208 |
interfaces
|
|
209 |
interfaces notNil ifTrue:[
|
172
|
210 |
interfaces := interfaces collect:[:clsRef |
|
|
211 |
clsRef isUnresolved ifTrue:[
|
|
212 |
clsRef preResolve
|
|
213 |
] ifFalse:[
|
|
214 |
clsRef
|
|
215 |
]
|
|
216 |
].
|
110
|
217 |
].
|
|
218 |
^ interfaces
|
|
219 |
!
|
|
220 |
|
90
|
221 |
javaClass
|
|
222 |
^ self
|
|
223 |
!
|
|
224 |
|
8
|
225 |
name
|
27
|
226 |
^ name "/ fullName
|
22
|
227 |
!
|
|
228 |
|
130
|
229 |
nameSpace
|
|
230 |
^ JAVA
|
|
231 |
|
|
232 |
"Created: 20.1.1997 / 13:04:30 / cg"
|
|
233 |
!
|
|
234 |
|
|
235 |
nameWithoutNameSpacePrefix
|
|
236 |
^ fullName
|
|
237 |
|
|
238 |
"Created: 20.1.1997 / 13:05:30 / cg"
|
|
239 |
!
|
|
240 |
|
|
241 |
nameWithoutPrefix
|
|
242 |
^ fullName
|
|
243 |
|
|
244 |
"Created: 20.1.1997 / 13:06:06 / cg"
|
|
245 |
!
|
|
246 |
|
22
|
247 |
package
|
|
248 |
"extract from the fullName"
|
|
249 |
|
|
250 |
|components|
|
|
251 |
|
|
252 |
components := fullName asCollectionOfSubstringsSeparatedBy:$/.
|
24
|
253 |
components size > 1 ifTrue:[
|
172
|
254 |
^ (components copyWithoutLast:1) asStringWith:$/
|
24
|
255 |
].
|
|
256 |
^ fullName
|
22
|
257 |
|
|
258 |
"
|
|
259 |
Java allClasses first fullName
|
|
260 |
Java allClasses first package
|
|
261 |
"
|
24
|
262 |
!
|
|
263 |
|
76
|
264 |
source
|
|
265 |
^ Java classSourceOf:self
|
|
266 |
|
|
267 |
"
|
|
268 |
(Java at:'java.awt.Frame') source
|
175
|
269 |
(Java at:'ArcTest') source
|
|
270 |
(Java at:'ArcCanvas') source
|
76
|
271 |
"
|
175
|
272 |
|
|
273 |
"Modified: 30.7.1997 / 14:31:01 / cg"
|
76
|
274 |
!
|
|
275 |
|
24
|
276 |
sourceFile
|
|
277 |
^ sourceFile
|
83
|
278 |
!
|
|
279 |
|
|
280 |
staticFields
|
|
281 |
^ staticFields
|
132
|
282 |
!
|
|
283 |
|
|
284 |
typeOfField:aFieldName
|
|
285 |
|
|
286 |
fields do:[:aField |
|
172
|
287 |
aField name = aFieldName ifTrue:[
|
|
288 |
^ aField type
|
|
289 |
]
|
132
|
290 |
].
|
|
291 |
self error:'no such field'
|
|
292 |
|
|
293 |
"
|
|
294 |
(JAVA at:#'java/awt/image/ColorModel') typeOfField:'pixel_bits'
|
|
295 |
"
|
|
296 |
|
|
297 |
"Modified: 21.1.1997 / 22:48:28 / cg"
|
5
|
298 |
! !
|
|
299 |
|
213
|
300 |
!JavaClass methodsFor:'adding / removing'!
|
|
301 |
|
|
302 |
removeFromSystem
|
|
303 |
Java removeClass:self
|
|
304 |
|
|
305 |
"Created: 12.8.1997 / 02:46:51 / cg"
|
|
306 |
! !
|
|
307 |
|
183
|
308 |
!JavaClass methodsFor:'compiler interface'!
|
|
309 |
|
|
310 |
compilerClass
|
|
311 |
"return the compiler to use for this class -
|
|
312 |
this can be redefined in special classes, to get classes with
|
|
313 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
|
|
314 |
|
197
|
315 |
^ Compiler.
|
|
316 |
|
183
|
317 |
^ JavaCompiler
|
|
318 |
|
|
319 |
"Created: 31.7.1997 / 23:03:37 / cg"
|
197
|
320 |
"Modified: 4.8.1997 / 16:50:08 / cg"
|
183
|
321 |
!
|
|
322 |
|
|
323 |
evaluatorClass
|
|
324 |
"return the compiler to use for expression evaluation for this class -
|
|
325 |
this can be redefined in special classes, to get classes with
|
|
326 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
|
|
327 |
|
197
|
328 |
^ Compiler.
|
|
329 |
|
183
|
330 |
^ JavaCompiler
|
|
331 |
|
|
332 |
"Created: 31.7.1997 / 23:03:56 / cg"
|
197
|
333 |
"Modified: 4.8.1997 / 16:49:14 / cg"
|
183
|
334 |
!
|
|
335 |
|
|
336 |
parserClass
|
|
337 |
"return the parser to use for parsing this class -
|
|
338 |
this can be redefined in special classes, to get classes with
|
|
339 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
|
|
340 |
|
197
|
341 |
^ Compiler.
|
|
342 |
|
183
|
343 |
^ JavaCompiler
|
|
344 |
|
|
345 |
"Created: 31.7.1997 / 23:04:11 / cg"
|
197
|
346 |
"Modified: 4.8.1997 / 16:50:18 / cg"
|
183
|
347 |
! !
|
|
348 |
|
160
|
349 |
!JavaClass methodsFor:'documentation support'!
|
|
350 |
|
|
351 |
htmlDocumentation
|
|
352 |
^ nil "/ replace by access to javadoc-generated documentation later
|
|
353 |
|
|
354 |
"Modified: 22.3.1997 / 14:18:50 / cg"
|
|
355 |
! !
|
|
356 |
|
130
|
357 |
!JavaClass methodsFor:'fileOut'!
|
|
358 |
|
160
|
359 |
basicFileOutDefinitionOn:aStream withNameSpace:nameSpaceBoolean
|
|
360 |
JavaDecompiler definitionOf:self on:aStream
|
|
361 |
|
|
362 |
"Modified: 22.3.1997 / 14:30:28 / cg"
|
|
363 |
!
|
130
|
364 |
|
160
|
365 |
fileOut
|
|
366 |
self warn:'fileOut not yet supported'
|
|
367 |
|
|
368 |
"Modified: 22.3.1997 / 14:30:28 / cg"
|
|
369 |
"Created: 22.3.1997 / 14:35:43 / cg"
|
130
|
370 |
! !
|
|
371 |
|
43
|
372 |
!JavaClass methodsFor:'java initialization'!
|
|
373 |
|
|
374 |
classInit
|
|
375 |
"call the classes JAVA clinit function"
|
|
376 |
|
63
|
377 |
|m|
|
43
|
378 |
|
|
379 |
initialized := true.
|
|
380 |
|
63
|
381 |
m := self compiledMethodAt:#'<clinit>()V'.
|
|
382 |
m notNil ifTrue:[
|
90
|
383 |
"/ 'calling clinit() of ' print. self fullName printNL.
|
175
|
384 |
[
|
|
385 |
self
|
|
386 |
invokeJavaMethod:m
|
|
387 |
sender:thisContext
|
|
388 |
selector:#'<clinit>()V'.
|
|
389 |
] valueOnUnwindDo:[
|
|
390 |
initialized := false
|
|
391 |
]
|
43
|
392 |
] ifFalse:[
|
71
|
393 |
"/ self fullName print. ' has no clinit()' printNL.
|
43
|
394 |
].
|
|
395 |
|
|
396 |
"
|
|
397 |
JavaInterpreter instructionTrace:true.
|
|
398 |
JavaInterpreter callTrace:true.
|
|
399 |
|
|
400 |
(Java classNamed:'java.lang.String') classInit
|
|
401 |
(Java classNamed:'java.lang.System') classInit
|
|
402 |
|
|
403 |
(Java classNamed:'java/io/FileDescriptor') classInit
|
|
404 |
(Java classNamed:'java.util.Properties') classInit
|
|
405 |
"
|
175
|
406 |
|
|
407 |
"Modified: 30.7.1997 / 13:28:38 / cg"
|
60
|
408 |
!
|
|
409 |
|
195
|
410 |
initializeIfNotYetDone
|
|
411 |
"if not yet done, call the classes JAVA clinit function"
|
|
412 |
|
|
413 |
initialized ~~ true ifTrue:[
|
|
414 |
self classInit
|
|
415 |
]
|
|
416 |
|
|
417 |
"Created: 1.8.1997 / 22:37:40 / cg"
|
|
418 |
!
|
|
419 |
|
60
|
420 |
initializeStaticFields
|
90
|
421 |
staticFields isNil ifTrue:[^ self].
|
|
422 |
|
60
|
423 |
staticFields do:[:f |
|
172
|
424 |
|val type|
|
86
|
425 |
|
172
|
426 |
(val := f constantValue) isNil ifTrue:[
|
|
427 |
"/ careful: int/long etc. constants must be initialized
|
|
428 |
"/ with correct type.
|
|
429 |
type := f type.
|
|
430 |
type == #long ifTrue:[
|
|
431 |
val := 0.
|
|
432 |
] ifFalse:[type == #int ifTrue:[
|
|
433 |
val := 0.
|
|
434 |
] ifFalse:[type == #float ifTrue:[
|
|
435 |
val := 0.0 asShortFloat
|
|
436 |
] ifFalse:[type == #double ifTrue:[
|
|
437 |
val := 0.0
|
|
438 |
] ifFalse:[type == #byte ifTrue:[
|
|
439 |
val := 0.
|
|
440 |
] ifFalse:[type == #char ifTrue:[
|
|
441 |
val := 0.
|
|
442 |
] ifFalse:[type == #'unsigned short' ifTrue:[
|
|
443 |
val := 0.
|
|
444 |
] ifFalse:[type == #boolean ifTrue:[
|
|
445 |
val := 0.
|
|
446 |
]]]]]]]].
|
|
447 |
].
|
|
448 |
self instVarNamed:(f name) put:val.
|
60
|
449 |
].
|
43
|
450 |
! !
|
|
451 |
|
|
452 |
!JavaClass methodsFor:'java instance creation'!
|
29
|
453 |
|
52
|
454 |
initValueFor:instVarName
|
|
455 |
|idx field|
|
|
456 |
|
|
457 |
idx := fields findFirst:[:field | field name = instVarName].
|
|
458 |
idx == 0 ifTrue:[
|
172
|
459 |
superclass ~~ JavaObject ifTrue:[
|
|
460 |
^ superclass initValueFor:instVarName
|
|
461 |
].
|
|
462 |
self halt
|
52
|
463 |
] ifFalse:[
|
172
|
464 |
field := fields at:idx.
|
|
465 |
^ field initialValue
|
52
|
466 |
].
|
|
467 |
!
|
|
468 |
|
|
469 |
new
|
|
470 |
"create a new instance, and call its JAVA init function"
|
|
471 |
|
|
472 |
|newJavaObject|
|
|
473 |
|
|
474 |
newJavaObject := self newCleared.
|
179
|
475 |
newJavaObject invoke:#'<init>()V'.
|
52
|
476 |
^ newJavaObject
|
|
477 |
|
|
478 |
"
|
|
479 |
(Java classNamed:'java.lang.String') basicNew inspect
|
|
480 |
(Java classNamed:'java.lang.String') new inspect
|
|
481 |
"
|
|
482 |
|
179
|
483 |
"Modified: 30.7.1997 / 17:40:25 / cg"
|
52
|
484 |
!
|
|
485 |
|
|
486 |
newCleared
|
148
|
487 |
"create a new cleared JAVA instance.
|
|
488 |
Its instVars are cleared to the corresponding typed values;
|
|
489 |
however, <init> is not invoked for it."
|
43
|
490 |
|
29
|
491 |
|newJavaObject|
|
|
492 |
|
|
493 |
newJavaObject := super basicNew.
|
43
|
494 |
|
52
|
495 |
fields isNil ifTrue:[
|
172
|
496 |
'OOPS - no fieldSpec for new object' errorPrintNL.
|
|
497 |
newJavaObject initializeToZero. "/ mhmh
|
52
|
498 |
] ifFalse:[
|
172
|
499 |
initValues notNil ifTrue:[
|
|
500 |
newJavaObject initializeFields:initValues
|
|
501 |
]
|
52
|
502 |
].
|
29
|
503 |
^ newJavaObject
|
43
|
504 |
|
|
505 |
"
|
|
506 |
(Java classNamed:'java.lang.String') basicNew inspect
|
53
|
507 |
(Java classNamed:'java.lang.String') newCleared inspect
|
43
|
508 |
(Java classNamed:'java.lang.String') new inspect
|
|
509 |
"
|
148
|
510 |
|
|
511 |
"Modified: 18.3.1997 / 17:31:18 / cg"
|
|
512 |
!
|
|
513 |
|
|
514 |
newFromInterpreter:anInterpreter sender:aJavaContext
|
|
515 |
"create a new instance, and call its JAVA init function.
|
|
516 |
This is done in the context of an already running interpreter."
|
|
517 |
|
|
518 |
|newJavaObject|
|
|
519 |
|
|
520 |
newJavaObject := self newCleared.
|
|
521 |
newJavaObject invoke:#'<init>' interpreter:anInterpreter sender:aJavaContext.
|
|
522 |
^ newJavaObject
|
|
523 |
|
|
524 |
"Created: 18.3.1997 / 17:33:07 / cg"
|
43
|
525 |
! !
|
|
526 |
|
|
527 |
!JavaClass methodsFor:'message sending'!
|
|
528 |
|
|
529 |
invokeJava:selector
|
170
|
530 |
"send javaSelector (name+sig) message, without arguments
|
|
531 |
as a static call to the class"
|
|
532 |
|
|
533 |
^ self
|
172
|
534 |
invokeJava:selector sender:thisContext sender
|
170
|
535 |
|
|
536 |
"Modified: 7.4.1997 / 22:52:30 / cg"
|
|
537 |
!
|
|
538 |
|
|
539 |
invokeJava:selector sender:aContext
|
|
540 |
"send javaSelector (name+sig) message, without arguments
|
|
541 |
as a static call to the class"
|
43
|
542 |
|
|
543 |
|method|
|
|
544 |
|
|
545 |
method := self lookupMethodFor:selector.
|
|
546 |
method notNil ifTrue:[
|
175
|
547 |
^ self
|
|
548 |
invokeJavaMethod:method
|
|
549 |
sender:aContext
|
|
550 |
selector:selector
|
43
|
551 |
].
|
|
552 |
|
|
553 |
^ self doesNotUnderstand:(Message selector:selector)
|
|
554 |
|
170
|
555 |
"Created: 7.4.1997 / 22:52:10 / cg"
|
175
|
556 |
"Modified: 30.7.1997 / 13:29:09 / cg"
|
43
|
557 |
!
|
|
558 |
|
|
559 |
invokeJava:selector with:arg
|
170
|
560 |
"send javaSelector (name+sig) message, with 1 argument
|
|
561 |
as a static call to the class"
|
43
|
562 |
|
|
563 |
|method|
|
|
564 |
|
|
565 |
method := self lookupMethodFor:selector.
|
|
566 |
method notNil ifTrue:[
|
175
|
567 |
^ self
|
|
568 |
invokeJavaMethod:method
|
|
569 |
sender:thisContext
|
|
570 |
selector:selector
|
|
571 |
with:arg
|
43
|
572 |
].
|
|
573 |
^ self doesNotUnderstand:(Message selector:selector)
|
|
574 |
|
175
|
575 |
"Modified: 30.7.1997 / 13:37:58 / cg"
|
170
|
576 |
!
|
|
577 |
|
|
578 |
invokeJava:selector with:arg sender:aContext
|
|
579 |
"send javaSelector (name+sig) message, with 1 argument
|
|
580 |
as a static call to the class"
|
|
581 |
|
|
582 |
|method|
|
|
583 |
|
|
584 |
method := self lookupMethodFor:selector.
|
|
585 |
method notNil ifTrue:[
|
175
|
586 |
^ self
|
|
587 |
invokeJavaMethod:method
|
|
588 |
sender:aContext
|
|
589 |
selector:selector
|
|
590 |
with:arg
|
170
|
591 |
].
|
|
592 |
^ self doesNotUnderstand:(Message selector:selector)
|
|
593 |
|
|
594 |
"Created: 7.4.1997 / 22:52:51 / cg"
|
175
|
595 |
"Modified: 30.7.1997 / 13:39:45 / cg"
|
43
|
596 |
!
|
|
597 |
|
175
|
598 |
invokeJavaMethod:aJavaMethod sender:aContext selector:sel
|
79
|
599 |
"invoke a static java method, without arguments"
|
|
600 |
|
|
601 |
|i val|
|
|
602 |
|
|
603 |
aJavaMethod numArgs ~~ 0 ifTrue:[
|
175
|
604 |
self halt:'need arguments'
|
79
|
605 |
].
|
|
606 |
aJavaMethod isStatic ifFalse:[
|
175
|
607 |
self halt:'non-static function'
|
79
|
608 |
].
|
|
609 |
|
|
610 |
i := JavaInterpreter new.
|
|
611 |
val := i interpret:aJavaMethod sender:aContext.
|
|
612 |
|
|
613 |
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
|
|
614 |
|
175
|
615 |
"Modified: 30.7.1997 / 12:01:52 / cg"
|
|
616 |
"Created: 30.7.1997 / 13:34:33 / cg"
|
79
|
617 |
!
|
|
618 |
|
175
|
619 |
invokeJavaMethod:aJavaMethod sender:aContext selector:sel with:arg1
|
|
620 |
"invoke a static java method, without arguments"
|
|
621 |
|
|
622 |
|i val|
|
43
|
623 |
|
175
|
624 |
aJavaMethod numArgs ~~ 1 ifTrue:[
|
|
625 |
self halt:'need arguments'
|
|
626 |
].
|
|
627 |
aJavaMethod isStatic ifFalse:[
|
|
628 |
self halt:'non-static function'
|
|
629 |
].
|
43
|
630 |
|
175
|
631 |
i := JavaInterpreter new.
|
|
632 |
i push:arg1.
|
|
633 |
val := i interpret:aJavaMethod sender:aContext.
|
|
634 |
|
|
635 |
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
|
|
636 |
|
|
637 |
"Created: 30.7.1997 / 13:34:33 / cg"
|
|
638 |
"Modified: 30.7.1997 / 13:38:46 / cg"
|
43
|
639 |
!
|
|
640 |
|
170
|
641 |
invokeJavaMethod:aJavaMethod with:arg sender:aContext
|
79
|
642 |
"invoke a static java method, with one argument"
|
|
643 |
|
|
644 |
|i val|
|
|
645 |
|
|
646 |
aJavaMethod numArgs ~~ 1 ifTrue:[
|
172
|
647 |
self halt:'argument count'
|
79
|
648 |
].
|
|
649 |
aJavaMethod isStatic ifFalse:[
|
172
|
650 |
self halt:'non-static function'
|
79
|
651 |
].
|
|
652 |
|
|
653 |
i := JavaInterpreter new.
|
|
654 |
i push:arg.
|
|
655 |
|
|
656 |
val := i interpret:aJavaMethod sender:aContext.
|
|
657 |
|
|
658 |
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
|
|
659 |
|
170
|
660 |
"Modified: 7.4.1997 / 22:50:02 / cg"
|
|
661 |
"Created: 7.4.1997 / 22:53:18 / cg"
|
79
|
662 |
!
|
|
663 |
|
200
|
664 |
invokeStatic:selector
|
|
665 |
"send a static message, without args."
|
|
666 |
|
|
667 |
|method cls sel|
|
|
668 |
|
|
669 |
sel := selector asSymbolIfInterned.
|
|
670 |
sel notNil ifTrue:[
|
|
671 |
cls := self.
|
|
672 |
[cls notNil and:[cls ~~ JavaObject]] whileTrue:[
|
|
673 |
cls methodDictionary keysAndValuesDo:[:sel :aMethod |
|
|
674 |
|
|
675 |
"/ aMethod name printNL.
|
|
676 |
|
|
677 |
aMethod isStatic ifTrue:[
|
|
678 |
sel == selector ifTrue:[
|
|
679 |
^ self
|
|
680 |
invokeJavaMethod:aMethod
|
|
681 |
sender:thisContext
|
|
682 |
selector:selector
|
|
683 |
]
|
|
684 |
]
|
|
685 |
].
|
|
686 |
cls := cls superclass.
|
|
687 |
].
|
|
688 |
].
|
|
689 |
|
|
690 |
^ self doesNotUnderstand:(Message selector:selector)
|
|
691 |
|
|
692 |
"Created: 5.8.1997 / 14:35:34 / cg"
|
|
693 |
"Modified: 5.8.1997 / 14:36:54 / cg"
|
|
694 |
!
|
|
695 |
|
43
|
696 |
lookupMethodFor:selector
|
|
697 |
|method cls sel|
|
|
698 |
|
|
699 |
sel := selector asSymbolIfInterned.
|
|
700 |
sel notNil ifTrue:[
|
172
|
701 |
cls := self.
|
|
702 |
[cls notNil] whileTrue:[
|
|
703 |
method := cls compiledMethodAt:sel.
|
|
704 |
method notNil ifTrue:[ ^ method ].
|
|
705 |
cls := cls superclass.
|
|
706 |
].
|
43
|
707 |
].
|
|
708 |
|
|
709 |
^ nil
|
29
|
710 |
! !
|
|
711 |
|
160
|
712 |
!JavaClass methodsFor:'printOut'!
|
|
713 |
|
|
714 |
printNameInHierarchy
|
|
715 |
"return my name as printed in the hierarchy"
|
|
716 |
|
|
717 |
^ self displayString
|
|
718 |
|
|
719 |
"Modified: 22.3.1997 / 14:16:55 / cg"
|
|
720 |
!
|
|
721 |
|
|
722 |
printOutOn:aStream
|
|
723 |
self warn:'printOut not yet supported'
|
|
724 |
|
|
725 |
"Created: 22.3.1997 / 14:36:12 / cg"
|
|
726 |
!
|
|
727 |
|
|
728 |
printOutProtocolOn:aStream
|
|
729 |
self warn:'printOut not yet supported'
|
|
730 |
|
|
731 |
"Created: 22.3.1997 / 14:36:28 / cg"
|
|
732 |
! !
|
|
733 |
|
1
|
734 |
!JavaClass methodsFor:'printing & storing'!
|
|
735 |
|
|
736 |
displayString
|
125
|
737 |
^ (fullName copyFrom:1) replaceAll:$/ by:$.
|
|
738 |
|
41
|
739 |
"/ ^ 'JAVA-' , name .
|
|
740 |
"/ ^ name , '(Java)' "/ 'JavaClass(' , name , ')'
|
1
|
741 |
|
|
742 |
"Created: 15.4.1996 / 16:02:48 / cg"
|
125
|
743 |
|
|
744 |
|
|
745 |
|
|
746 |
|
1
|
747 |
! !
|
|
748 |
|
|
749 |
!JavaClass methodsFor:'private accessing'!
|
|
750 |
|
5
|
751 |
addMethod:m name:name signature:signature
|
63
|
752 |
|sel|
|
|
753 |
|
|
754 |
sel := (name , signature) asSymbol.
|
|
755 |
self addSelector:sel withMethod:m.
|
|
756 |
^ self.
|
|
757 |
|
98
|
758 |
"/ selectorArray isNil ifTrue:[
|
|
759 |
"/ selectorArray := #().
|
|
760 |
"/ methodArray := #()
|
|
761 |
"/ ].
|
|
762 |
"/ selectorArray := selectorArray copyWith:(name , signature) asSymbol. "/ name.
|
|
763 |
"/"/ selectorArray := selectorArray copyWith:name asSymbol. "/ name.
|
|
764 |
"/ methodArray := methodArray copyWith:m
|
5
|
765 |
|
|
766 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
98
|
767 |
|
|
768 |
|
5
|
769 |
!
|
|
770 |
|
130
|
771 |
addSelector:newSelector withMethod:newMethod
|
|
772 |
"redefined to not flush smalltalk caches and send NO smalltalk-class
|
|
773 |
change notification. Will eventually flush Java caches."
|
|
774 |
|
|
775 |
|nargs oldMethod|
|
|
776 |
|
|
777 |
oldMethod := self compiledMethodAt:newSelector.
|
|
778 |
(self primAddSelector:newSelector withMethod:newMethod) ifFalse:[^ false].
|
|
779 |
|
|
780 |
^ true
|
|
781 |
|
|
782 |
"Created: 20.1.1997 / 13:00:48 / cg"
|
|
783 |
!
|
|
784 |
|
204
|
785 |
makeObsolete
|
|
786 |
accessFlags := accessFlags bitOr:16r8000
|
|
787 |
|
|
788 |
"Created: 7.8.1997 / 19:04:48 / cg"
|
|
789 |
!
|
|
790 |
|
43
|
791 |
markUninitialized
|
|
792 |
initialized := false.
|
|
793 |
!
|
|
794 |
|
1
|
795 |
setAccessFlags:flags
|
3
|
796 |
accessFlags := flags.
|
1
|
797 |
|
|
798 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
5
|
799 |
!
|
|
800 |
|
73
|
801 |
setBinaryFilePath:aPathName
|
|
802 |
binaryFilePath := aPathName
|
|
803 |
!
|
|
804 |
|
5
|
805 |
setConstantPool:anArray
|
|
806 |
constantPool := anArray.
|
90
|
807 |
hasUnresolvedConstants := true
|
5
|
808 |
|
|
809 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
|
810 |
!
|
|
811 |
|
27
|
812 |
setFields:f
|
54
|
813 |
JavaClass setInstanceVariableStringFromFields:f in:self.
|
|
814 |
|
|
815 |
instSize := superclass instSize + f size.
|
|
816 |
|
52
|
817 |
fields := f.
|
|
818 |
initValues := self allInstVarNames collect:[:nm |
|
172
|
819 |
self initValueFor:nm
|
52
|
820 |
].
|
76
|
821 |
initValues isEmpty ifTrue:[
|
172
|
822 |
initValues := nil
|
76
|
823 |
].
|
27
|
824 |
|
|
825 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
52
|
826 |
|
|
827 |
|
27
|
828 |
!
|
|
829 |
|
7
|
830 |
setFullName:aString
|
|
831 |
|nameComponents|
|
|
832 |
|
125
|
833 |
fullName := aString asSymbol.
|
7
|
834 |
nameComponents := aString asCollectionOfSubstringsSeparatedBy:$/.
|
125
|
835 |
name := nameComponents last asSymbol
|
7
|
836 |
|
|
837 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
|
838 |
!
|
|
839 |
|
110
|
840 |
setInterfaces:i
|
|
841 |
i size > 0 ifTrue:[
|
172
|
842 |
interfaces := i
|
168
|
843 |
] ifFalse:[
|
172
|
844 |
interfaces := nil
|
110
|
845 |
]
|
|
846 |
|
168
|
847 |
"Modified: 7.4.1997 / 15:44:53 / cg"
|
110
|
848 |
!
|
|
849 |
|
5
|
850 |
setSourceFile:aFilename
|
|
851 |
sourceFile := aFilename.
|
|
852 |
|
|
853 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
27
|
854 |
!
|
|
855 |
|
60
|
856 |
setStaticFields:f
|
|
857 |
JavaClass setInstanceVariableStringFromFields:f in:self class.
|
|
858 |
|
|
859 |
staticFields := f.
|
|
860 |
|
|
861 |
|
|
862 |
!
|
|
863 |
|
27
|
864 |
setSuperclass:aClass
|
|
865 |
aClass isNil ifTrue:[
|
172
|
866 |
super setSuperclass:JavaObject
|
29
|
867 |
] ifFalse:[
|
172
|
868 |
(aClass isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
869 |
self halt.
|
|
870 |
].
|
|
871 |
super setSuperclass:aClass.
|
27
|
872 |
].
|
29
|
873 |
|
|
874 |
instvars notNil ifTrue:[
|
172
|
875 |
(superclass notNil and:[(superclass isMemberOf:JavaUnresolvedClassConstant) not]) ifTrue:[
|
|
876 |
instSize := superclass instSize + (instvars asCollectionOfWords size)
|
|
877 |
] ifFalse:[
|
|
878 |
instSize := instvars asCollectionOfWords size
|
|
879 |
]
|
29
|
880 |
].
|
27
|
881 |
|
|
882 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
1
|
883 |
! !
|
|
884 |
|
18
|
885 |
!JavaClass methodsFor:'queries'!
|
|
886 |
|
42
|
887 |
browserClass
|
|
888 |
"return the browser to use for this class -
|
|
889 |
this can be redefined in special classes, to get different browsers"
|
|
890 |
|
|
891 |
^ JavaBrowser
|
|
892 |
|
|
893 |
|
|
894 |
|
|
895 |
|
|
896 |
!
|
|
897 |
|
53
|
898 |
hasInterface:aJavaInterface
|
111
|
899 |
interfaces size > 0 ifTrue:[
|
172
|
900 |
self interfaces do:[:if |
|
|
901 |
aJavaInterface == if ifTrue:[
|
|
902 |
^ true
|
|
903 |
].
|
|
904 |
]
|
111
|
905 |
].
|
|
906 |
"/ ^ false.
|
|
907 |
|
69
|
908 |
aJavaInterface methodDictionary keysAndValuesDo:[:sel :mthd |
|
172
|
909 |
(self canUnderstand:sel) ifFalse:[
|
|
910 |
self halt.
|
|
911 |
^ false.
|
|
912 |
]
|
53
|
913 |
].
|
|
914 |
^ true
|
52
|
915 |
!
|
|
916 |
|
83
|
917 |
isAbstract
|
|
918 |
^ (accessFlags bitAnd:16r0400) ~~ 0
|
|
919 |
!
|
|
920 |
|
27
|
921 |
isClass
|
|
922 |
^ true
|
|
923 |
!
|
|
924 |
|
18
|
925 |
isFinal
|
|
926 |
^ (accessFlags bitAnd:16r0010) ~~ 0
|
|
927 |
!
|
|
928 |
|
43
|
929 |
isInitialized
|
|
930 |
^ initialized == true
|
|
931 |
!
|
|
932 |
|
18
|
933 |
isInterface
|
|
934 |
^ (accessFlags bitAnd:16r0200) ~~ 0
|
|
935 |
!
|
|
936 |
|
148
|
937 |
isJavaClass
|
|
938 |
^ self ~~ JavaClass
|
|
939 |
|
|
940 |
"Created: 18.3.1997 / 17:48:01 / cg"
|
|
941 |
!
|
|
942 |
|
71
|
943 |
isObsolete
|
|
944 |
"return true, if the receiver is obsolete
|
|
945 |
Java classes are never."
|
|
946 |
|
204
|
947 |
^ (accessFlags bitAnd:16r8000) ~~ 0.
|
71
|
948 |
^ false
|
|
949 |
|
204
|
950 |
"Modified: 7.8.1997 / 19:04:28 / cg"
|
71
|
951 |
!
|
|
952 |
|
18
|
953 |
isPublic
|
|
954 |
^ (accessFlags bitAnd:16r0001) ~~ 0
|
90
|
955 |
!
|
21
|
956 |
|
90
|
957 |
isUnresolved
|
|
958 |
^ false
|
175
|
959 |
!
|
|
960 |
|
|
961 |
supportsMethodCategories
|
|
962 |
^ self == JavaClass
|
|
963 |
|
|
964 |
"Created: 30.7.1997 / 14:58:58 / cg"
|
21
|
965 |
! !
|
|
966 |
|
43
|
967 |
!JavaClass methodsFor:'smalltalk interface'!
|
|
968 |
|
|
969 |
invoke:selector
|
175
|
970 |
"send a message, without args."
|
43
|
971 |
|
|
972 |
|method cls sel|
|
|
973 |
|
|
974 |
sel := selector asSymbolIfInterned.
|
|
975 |
sel notNil ifTrue:[
|
175
|
976 |
cls := self.
|
|
977 |
[cls notNil and:[cls ~~ JavaObject]] whileTrue:[
|
|
978 |
cls methodDictionary keysAndValuesDo:[:sel :aMethod |
|
69
|
979 |
|
43
|
980 |
"/ aMethod name printNL.
|
175
|
981 |
|
|
982 |
(aMethod name == selector
|
|
983 |
or:[aMethod signatureNameWithoutReturnType = selector]) ifTrue:[
|
|
984 |
aMethod numArgs == 0 ifTrue:[
|
|
985 |
^ self
|
|
986 |
invokeJavaMethod:aMethod
|
|
987 |
sender:thisContext
|
|
988 |
selector:selector
|
|
989 |
]
|
|
990 |
]
|
|
991 |
].
|
|
992 |
cls := cls superclass.
|
|
993 |
].
|
|
994 |
].
|
|
995 |
|
|
996 |
^ self doesNotUnderstand:(Message selector:selector)
|
|
997 |
|
|
998 |
"
|
|
999 |
|stack|
|
|
1000 |
|
|
1001 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1002 |
stack invoke:#'<init>'.
|
|
1003 |
"
|
|
1004 |
"
|
|
1005 |
|stack|
|
|
1006 |
|
|
1007 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1008 |
stack invoke:#isEmpty.
|
|
1009 |
"
|
|
1010 |
"
|
|
1011 |
|stack|
|
|
1012 |
|
|
1013 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1014 |
stack invoke:#size.
|
|
1015 |
"
|
|
1016 |
|
|
1017 |
"Created: 30.7.1997 / 14:06:50 / cg"
|
185
|
1018 |
"Modified: 1.8.1997 / 00:06:56 / cg"
|
175
|
1019 |
!
|
|
1020 |
|
|
1021 |
invoke:selector signature:signature
|
|
1022 |
"send a message, without args."
|
|
1023 |
|
|
1024 |
|method cls sel sig|
|
|
1025 |
|
|
1026 |
sel := selector asSymbolIfInterned.
|
|
1027 |
sel notNil ifTrue:[
|
|
1028 |
sig := signature asSymbolIfInterned.
|
|
1029 |
sig notNil ifTrue:[
|
|
1030 |
cls := self.
|
|
1031 |
[cls notNil and:[cls ~~ JavaObject]] whileTrue:[
|
185
|
1032 |
method := cls compiledMethodAt:sel signature:signature.
|
|
1033 |
method notNil ifTrue:[
|
|
1034 |
^ self
|
|
1035 |
invokeJavaMethod:method
|
|
1036 |
sender:thisContext
|
|
1037 |
selector:sel
|
175
|
1038 |
].
|
|
1039 |
cls := cls superclass.
|
|
1040 |
].
|
|
1041 |
].
|
43
|
1042 |
].
|
|
1043 |
|
|
1044 |
^ self doesNotUnderstand:(Message selector:selector)
|
|
1045 |
|
|
1046 |
"
|
|
1047 |
|stack|
|
|
1048 |
|
|
1049 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1050 |
stack invoke:#'<init>'.
|
|
1051 |
"
|
|
1052 |
"
|
|
1053 |
|stack|
|
|
1054 |
|
|
1055 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1056 |
stack invoke:#isEmpty.
|
|
1057 |
"
|
|
1058 |
"
|
|
1059 |
|stack|
|
|
1060 |
|
|
1061 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1062 |
stack invoke:#size.
|
|
1063 |
"
|
|
1064 |
|
175
|
1065 |
"Created: 30.7.1997 / 14:12:29 / cg"
|
185
|
1066 |
"Modified: 1.8.1997 / 00:04:45 / cg"
|
175
|
1067 |
!
|
43
|
1068 |
|
175
|
1069 |
invoke:selector signature:signature with:arg
|
|
1070 |
"send a message, with 1 arg1."
|
|
1071 |
|
|
1072 |
|method cls sel sig|
|
|
1073 |
|
|
1074 |
sel := selector asSymbolIfInterned.
|
|
1075 |
sel notNil ifTrue:[
|
|
1076 |
sig := signature asSymbolIfInterned.
|
|
1077 |
sig notNil ifTrue:[
|
|
1078 |
cls := self.
|
|
1079 |
[cls notNil and:[cls ~~ JavaObject]] whileTrue:[
|
185
|
1080 |
method := cls compiledMethodAt:sel signature:signature.
|
|
1081 |
method notNil ifTrue:[
|
|
1082 |
^ self
|
|
1083 |
invokeJavaMethod:method
|
|
1084 |
sender:thisContext
|
|
1085 |
selector:sel
|
|
1086 |
with:arg
|
175
|
1087 |
].
|
|
1088 |
cls := cls superclass.
|
|
1089 |
].
|
|
1090 |
].
|
|
1091 |
].
|
|
1092 |
|
|
1093 |
^ self doesNotUnderstand:(Message selector:selector)
|
|
1094 |
|
|
1095 |
"
|
|
1096 |
|stack|
|
|
1097 |
|
|
1098 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1099 |
stack invoke:#'<init>'.
|
|
1100 |
"
|
|
1101 |
"
|
|
1102 |
|stack|
|
|
1103 |
|
|
1104 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1105 |
stack invoke:#isEmpty.
|
|
1106 |
"
|
|
1107 |
"
|
|
1108 |
|stack|
|
|
1109 |
|
|
1110 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1111 |
stack invoke:#size.
|
|
1112 |
"
|
|
1113 |
|
|
1114 |
"Created: 30.7.1997 / 14:13:30 / cg"
|
185
|
1115 |
"Modified: 1.8.1997 / 00:04:40 / cg"
|
113
|
1116 |
!
|
|
1117 |
|
|
1118 |
invoke:selector with:arg
|
175
|
1119 |
"send a message, with one arg"
|
|
1120 |
|
|
1121 |
|method cls sel|
|
|
1122 |
|
|
1123 |
sel := selector asSymbolIfInterned.
|
|
1124 |
sel notNil ifTrue:[
|
|
1125 |
cls := self.
|
|
1126 |
[cls notNil and:[cls ~~ JavaObject]] whileTrue:[
|
|
1127 |
cls methodDictionary keysAndValuesDo:[:sel :aMethod |
|
|
1128 |
|
|
1129 |
"/ aMethod name printNL.
|
|
1130 |
(aMethod name == selector
|
|
1131 |
or:[aMethod signatureNameWithoutReturnType = selector]) ifTrue:[
|
|
1132 |
aMethod numArgs == 1 ifTrue:[
|
|
1133 |
^ self
|
|
1134 |
invokeJavaMethod:aMethod
|
|
1135 |
sender:thisContext
|
|
1136 |
selector:selector
|
|
1137 |
with:arg
|
|
1138 |
]
|
|
1139 |
]
|
|
1140 |
].
|
|
1141 |
cls := cls superclass.
|
|
1142 |
].
|
|
1143 |
].
|
|
1144 |
|
|
1145 |
^ self doesNotUnderstand:(Message selector:selector)
|
|
1146 |
|
|
1147 |
"Modified: 30.7.1997 / 13:59:49 / cg"
|
|
1148 |
!
|
|
1149 |
|
|
1150 |
invoke:selector with:arg1 with:arg2
|
|
1151 |
"send a message, with two args"
|
113
|
1152 |
|
|
1153 |
|method cls sel|
|
|
1154 |
|
|
1155 |
sel := selector asSymbolIfInterned.
|
|
1156 |
sel notNil ifTrue:[
|
175
|
1157 |
cls := self.
|
|
1158 |
[cls notNil and:[cls ~~ JavaObject]] whileTrue:[
|
|
1159 |
cls methodDictionary keysAndValuesDo:[:sel :aMethod |
|
113
|
1160 |
|
|
1161 |
"/ aMethod name printNL.
|
175
|
1162 |
(aMethod name == selector
|
|
1163 |
or:[aMethod signatureNameWithoutReturnType = selector]) ifTrue:[
|
|
1164 |
aMethod numArgs == 2 ifTrue:[
|
|
1165 |
^ self
|
|
1166 |
invokeJavaMethod:aMethod
|
|
1167 |
sender:thisContext
|
|
1168 |
selector:selector
|
|
1169 |
with:arg1
|
|
1170 |
with:arg2
|
|
1171 |
]
|
|
1172 |
]
|
|
1173 |
].
|
|
1174 |
cls := cls superclass.
|
|
1175 |
].
|
113
|
1176 |
].
|
|
1177 |
|
|
1178 |
^ self doesNotUnderstand:(Message selector:selector)
|
|
1179 |
|
175
|
1180 |
"Modified: 30.7.1997 / 13:39:15 / cg"
|
|
1181 |
"Created: 30.7.1997 / 14:00:09 / cg"
|
|
1182 |
!
|
|
1183 |
|
|
1184 |
invoke:selector withAll:args
|
|
1185 |
"send a message, with a number of args"
|
|
1186 |
|
|
1187 |
|method cls sel numArgGiven|
|
|
1188 |
|
|
1189 |
numArgGiven := args size.
|
|
1190 |
|
|
1191 |
sel := selector asSymbolIfInterned.
|
|
1192 |
sel notNil ifTrue:[
|
|
1193 |
cls := self.
|
|
1194 |
[cls notNil and:[cls ~~ JavaObject]] whileTrue:[
|
|
1195 |
cls methodDictionary keysAndValuesDo:[:sel :aMethod |
|
|
1196 |
|
|
1197 |
"/ aMethod name printNL.
|
|
1198 |
(aMethod name == selector
|
|
1199 |
or:[aMethod signatureNameWithoutReturnType = selector]) ifTrue:[
|
|
1200 |
aMethod numArgs == numArgGiven ifTrue:[
|
|
1201 |
^ self
|
|
1202 |
invokeJavaMethod:aMethod
|
|
1203 |
sender:thisContext
|
|
1204 |
selector:selector
|
|
1205 |
withAll:args
|
|
1206 |
]
|
|
1207 |
]
|
|
1208 |
].
|
|
1209 |
cls := cls superclass.
|
|
1210 |
].
|
|
1211 |
].
|
|
1212 |
|
|
1213 |
^ self doesNotUnderstand:(Message selector:selector)
|
|
1214 |
|
|
1215 |
"Modified: 30.7.1997 / 13:39:15 / cg"
|
|
1216 |
"Created: 30.7.1997 / 14:00:53 / cg"
|
|
1217 |
!
|
|
1218 |
|
|
1219 |
invokeSignature:signature
|
|
1220 |
"send a message, without args."
|
|
1221 |
|
|
1222 |
|method cls sel|
|
|
1223 |
|
|
1224 |
sel := signature asSymbolIfInterned.
|
|
1225 |
sel notNil ifTrue:[
|
|
1226 |
cls := self.
|
|
1227 |
[cls notNil and:[cls ~~ JavaObject]] whileTrue:[
|
|
1228 |
cls methodDictionary keysAndValuesDo:[:sel :aMethod |
|
|
1229 |
|
|
1230 |
"/ aMethod name printNL.
|
|
1231 |
|
|
1232 |
aMethod signatureName = signature ifTrue:[
|
|
1233 |
aMethod numArgs == 0 ifTrue:[
|
|
1234 |
^ self
|
|
1235 |
invokeJavaMethod:aMethod
|
|
1236 |
sender:thisContext
|
|
1237 |
selector:signature
|
|
1238 |
]
|
|
1239 |
]
|
|
1240 |
].
|
|
1241 |
cls := cls superclass.
|
|
1242 |
].
|
|
1243 |
].
|
|
1244 |
|
|
1245 |
^ self doesNotUnderstand:(Message selector:signature)
|
|
1246 |
|
|
1247 |
"
|
|
1248 |
|stack|
|
|
1249 |
|
|
1250 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1251 |
stack invoke:#'<init>'.
|
|
1252 |
"
|
|
1253 |
"
|
|
1254 |
|stack|
|
|
1255 |
|
|
1256 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1257 |
stack invoke:#isEmpty.
|
|
1258 |
"
|
|
1259 |
"
|
|
1260 |
|stack|
|
|
1261 |
|
|
1262 |
stack := (Java at:'java/util/Stack') basicNew.
|
|
1263 |
stack invoke:#size.
|
|
1264 |
"
|
|
1265 |
|
|
1266 |
"Modified: 30.7.1997 / 14:07:55 / cg"
|
|
1267 |
"Created: 30.7.1997 / 14:09:31 / cg"
|
133
|
1268 |
!
|
|
1269 |
|
|
1270 |
methodMatching:aSmalltalkSelector
|
|
1271 |
|numArgs cls|
|
|
1272 |
|
|
1273 |
numArgs := aSmalltalkSelector numArgs.
|
|
1274 |
cls := self.
|
|
1275 |
[cls notNil] whileTrue:[
|
172
|
1276 |
methodDictionary keysAndValuesDo:[:jSelector :aMethod |
|
|
1277 |
aMethod numArgs == numArgs ifTrue:[
|
|
1278 |
aMethod name = aSmalltalkSelector ifTrue:[
|
|
1279 |
^ aMethod
|
|
1280 |
]
|
|
1281 |
]
|
|
1282 |
].
|
|
1283 |
cls := cls superclass
|
133
|
1284 |
].
|
|
1285 |
^ nil
|
|
1286 |
|
|
1287 |
"Modified: 1.2.1997 / 21:57:36 / cg"
|
|
1288 |
"Created: 1.2.1997 / 21:57:53 / cg"
|
43
|
1289 |
! !
|
|
1290 |
|
203
|
1291 |
!JavaClass methodsFor:'special'!
|
|
1292 |
|
|
1293 |
updateClassRefsFrom:oldClass to:newClass
|
204
|
1294 |
self == oldClass ifTrue:[
|
|
1295 |
self makeObsolete.
|
|
1296 |
^ self
|
|
1297 |
].
|
|
1298 |
|
203
|
1299 |
constantPool updateClassRefsFrom:oldClass to:newClass.
|
|
1300 |
interfaces notNil ifTrue:[
|
|
1301 |
interfaces := interfaces collect:[:anInterface |
|
|
1302 |
anInterface == oldClass ifTrue:[
|
|
1303 |
newClass
|
|
1304 |
] ifFalse:[
|
204
|
1305 |
anInterface
|
203
|
1306 |
]
|
|
1307 |
]
|
|
1308 |
]
|
|
1309 |
|
204
|
1310 |
"Modified: 8.8.1997 / 12:19:14 / cg"
|
203
|
1311 |
! !
|
|
1312 |
|
130
|
1313 |
!JavaClass class methodsFor:'documentation'!
|
1
|
1314 |
|
|
1315 |
version
|
213
|
1316 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClass.st,v 1.60 1997/08/12 00:57:31 cg Exp $'
|
1
|
1317 |
! !
|
52
|
1318 |
JavaClass initialize!
|