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