454
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
674
|
16 |
"{ Package: 'stx:libjava' }"
|
|
17 |
|
172
|
18 |
Class subclass:#JavaClass
|
261
|
19 |
instanceVariableNames:'constantPool interfaces accessFlags classLoader fullName
|
|
20 |
sourceFile binaryFilePath fields initValues staticFields'
|
252
|
21 |
classVariableNames:'InitialValuePerType A_OBSOLETE A_INTERFACE A_PUBLIC A_FINAL
|
451
|
22 |
A_ABSTRACT A_INITIALIZED A_SMALLTALK A_ABSTRACT_OR_INTERFACE
|
435
|
23 |
ArgumentConversionErrorSignal OrderOfClassInits'
|
1
|
24 |
poolDictionaries:''
|
|
25 |
category:'Java-Classes'
|
|
26 |
!
|
|
27 |
|
133
|
28 |
!JavaClass class methodsFor:'documentation'!
|
|
29 |
|
454
|
30 |
copyright
|
|
31 |
"
|
|
32 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
33 |
All Rights Reserved
|
|
34 |
|
|
35 |
This software is furnished under a license and may be used
|
|
36 |
only in accordance with the terms of that license and with the
|
|
37 |
inclusion of the above copyright notice. This software may not
|
|
38 |
be provided or otherwise made available to, or used by, any
|
|
39 |
other person. No title to or ownership of the software is
|
|
40 |
hereby transferred.
|
|
41 |
"
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
!
|
|
46 |
|
255
|
47 |
documentation
|
|
48 |
"
|
|
49 |
fields upTo-and-including accessFlags are known & used by the VM
|
|
50 |
only add fields after those and keep their order intact.
|
|
51 |
"
|
|
52 |
!
|
|
53 |
|
133
|
54 |
examples
|
|
55 |
"
|
|
56 |
(Java at:'java.util.Stack') new inspect
|
|
57 |
(Java at:'java.util.Vector') new inspect
|
|
58 |
"
|
|
59 |
! !
|
1
|
60 |
|
130
|
61 |
!JavaClass class methodsFor:'initialization'!
|
52
|
62 |
|
|
63 |
initialize
|
252
|
64 |
"/ those are defined in Java and read from the classFile
|
|
65 |
A_PUBLIC := 16r000001.
|
349
|
66 |
"/ A_PRIVATE := 16r000002.
|
|
67 |
"/ A_PROTECTED := 16r000004.
|
357
|
68 |
A_STATIC := 16r000008.
|
252
|
69 |
A_FINAL := 16r000010.
|
349
|
70 |
"/ A_SUPER := 16r000020.
|
|
71 |
"/ A_SYNCHRONIZED := 16r000020.
|
|
72 |
"/ A_VOLATILE := 16r000040.
|
|
73 |
"/ A_TRANSIENT := 16r000080.
|
357
|
74 |
A_NATIVE := 16r000100.
|
349
|
75 |
|
252
|
76 |
A_INTERFACE := 16r000200.
|
|
77 |
A_ABSTRACT := 16r000400.
|
|
78 |
A_OBSOLETE := 16r008000.
|
|
79 |
|
|
80 |
"/ those are local to the ST/X implementation
|
|
81 |
A_INITIALIZED := 16r100000.
|
345
|
82 |
A_SMALLTALK := 16r200000.
|
252
|
83 |
|
451
|
84 |
A_ABSTRACT_OR_INTERFACE := A_ABSTRACT bitOr:A_INTERFACE.
|
|
85 |
|
52
|
86 |
InitialValuePerType := IdentityDictionary new.
|
|
87 |
InitialValuePerType at:$B put:0.
|
|
88 |
InitialValuePerType at:$C put:0.
|
|
89 |
InitialValuePerType at:$D put:0.0.
|
252
|
90 |
InitialValuePerType at:$F put:(0.0 asShortFloat).
|
52
|
91 |
InitialValuePerType at:$I put:0.
|
|
92 |
InitialValuePerType at:$J put:0.
|
|
93 |
InitialValuePerType at:$S put:0.
|
|
94 |
InitialValuePerType at:$Z put:0.
|
|
95 |
InitialValuePerType at:$L put:nil.
|
|
96 |
InitialValuePerType at:$[ put:nil.
|
|
97 |
|
423
|
98 |
ArgumentConversionErrorSignal := ErrorSignal newSignal mayProceed:true.
|
|
99 |
|
52
|
100 |
"
|
|
101 |
JavaClass initialize
|
|
102 |
"
|
345
|
103 |
|
451
|
104 |
"Modified: / 13.11.1998 / 14:09:52 / cg"
|
52
|
105 |
! !
|
|
106 |
|
130
|
107 |
!JavaClass class methodsFor:'instance creation'!
|
1
|
108 |
|
7
|
109 |
fullName:aString
|
90
|
110 |
self shouldNotImplement.
|
|
111 |
^ self new flags:0; setFullName:aString
|
7
|
112 |
|
|
113 |
!
|
|
114 |
|
38
|
115 |
fullName:aString numStatic:nStatic
|
590
|
116 |
|meta cls s ns nameComponents|
|
38
|
117 |
|
130
|
118 |
"/ check for a JAVA nameSpace to exist
|
|
119 |
JAVA isNil ifTrue:[
|
674
|
120 |
NameSpace name:'JAVA'
|
130
|
121 |
].
|
|
122 |
|
38
|
123 |
"create the metaclass first"
|
|
124 |
|
40
|
125 |
meta := Metaclass new.
|
|
126 |
meta setSuperclass:(self).
|
130
|
127 |
meta instSize:(JavaClass instSize + nStatic).
|
172
|
128 |
"/ meta setName:(aString , 'class') asSymbol.
|
|
129 |
"/ meta setClassVariableString:''.
|
252
|
130 |
meta flags:(meta flags bitOr:Behavior flagJavaClass).
|
|
131 |
"/ meta setSuperclass:JavaObject class.
|
38
|
132 |
|
|
133 |
"then let the new meta create the class"
|
|
134 |
cls := meta new.
|
|
135 |
cls setSuperclass:JavaObject.
|
|
136 |
cls instSize:0.
|
130
|
137 |
cls setName:('JAVA::' , aString).
|
38
|
138 |
cls flags:0.
|
590
|
139 |
cls setAccessFlags:0.
|
40
|
140 |
"/ cls setClassVariableString:''.
|
38
|
141 |
cls setInstanceVariableString:''.
|
|
142 |
cls category:#java.
|
590
|
143 |
cls setFullName:aString.
|
40
|
144 |
|
590
|
145 |
"/ java classes do not really have a category;
|
|
146 |
"/ simulate one by separating its name into individual components,
|
|
147 |
"/ prepending 'java'"
|
|
148 |
|
|
149 |
nameComponents := aString asCollectionOfSubstringsSeparatedBy:$/.
|
|
150 |
nameComponents size > 1 ifTrue:[
|
|
151 |
cls category:((nameComponents asStringWith:$/ from:1 to:(nameComponents size - 1))
|
|
152 |
replaceAll:$/ with:$. ).
|
|
153 |
].
|
|
154 |
|
|
155 |
nameComponents size > 1 ifTrue:[
|
|
156 |
cls setPackage:((nameComponents copyWithoutLast:1) asStringWith:$/) asSymbol
|
|
157 |
] ifFalse:[
|
|
158 |
cls setPackage:aString asSymbol
|
|
159 |
].
|
130
|
160 |
|
181
|
161 |
"/ break up the package and create nameSpaces
|
|
162 |
"/ for each package component.
|
|
163 |
"/ This allows java.foo.bar to be visible in ST/X
|
|
164 |
"/ under the name JAVA::java::foo::bar
|
|
165 |
|
|
166 |
ns := JAVA.
|
|
167 |
|
590
|
168 |
nameComponents size > 1 ifTrue:[
|
|
169 |
s := '' writeStream.
|
|
170 |
s nextPutAll:'JAVA'.
|
|
171 |
nameComponents from:1 to:(nameComponents size - 1) do:[:aPart |
|
|
172 |
s nextPutAll:'::'.
|
|
173 |
s nextPutAll:aPart
|
|
174 |
].
|
|
175 |
Metaclass confirmationQuerySignal answer:false do:[
|
|
176 |
Class updateChangeFileQuerySignal answer:false do:[
|
674
|
177 |
ns := NameSpace fullName:(s contents).
|
590
|
178 |
]
|
|
179 |
]
|
181
|
180 |
].
|
675
|
181 |
ns isNameSpace ifTrue:[
|
590
|
182 |
ns at:nameComponents last asSymbol put:cls.
|
197
|
183 |
].
|
181
|
184 |
|
|
185 |
"/ for ST/X browsing
|
130
|
186 |
Smalltalk at:('JAVA::' , aString) asSymbol put:cls.
|
|
187 |
|
38
|
188 |
^ cls
|
|
189 |
|
252
|
190 |
"Created: / 15.4.1996 / 15:52:55 / cg"
|
|
191 |
"Modified: / 3.1.1998 / 22:32:25 / cg"
|
38
|
192 |
!
|
|
193 |
|
1
|
194 |
name:aString
|
7
|
195 |
self shouldNotImplement
|
1
|
196 |
|
|
197 |
"Created: 15.4.1996 / 15:52:55 / cg"
|
|
198 |
! !
|
|
199 |
|
355
|
200 |
!JavaClass class methodsFor:'constants'!
|
|
201 |
|
357
|
202 |
A_NATIVE
|
|
203 |
^ A_NATIVE
|
|
204 |
|
|
205 |
"Created: / 16.5.1998 / 01:18:43 / cg"
|
|
206 |
!
|
|
207 |
|
355
|
208 |
A_PUBLIC
|
|
209 |
^ A_PUBLIC
|
|
210 |
|
|
211 |
"Created: / 13.5.1998 / 13:03:18 / cg"
|
|
212 |
!
|
|
213 |
|
357
|
214 |
A_STATIC
|
|
215 |
^ A_STATIC
|
355
|
216 |
|
357
|
217 |
"Created: / 16.5.1998 / 00:02:07 / cg"
|
355
|
218 |
! !
|
|
219 |
|
229
|
220 |
!JavaClass class methodsFor:'method lookup'!
|
|
221 |
|
423
|
222 |
canConvertArgsToJava:argArray asSpecifiedIn:argSigSpecArray
|
|
223 |
"given a smalltalk argument array, return true, if these can be converted to java objects as appropriate."
|
|
224 |
|
426
|
225 |
argArray
|
|
226 |
with:argSigSpecArray
|
|
227 |
do:[:arg :type |
|
|
228 |
self
|
|
229 |
convertToJava:arg
|
|
230 |
type:type
|
|
231 |
ifFail:[:msg :default| ^ false]].
|
423
|
232 |
^ true
|
|
233 |
|
|
234 |
"Created: / 5.11.1998 / 18:25:05 / cg"
|
426
|
235 |
"Modified: / 6.11.1998 / 00:45:58 / cg"
|
423
|
236 |
!
|
|
237 |
|
426
|
238 |
convertArgsToJava:argArray asSpecifiedIn:argSigSpecArray numArgs:na
|
|
239 |
"given a smalltalk argument array, convert to java objects as appropriate.
|
|
240 |
Currently, only Strings and booleans are converted."
|
|
241 |
|
|
242 |
|sigIndex newArgIndex newArgArray|
|
|
243 |
|
|
244 |
sigIndex := newArgIndex := 1.
|
|
245 |
|
|
246 |
newArgArray := Array new:na.
|
|
247 |
argArray do:[:arg |
|
|
248 |
|type newArg|
|
|
249 |
|
|
250 |
type := argSigSpecArray at:sigIndex.
|
|
251 |
sigIndex := sigIndex + 1.
|
|
252 |
newArg := self convertToJava:arg type:type.
|
|
253 |
newArgArray at:newArgIndex put:newArg.
|
|
254 |
newArgIndex := newArgIndex + 1.
|
|
255 |
(type == #long or:[type == #double]) ifTrue:[
|
|
256 |
newArgIndex > na ifTrue:[
|
|
257 |
self halt:'should not happen'
|
|
258 |
].
|
|
259 |
newArgArray at:newArgIndex put:nil.
|
|
260 |
newArgIndex := newArgIndex + 1.
|
|
261 |
]
|
|
262 |
].
|
|
263 |
|
|
264 |
^ newArgArray
|
|
265 |
|
|
266 |
"Created: / 5.11.1998 / 18:30:57 / cg"
|
|
267 |
"Modified: / 6.11.1998 / 00:45:00 / cg"
|
|
268 |
!
|
|
269 |
|
|
270 |
convertToJava:arg type:type
|
423
|
271 |
"given a smalltalk argument, convert to a java object as appropriate."
|
|
272 |
|
|
273 |
^ self
|
426
|
274 |
convertToJava:arg
|
423
|
275 |
type:type
|
|
276 |
ifFail:[:msg :default |
|
|
277 |
ArgumentConversionErrorSignal
|
|
278 |
raiseWith:arg
|
|
279 |
errorString:msg.
|
|
280 |
default
|
|
281 |
]
|
|
282 |
|
|
283 |
"Modified: / 5.11.1998 / 18:43:33 / cg"
|
426
|
284 |
"Created: / 6.11.1998 / 00:45:13 / cg"
|
423
|
285 |
!
|
|
286 |
|
426
|
287 |
convertToJava:arg type:type ifFail:failBlock
|
423
|
288 |
"given a smalltalk argument, convert to a java object as appropriate.
|
|
289 |
Currently, only a few types are converted."
|
|
290 |
|
546
|
291 |
|expectedCls f failValue|
|
426
|
292 |
|
423
|
293 |
type == #boolean ifTrue:[
|
|
294 |
arg == true ifTrue:[
|
|
295 |
^ 1
|
|
296 |
].
|
|
297 |
arg == false ifTrue:[
|
|
298 |
^ 0
|
|
299 |
].
|
|
300 |
^ failBlock value:('cannot convert argument to ' , type) value:0
|
|
301 |
].
|
|
302 |
|
|
303 |
type == #int ifTrue:[
|
|
304 |
arg isInteger ifTrue:[
|
|
305 |
(arg between:-16r8000000 and:16r7FFFFFFF) ifTrue:[
|
|
306 |
^ arg
|
|
307 |
].
|
|
308 |
^ failBlock value:('integer range; cannot convert argument to ' , type) value:0.
|
|
309 |
].
|
|
310 |
^ failBlock value:('cannot convert argument to ' , type) value:0
|
|
311 |
].
|
|
312 |
|
|
313 |
type == #long ifTrue:[
|
|
314 |
arg isInteger ifTrue:[
|
|
315 |
(arg between:-16r800000000000000 and:16r7FFFFFFFFFFFFFFF) ifTrue:[
|
|
316 |
^ arg
|
|
317 |
].
|
|
318 |
^ failBlock value:('integer range; cannot convert argument to ' , type) value:0
|
|
319 |
].
|
|
320 |
^ failBlock value:('cannot convert argument to ' , type) value:0
|
|
321 |
].
|
|
322 |
|
|
323 |
(type == #float) ifTrue:[
|
|
324 |
arg isReal ifTrue:[
|
|
325 |
^ arg asShortFloat
|
|
326 |
].
|
|
327 |
^ failBlock value:('cannot convert argument to ' , type) value:0.0.
|
|
328 |
].
|
|
329 |
|
433
|
330 |
(type == 'java.lang.Float') ifTrue:[
|
|
331 |
arg isReal ifTrue:[
|
|
332 |
f := (Java at:'java.lang.Float') new.
|
|
333 |
f perform:#'<init>(F)V' with:(arg asShortFloat).
|
|
334 |
self halt.
|
|
335 |
^ f.
|
|
336 |
].
|
|
337 |
^ failBlock value:('cannot convert argument to ' , type) value:0.0.
|
|
338 |
].
|
|
339 |
(type == 'java.lang.Double') ifTrue:[
|
|
340 |
arg isReal ifTrue:[
|
|
341 |
f := (Java at:'java.lang.Double') new.
|
|
342 |
f perform:#'<init>(D)V' with:(arg asFloat).
|
|
343 |
self halt.
|
|
344 |
^ f.
|
|
345 |
].
|
|
346 |
^ failBlock value:('cannot convert argument to ' , type) value:0.0.
|
|
347 |
].
|
|
348 |
|
423
|
349 |
(type == #double) ifTrue:[
|
|
350 |
arg isReal ifTrue:[
|
|
351 |
^ arg asFloat
|
|
352 |
].
|
|
353 |
^ failBlock value:('cannot convert argument to ' , type) value:0.0.
|
|
354 |
].
|
|
355 |
|
|
356 |
(type == #char) ifTrue:[
|
|
357 |
arg isCharacter ifTrue:[
|
|
358 |
^ arg asciiValue
|
|
359 |
].
|
|
360 |
^ failBlock value:('cannot convert argument to ' , type) value:0
|
|
361 |
].
|
|
362 |
|
|
363 |
(type = 'char[]') ifTrue:[
|
|
364 |
arg isString ifTrue:[
|
|
365 |
^ arg
|
|
366 |
].
|
|
367 |
^ failBlock value:('cannot convert argument to ' , type) value:''
|
|
368 |
].
|
|
369 |
|
426
|
370 |
(type = 'int[]') ifTrue:[
|
|
371 |
(arg isArray or:[arg isMemberOf:SignedIntegerArray]) ifTrue:[
|
|
372 |
^ arg
|
|
373 |
].
|
|
374 |
^ failBlock value:('cannot convert argument to ' , type) value:''
|
|
375 |
].
|
|
376 |
(type = 'long[]') ifTrue:[
|
|
377 |
(arg isArray or:[arg isMemberOf:SignedIntegerArray]) ifTrue:[
|
|
378 |
^ arg
|
|
379 |
].
|
|
380 |
^ failBlock value:('cannot convert argument to ' , type) value:''
|
|
381 |
].
|
|
382 |
(type = 'float[]') ifTrue:[
|
|
383 |
(arg isArray or:[arg isMemberOf:FloatArray]) ifTrue:[
|
|
384 |
^ arg
|
|
385 |
].
|
|
386 |
^ failBlock value:('cannot convert argument to ' , type) value:''
|
|
387 |
].
|
|
388 |
(type = 'double[]') ifTrue:[
|
|
389 |
(arg isArray or:[arg isMemberOf:DoubleArray]) ifTrue:[
|
|
390 |
^ arg
|
|
391 |
].
|
|
392 |
^ failBlock value:('cannot convert argument to ' , type) value:''
|
|
393 |
].
|
|
394 |
|
|
395 |
(type endsWith:'[]') ifTrue:[
|
|
396 |
(arg isArray or:[arg isNil]) ifTrue:[
|
|
397 |
^ arg
|
|
398 |
].
|
|
399 |
^ failBlock value:('cannot convert argument to ' , type) value:''
|
|
400 |
].
|
|
401 |
|
423
|
402 |
(type = 'java.lang.Object') ifTrue:[
|
|
403 |
"/ matches any
|
|
404 |
^ arg
|
|
405 |
].
|
|
406 |
(type = 'java.lang.String') ifTrue:[
|
|
407 |
arg isString ifTrue:[
|
|
408 |
^ Java as_String:arg
|
|
409 |
].
|
546
|
410 |
failValue := ''
|
423
|
411 |
].
|
426
|
412 |
expectedCls := Java classForName:type.
|
|
413 |
(arg isKindOf:expectedCls) ifTrue:[
|
|
414 |
"/ matches class and subclasses
|
|
415 |
^ arg
|
|
416 |
].
|
456
|
417 |
arg isNil ifTrue:[
|
|
418 |
"/ matches any
|
|
419 |
^ arg
|
|
420 |
].
|
423
|
421 |
self halt.
|
546
|
422 |
^ failBlock value:('cannot convert argument to ' , type) value:failValue
|
423
|
423 |
|
426
|
424 |
"Created: / 6.11.1998 / 00:46:19 / cg"
|
546
|
425 |
"Modified: / 28.1.1999 / 17:55:17 / cg"
|
423
|
426 |
!
|
|
427 |
|
426
|
428 |
convertToSmalltalk:jObj type:type
|
|
429 |
"given a java return value, convert to a smalltalk object as appropriate.
|
|
430 |
Currently, only a few types are converted."
|
336
|
431 |
|
426
|
432 |
type == #boolean ifTrue:[
|
|
433 |
jObj == 0 ifTrue:[
|
|
434 |
^ false
|
|
435 |
].
|
|
436 |
^ true
|
|
437 |
].
|
|
438 |
|
|
439 |
type == #void ifTrue:[
|
|
440 |
^ nil
|
336
|
441 |
].
|
|
442 |
|
426
|
443 |
(type = 'java.lang.String') ifTrue:[
|
|
444 |
^ Java as_ST_String:jObj
|
|
445 |
].
|
336
|
446 |
|
433
|
447 |
"/ (type = 'java.lang.Float') ifTrue:[
|
|
448 |
"/ ^ jObj instVarNamed:'value'
|
|
449 |
"/ ].
|
|
450 |
"/ (type = 'java.lang.Double') ifTrue:[
|
|
451 |
"/ ^ jObj instVarNamed:'value'
|
|
452 |
"/ ].
|
|
453 |
|
426
|
454 |
(type == #char) ifTrue:[
|
|
455 |
jObj isInteger ifTrue:[
|
|
456 |
^ Character value:jObj
|
|
457 |
].
|
|
458 |
].
|
|
459 |
|
|
460 |
^ jObj
|
|
461 |
|
|
462 |
"Created: / 6.11.1998 / 00:49:53 / cg"
|
433
|
463 |
"Modified: / 11.11.1998 / 02:08:11 / cg"
|
336
|
464 |
!
|
|
465 |
|
236
|
466 |
lookupMethod:selector numArgs:nargs in:aClass static:staticMethod
|
229
|
467 |
"lookup a method"
|
|
468 |
|
|
469 |
|method cls sel|
|
|
470 |
|
|
471 |
sel := selector.
|
|
472 |
(sel includes:$:) ifTrue:[
|
375
|
473 |
sel := sel copyTo:(sel indexOf:$:)-1
|
229
|
474 |
].
|
|
475 |
|
|
476 |
sel := sel asSymbolIfInterned.
|
|
477 |
sel notNil ifTrue:[
|
375
|
478 |
cls := aClass.
|
229
|
479 |
|
375
|
480 |
[cls notNil
|
|
481 |
and:[cls ~~ JavaObject
|
|
482 |
and:[cls ~~ JavaClass]]] whileTrue:[
|
456
|
483 |
cls methodDictionary keysAndValuesDo:[:jSel :m |
|
|
484 |
|aMethod|
|
|
485 |
|
|
486 |
aMethod := m.
|
|
487 |
aMethod isWrapped ifTrue:[
|
|
488 |
aMethod := aMethod originalMethod
|
|
489 |
].
|
|
490 |
|
375
|
491 |
((jSel == sel)
|
|
492 |
or:[aMethod name = sel
|
|
493 |
or:[aMethod signatureNameWithoutReturnType = sel]])
|
|
494 |
ifTrue:[
|
|
495 |
aMethod numArgs == nargs ifTrue:[
|
415
|
496 |
staticMethod == (aMethod isStatic) ifTrue:[
|
456
|
497 |
^ m
|
375
|
498 |
]
|
|
499 |
]
|
|
500 |
]
|
|
501 |
].
|
229
|
502 |
|
375
|
503 |
cls := cls superclass.
|
|
504 |
].
|
229
|
505 |
].
|
375
|
506 |
"/ self halt.
|
229
|
507 |
^ nil
|
|
508 |
|
375
|
509 |
"Created: / 17.8.1997 / 18:25:47 / cg"
|
456
|
510 |
"Modified: / 16.11.1998 / 16:46:48 / cg"
|
415
|
511 |
!
|
|
512 |
|
|
513 |
lookupMethods:selector numArgs:nargs in:aClass static:staticMethod
|
|
514 |
"lookup methods matching a selector.
|
|
515 |
This is a special entry for doesNotUnderstand redirection
|
|
516 |
(the caller must select the one method which fits the argument(s) best."
|
|
517 |
|
|
518 |
|methods cls sel|
|
|
519 |
|
|
520 |
sel := selector.
|
|
521 |
(sel includes:$:) ifTrue:[
|
|
522 |
sel := sel copyTo:(sel indexOf:$:)-1
|
|
523 |
].
|
|
524 |
|
|
525 |
sel := sel asSymbolIfInterned.
|
|
526 |
sel notNil ifTrue:[
|
|
527 |
cls := aClass.
|
|
528 |
|
|
529 |
[cls notNil
|
|
530 |
and:[cls ~~ JavaObject
|
|
531 |
and:[cls ~~ JavaClass]]] whileTrue:[
|
|
532 |
cls methodDictionary keysAndValuesDo:[:jSel :aMethod |
|
|
533 |
((jSel == sel)
|
|
534 |
or:[aMethod name = sel
|
|
535 |
or:[aMethod signatureNameWithoutReturnType = sel]])
|
|
536 |
ifTrue:[
|
|
537 |
(nargs isNil
|
|
538 |
or:[aMethod numArgs == nargs]) ifTrue:[
|
|
539 |
staticMethod == (aMethod isStatic) ifTrue:[
|
|
540 |
methods isNil ifTrue:[
|
|
541 |
methods := OrderedCollection new
|
|
542 |
].
|
|
543 |
methods add:aMethod
|
|
544 |
]
|
|
545 |
]
|
|
546 |
]
|
|
547 |
].
|
|
548 |
|
|
549 |
cls := cls superclass.
|
|
550 |
].
|
|
551 |
].
|
|
552 |
^ methods ? #()
|
|
553 |
|
|
554 |
"Created: / 4.11.1998 / 19:04:51 / cg"
|
|
555 |
"Modified: / 4.11.1998 / 19:31:33 / cg"
|
229
|
556 |
! !
|
|
557 |
|
130
|
558 |
!JavaClass class methodsFor:'signature parsing'!
|
52
|
559 |
|
|
560 |
initialValueFromSignature:aSignature
|
|
561 |
"given a signature, return an initializer value"
|
|
562 |
|
|
563 |
|s|
|
|
564 |
|
|
565 |
s := aSignature readStream.
|
|
566 |
^ self initialValueFromStream:s.
|
|
567 |
|
|
568 |
"
|
|
569 |
JavaClass initialValueFromSignature:'LObject;'
|
|
570 |
JavaClass initialValueFromSignature:'B'
|
|
571 |
JavaClass initialValueFromSignature:'I'
|
|
572 |
"
|
|
573 |
|
|
574 |
|
|
575 |
!
|
|
576 |
|
|
577 |
initialValueFromStream:s
|
|
578 |
"parse a fieldTypeSpec - see java doc"
|
|
579 |
|
|
580 |
|typeChar|
|
|
581 |
|
|
582 |
typeChar := s next.
|
|
583 |
^ InitialValuePerType at:typeChar ifAbsent:nil.
|
|
584 |
! !
|
|
585 |
|
130
|
586 |
!JavaClass class methodsFor:'special'!
|
40
|
587 |
|
435
|
588 |
orderOfClassInits
|
|
589 |
^ OrderOfClassInits
|
|
590 |
|
|
591 |
"Created: / 12.11.1998 / 15:35:57 / cg"
|
|
592 |
!
|
|
593 |
|
40
|
594 |
setInstanceVariableStringFromFields:f in:aClass
|
|
595 |
|varNames|
|
|
596 |
|
|
597 |
varNames := ''.
|
|
598 |
f do:[:aField |
|
172
|
599 |
varNames := varNames , aField name , ' '
|
40
|
600 |
].
|
|
601 |
aClass setInstanceVariableString:varNames.
|
|
602 |
|
|
603 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
435
|
604 |
!
|
|
605 |
|
|
606 |
startRememberingOrderOfClassInits
|
|
607 |
OrderOfClassInits := OrderedCollection new.
|
|
608 |
|
|
609 |
"Created: / 12.11.1998 / 15:26:32 / cg"
|
|
610 |
"Modified: / 12.11.1998 / 15:29:10 / cg"
|
40
|
611 |
! !
|
|
612 |
|
5
|
613 |
!JavaClass methodsFor:'accessing'!
|
|
614 |
|
74
|
615 |
binaryFile
|
|
616 |
^ binaryFilePath
|
|
617 |
!
|
|
618 |
|
7
|
619 |
category
|
590
|
620 |
"java classes do not really have a category;
|
7
|
621 |
simulate one by separating its name into individual components,
|
|
622 |
prepending 'java'"
|
|
623 |
|
|
624 |
|nameComponents|
|
|
625 |
|
|
626 |
nameComponents := fullName asCollectionOfSubstringsSeparatedBy:$/.
|
160
|
627 |
nameComponents size <= 1 ifTrue:[
|
590
|
628 |
^ 'java' "/ fullName
|
160
|
629 |
].
|
252
|
630 |
^ ((nameComponents asStringWith:$/ from:1 to:(nameComponents size - 1)))
|
590
|
631 |
replaceAll:$/ with:$.
|
160
|
632 |
|
175
|
633 |
"Modified: 30.7.1997 / 15:35:22 / cg"
|
7
|
634 |
!
|
|
635 |
|
255
|
636 |
classLoader
|
|
637 |
^ classLoader
|
|
638 |
!
|
|
639 |
|
|
640 |
classLoader:aJavaClassLoaderOrNil
|
|
641 |
classLoader := aJavaClassLoaderOrNil
|
|
642 |
!
|
|
643 |
|
651
|
644 |
compiledMethodAt:name
|
|
645 |
"redefined to find the constructor"
|
|
646 |
|
|
647 |
|m|
|
|
648 |
|
|
649 |
m := super compiledMethodAt:name.
|
|
650 |
m isNil ifTrue:[
|
|
651 |
name = self lastName ifTrue:[
|
|
652 |
^ super compiledMethodAt:#'<init>()V'
|
|
653 |
].
|
|
654 |
].
|
|
655 |
^ m
|
|
656 |
|
|
657 |
"
|
|
658 |
JAVA::java::lang::Object compiledMethodAt:#Object
|
|
659 |
"
|
|
660 |
|
|
661 |
"Created: / 24.12.1999 / 02:02:50 / cg"
|
|
662 |
"Modified: / 24.12.1999 / 02:04:46 / cg"
|
|
663 |
!
|
|
664 |
|
185
|
665 |
compiledMethodAt:name signature:sig
|
|
666 |
"lookup the classes methodDictionary"
|
|
667 |
|
|
668 |
methodDictionary keysAndValuesDo:[:mFullSelector :aMethod |
|
252
|
669 |
aMethod name == name ifTrue:[
|
|
670 |
aMethod signature == sig ifTrue:[
|
|
671 |
^ aMethod
|
|
672 |
]
|
|
673 |
]
|
185
|
674 |
].
|
|
675 |
^ nil
|
|
676 |
|
|
677 |
"Created: 1.8.1997 / 00:01:58 / cg"
|
|
678 |
!
|
|
679 |
|
5
|
680 |
constantPool
|
|
681 |
^ constantPool
|
7
|
682 |
!
|
|
683 |
|
83
|
684 |
fields
|
|
685 |
^ fields
|
|
686 |
!
|
|
687 |
|
7
|
688 |
fullName
|
|
689 |
^ fullName
|
8
|
690 |
!
|
|
691 |
|
110
|
692 |
interfaces
|
|
693 |
interfaces notNil ifTrue:[
|
172
|
694 |
interfaces := interfaces collect:[:clsRef |
|
|
695 |
clsRef isUnresolved ifTrue:[
|
|
696 |
clsRef preResolve
|
|
697 |
] ifFalse:[
|
|
698 |
clsRef
|
|
699 |
]
|
|
700 |
].
|
110
|
701 |
].
|
|
702 |
^ interfaces
|
|
703 |
!
|
|
704 |
|
90
|
705 |
javaClass
|
|
706 |
^ self
|
|
707 |
!
|
|
708 |
|
691
|
709 |
javaName
|
|
710 |
"the javaname - as seen by a java programmer.
|
|
711 |
(with '/'s replaced by dots) extract from the fullName"
|
|
712 |
|
|
713 |
^ fullName copyReplaceAll:$/ with:$.
|
|
714 |
|
|
715 |
"
|
|
716 |
Java allClasses first fullName
|
|
717 |
Java allClasses first name
|
|
718 |
Java allClasses first javaName
|
|
719 |
Java allClasses first javaPackage
|
|
720 |
Java allClasses first package
|
|
721 |
"
|
|
722 |
!
|
|
723 |
|
684
|
724 |
javaPackage
|
|
725 |
"the javaPackage - as seen by a java programmer.
|
|
726 |
(with '/'s replaced by dots) extract from the fullName"
|
|
727 |
|
|
728 |
|components|
|
|
729 |
|
|
730 |
components := fullName asCollectionOfSubstringsSeparatedBy:$/.
|
|
731 |
components size > 1 ifTrue:[
|
|
732 |
^ (components copyWithoutLast:1) asStringWith:$.
|
|
733 |
].
|
|
734 |
^ fullName
|
|
735 |
|
|
736 |
"
|
|
737 |
Java allClasses first fullName
|
|
738 |
Java allClasses first javaPackage
|
|
739 |
Java allClasses first package
|
|
740 |
"
|
|
741 |
!
|
|
742 |
|
423
|
743 |
lastName
|
|
744 |
^ fullName copyFrom:(fullName lastIndexOf:$/)+1
|
|
745 |
|
|
746 |
"Created: / 5.11.1998 / 19:16:00 / cg"
|
|
747 |
!
|
|
748 |
|
8
|
749 |
name
|
27
|
750 |
^ name "/ fullName
|
22
|
751 |
!
|
|
752 |
|
130
|
753 |
nameSpace
|
|
754 |
^ JAVA
|
|
755 |
|
|
756 |
"Created: 20.1.1997 / 13:04:30 / cg"
|
|
757 |
!
|
|
758 |
|
|
759 |
nameWithoutNameSpacePrefix
|
|
760 |
^ fullName
|
|
761 |
|
|
762 |
"Created: 20.1.1997 / 13:05:30 / cg"
|
|
763 |
!
|
|
764 |
|
|
765 |
nameWithoutPrefix
|
|
766 |
^ fullName
|
|
767 |
|
|
768 |
"Created: 20.1.1997 / 13:06:06 / cg"
|
|
769 |
!
|
|
770 |
|
22
|
771 |
package
|
684
|
772 |
"the package (as seen by a smalltalk programmer)
|
|
773 |
extract from the fullName, (with '/'s) and prepend 'java:'"
|
22
|
774 |
|
686
|
775 |
|components p i|
|
|
776 |
|
|
777 |
i := fullName lastIndexOf:$/.
|
|
778 |
p := fullName copyTo:i - 1.
|
689
|
779 |
p size == 0 ifTrue:[
|
|
780 |
^ 'java'
|
|
781 |
].
|
686
|
782 |
"/ components := fullName asCollectionOfSubstringsSeparatedBy:$/.
|
|
783 |
"/ components size > 1 ifTrue:[
|
|
784 |
"/ p := (components copyWithoutLast:1) asStringWith:$/
|
|
785 |
"/ ] ifFalse:[
|
|
786 |
"/ p := fullName
|
|
787 |
"/ ].
|
|
788 |
|
684
|
789 |
^ 'java:' , p
|
22
|
790 |
|
|
791 |
"
|
684
|
792 |
Java allClasses first fullName
|
|
793 |
Java allClasses first package
|
|
794 |
Java allClasses first javaPackage
|
22
|
795 |
"
|
24
|
796 |
!
|
|
797 |
|
76
|
798 |
source
|
|
799 |
^ Java classSourceOf:self
|
|
800 |
|
|
801 |
"
|
|
802 |
(Java at:'java.awt.Frame') source
|
175
|
803 |
(Java at:'ArcTest') source
|
|
804 |
(Java at:'ArcCanvas') source
|
76
|
805 |
"
|
175
|
806 |
|
|
807 |
"Modified: 30.7.1997 / 14:31:01 / cg"
|
76
|
808 |
!
|
|
809 |
|
24
|
810 |
sourceFile
|
|
811 |
^ sourceFile
|
83
|
812 |
!
|
|
813 |
|
|
814 |
staticFields
|
|
815 |
^ staticFields
|
132
|
816 |
!
|
|
817 |
|
|
818 |
typeOfField:aFieldName
|
|
819 |
|
|
820 |
fields do:[:aField |
|
172
|
821 |
aField name = aFieldName ifTrue:[
|
|
822 |
^ aField type
|
|
823 |
]
|
132
|
824 |
].
|
|
825 |
self error:'no such field'
|
|
826 |
|
|
827 |
"
|
|
828 |
(JAVA at:#'java/awt/image/ColorModel') typeOfField:'pixel_bits'
|
|
829 |
"
|
|
830 |
|
|
831 |
"Modified: 21.1.1997 / 22:48:28 / cg"
|
5
|
832 |
! !
|
|
833 |
|
213
|
834 |
!JavaClass methodsFor:'adding / removing'!
|
|
835 |
|
|
836 |
removeFromSystem
|
|
837 |
Java removeClass:self
|
|
838 |
|
|
839 |
"Created: 12.8.1997 / 02:46:51 / cg"
|
|
840 |
! !
|
|
841 |
|
261
|
842 |
!JavaClass methodsFor:'browser interface'!
|
|
843 |
|
|
844 |
isVisualStartable
|
|
845 |
"return true, if this is an application class,
|
|
846 |
which can be started via #open"
|
|
847 |
|
413
|
848 |
"/ if I have a main() method, I am
|
|
849 |
|
|
850 |
(self compiledMethodAt:#'main([Ljava/lang/String;)V') notNil ifTrue:[
|
|
851 |
^ true
|
|
852 |
].
|
261
|
853 |
|
413
|
854 |
"/ NEEDS startApplet to work ...
|
|
855 |
"/ "/ if I inherit from Applet, I am
|
|
856 |
"/
|
|
857 |
"/ (self isSubclassOf:(Java at:'java.applet.Applet')) ifTrue:[
|
|
858 |
"/ ^ true.
|
|
859 |
"/ ].
|
|
860 |
|
|
861 |
^ false
|
|
862 |
|
|
863 |
"Modified: / 3.11.1998 / 23:04:59 / cg"
|
261
|
864 |
!
|
|
865 |
|
|
866 |
open
|
|
867 |
"start a thread for my main method"
|
|
868 |
|
413
|
869 |
"/ if I have a main, call it ...
|
|
870 |
|
|
871 |
(self compiledMethodAt:#'main([Ljava/lang/String;)V') notNil ifTrue:[
|
|
872 |
^ self startMain
|
|
873 |
].
|
|
874 |
|
|
875 |
"/ otherwise, create a frame and wrap me;
|
|
876 |
"/ as in:
|
|
877 |
|
|
878 |
"/ public static void main(String args[]) {
|
|
879 |
"/ Frame f = new Frame("myName");
|
|
880 |
"/ mySelf me = new mySelf();
|
|
881 |
"/
|
|
882 |
"/ me.init();
|
|
883 |
"/ me.start();
|
|
884 |
"/
|
|
885 |
"/ f.add("Center", me);
|
|
886 |
"/ f.setSize(300, 300);
|
|
887 |
"/ f.show();
|
|
888 |
"/ }
|
|
889 |
|
|
890 |
^ self startApplet
|
261
|
891 |
|
|
892 |
"Created: / 15.1.1998 / 17:18:30 / cg"
|
413
|
893 |
"Modified: / 3.11.1998 / 22:51:47 / cg"
|
261
|
894 |
! !
|
|
895 |
|
183
|
896 |
!JavaClass methodsFor:'compiler interface'!
|
|
897 |
|
566
|
898 |
browserClass
|
|
899 |
"return the browser to use for this class -
|
|
900 |
this can be redefined in special classes, to get different browsers"
|
|
901 |
|
679
|
902 |
"/ ^ JavaBrowser
|
|
903 |
^ super browserClass.
|
566
|
904 |
|
|
905 |
"Modified: / 14.10.1998 / 15:28:38 / cg"
|
|
906 |
!
|
|
907 |
|
183
|
908 |
compilerClass
|
|
909 |
"return the compiler to use for this class -
|
566
|
910 |
this can be redefined in special classes, to compile classes with
|
183
|
911 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
|
|
912 |
|
566
|
913 |
^ JavaCompiler ? Compiler
|
183
|
914 |
!
|
|
915 |
|
|
916 |
evaluatorClass
|
|
917 |
"return the compiler to use for expression evaluation for this class -
|
566
|
918 |
this can be redefined in special classes, to evaluate expressions with
|
183
|
919 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
|
|
920 |
|
566
|
921 |
^ JavaParser ? Parser.
|
197
|
922 |
|
183
|
923 |
!
|
|
924 |
|
|
925 |
parserClass
|
|
926 |
"return the parser to use for parsing this class -
|
566
|
927 |
this can be redefined in special classes, to parse classes with
|
183
|
928 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
|
|
929 |
|
566
|
930 |
^ JavaParser ? Parser.
|
|
931 |
|
|
932 |
!
|
197
|
933 |
|
566
|
934 |
syntaxHighlighterClass
|
|
935 |
"return the class to use for syntaxHighlighting (prettyPrinting) this class -
|
|
936 |
this can be redefined in special classes, to highlight classes with
|
|
937 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
|
183
|
938 |
|
570
|
939 |
^ JavaSyntaxHighlighter "/ ? SyntaxHighlighter
|
183
|
940 |
! !
|
|
941 |
|
624
|
942 |
!JavaClass methodsFor:'compiling'!
|
|
943 |
|
|
944 |
recompileMethodsAccessingGlobal:aGlobalKey
|
|
945 |
"/ dummy for now
|
|
946 |
|
|
947 |
"Created: / 9.11.1999 / 16:42:09 / cg"
|
|
948 |
! !
|
|
949 |
|
160
|
950 |
!JavaClass methodsFor:'documentation support'!
|
|
951 |
|
626
|
952 |
htmlDocumentation
|
|
953 |
^ nil "/ replace by access to javadoc-generated documentation later
|
160
|
954 |
|
626
|
955 |
"Modified: 22.3.1997 / 14:18:50 / cg"
|
160
|
956 |
! !
|
|
957 |
|
312
|
958 |
!JavaClass methodsFor:'executing programs'!
|
|
959 |
|
626
|
960 |
startApplet
|
|
961 |
|f me stub|
|
|
962 |
|
|
963 |
"/ TODO: setup embeddedAppletFrame correctly
|
|
964 |
"/ (for getParameter to work ...)
|
|
965 |
|
|
966 |
"/ create a frame and wrap me;
|
|
967 |
"/ as in:
|
413
|
968 |
|
626
|
969 |
"/ public static void main(String args[]) {
|
|
970 |
"/ Frame f = new Frame("myName");
|
|
971 |
"/ mySelf me = new mySelf();
|
|
972 |
"/
|
|
973 |
"/ me.init();
|
|
974 |
"/ me.start();
|
|
975 |
"/
|
|
976 |
"/ f.add("Center", me);
|
|
977 |
"/ f.setSize(300, 300);
|
|
978 |
"/ f.show();
|
|
979 |
"/ }
|
|
980 |
f := (Java at:'java.awt.Frame') basicNew.
|
|
981 |
f perform:#'<init>(Ljava/lang/String;)V' with:(Java as_String:self name).
|
|
982 |
self halt.
|
|
983 |
me := self basicNew.
|
|
984 |
me perform:#'<init>()V'.
|
|
985 |
self halt.
|
413
|
986 |
|
626
|
987 |
stub := (Java at:'netscape.applet.EmbeddedAppletFrame') new.
|
|
988 |
me instVarNamed:'stub' put:stub.
|
|
989 |
self halt.
|
|
990 |
|
|
991 |
me perform:#'init()V'.
|
|
992 |
me perform:#'start()V'.
|
|
993 |
self halt.
|
|
994 |
|
|
995 |
f perform:#'add(Ljava/lang/String;Ljava/awt/Component;)Ljava/awt/Component;'
|
|
996 |
with:(Java as_String:'Center')
|
|
997 |
with:me.
|
|
998 |
self halt.
|
413
|
999 |
f perform:#'setSize(II)V' with:300 with:300.
|
|
1000 |
self halt.
|
|
1001 |
f perform:#'show()V'.
|
|
1002 |
self halt.
|
|
1003 |
|
|
1004 |
"Modified: / 3.11.1998 / 23:04:41 / cg"
|
|
1005 |
!
|
|
1006 |
|
626
|
1007 |
startMain
|
|
1008 |
"start a thread for my main() method"
|
|
1009 |
|
|
1010 |
^ self startMainWithArgumentString:nil
|
|
1011 |
|
|
1012 |
"Modified: / 30.12.1998 / 20:24:58 / cg"
|
|
1013 |
!
|
312
|
1014 |
|
626
|
1015 |
startMainWithArgumentString:aCommandLineString
|
|
1016 |
"start a thread for my main() method, passing a string with arguments"
|
|
1017 |
|
|
1018 |
|p|
|
312
|
1019 |
|
626
|
1020 |
p := Java javaProcessForMainOf:self argumentString:aCommandLineString.
|
|
1021 |
p notNil ifTrue:[
|
|
1022 |
p resume.
|
|
1023 |
Object abortSignal handle:[:ex |
|
|
1024 |
p == JavaVM javaScreenUpdaterThread ifTrue:[self halt].
|
654
|
1025 |
p == JavaVM javaEventQueueThread ifTrue:[self halt].
|
626
|
1026 |
p terminate.
|
|
1027 |
ex reject.
|
508
|
1028 |
] do:[
|
|
1029 |
p waitUntilTerminated
|
|
1030 |
].
|
|
1031 |
]
|
|
1032 |
|
654
|
1033 |
"Modified: / 24.12.1999 / 02:35:04 / cg"
|
626
|
1034 |
! !
|
312
|
1035 |
|
626
|
1036 |
!JavaClass methodsFor:'fileOut'!
|
|
1037 |
|
|
1038 |
basicFileOutDefinitionOn:aStream withNameSpace:nameSpaceBoolean
|
160
|
1039 |
JavaDecompiler definitionOf:self on:aStream
|
|
1040 |
|
|
1041 |
"Modified: 22.3.1997 / 14:30:28 / cg"
|
626
|
1042 |
!
|
|
1043 |
|
|
1044 |
fileOut
|
|
1045 |
self warn:'fileOut not yet supported'
|
|
1046 |
|
|
1047 |
"Modified: 22.3.1997 / 14:30:28 / cg"
|
|
1048 |
"Created: 22.3.1997 / 14:35:43 / cg"
|
130
|
1049 |
! !
|
|
1050 |
|
43
|
1051 |
!JavaClass methodsFor:'java initialization'!
|
|
1052 |
|
626
|
1053 |
classInit
|
|
1054 |
"call the classes JAVA clinit function"
|
|
1055 |
|
|
1056 |
|m|
|
|
1057 |
|
|
1058 |
(accessFlags bitAnd:A_INITIALIZED) ~~ 0 ifTrue:[^ self].
|
|
1059 |
|
|
1060 |
accessFlags := accessFlags bitOr:A_INITIALIZED.
|
|
1061 |
|
|
1062 |
superclass ~~ JavaObject ifTrue:[
|
|
1063 |
superclass classInit
|
|
1064 |
].
|
|
1065 |
"/ "/ also, all referenced classes must be ...
|
|
1066 |
"/ constantPool classReferencesDo:[:aClass |
|
|
1067 |
"/ aClass classInit
|
|
1068 |
"/ ].
|
43
|
1069 |
|
626
|
1070 |
m := self compiledMethodAt:#'<clinit>()V'.
|
|
1071 |
m notNil ifTrue:[
|
|
1072 |
"/ 'calling clinit() of ' print. self fullName printNL.
|
|
1073 |
[
|
|
1074 |
OrderOfClassInits notNil ifTrue:[
|
|
1075 |
OrderOfClassInits add:self.
|
|
1076 |
].
|
435
|
1077 |
|
626
|
1078 |
m
|
|
1079 |
valueWithReceiver:self
|
|
1080 |
arguments:#()
|
|
1081 |
selector:#'<clinit>()V'
|
|
1082 |
search:self class
|
|
1083 |
sender:nil
|
|
1084 |
] valueOnUnwindDo:[
|
|
1085 |
accessFlags := accessFlags bitXor:A_INITIALIZED.
|
|
1086 |
]
|
|
1087 |
] ifFalse:[
|
|
1088 |
"/ self fullName print. ' has no clinit()' printNL.
|
|
1089 |
].
|
|
1090 |
|
|
1091 |
"
|
|
1092 |
JavaVM instructionTrace:true.
|
|
1093 |
JavaVM callTrace:true.
|
|
1094 |
|
|
1095 |
(Java classNamed:'java.lang.String') classInit
|
|
1096 |
(Java classNamed:'java.lang.System') classInit
|
|
1097 |
|
|
1098 |
(Java classNamed:'java/io/FileDescriptor') classInit
|
43
|
1099 |
(Java classNamed:'java.util.Properties') classInit
|
|
1100 |
"
|
175
|
1101 |
|
435
|
1102 |
"Modified: / 12.11.1998 / 15:41:11 / cg"
|
626
|
1103 |
!
|
|
1104 |
|
|
1105 |
initializeStaticFields
|
|
1106 |
staticFields isNil ifTrue:[^ self].
|
|
1107 |
|
|
1108 |
staticFields do:[:f |
|
|
1109 |
|val type|
|
86
|
1110 |
|
626
|
1111 |
(val := f constantValue) isNil ifTrue:[
|
|
1112 |
"/ careful: int/long etc. constants must be initialized
|
|
1113 |
"/ with correct type.
|
|
1114 |
type := f type.
|
|
1115 |
type == #long ifTrue:[
|
|
1116 |
val := 0.
|
|
1117 |
] ifFalse:[type == #int ifTrue:[
|
|
1118 |
val := 0.
|
|
1119 |
] ifFalse:[type == #float ifTrue:[
|
|
1120 |
val := 0.0 asShortFloat
|
|
1121 |
] ifFalse:[type == #double ifTrue:[
|
|
1122 |
val := 0.0
|
|
1123 |
] ifFalse:[type == #byte ifTrue:[
|
|
1124 |
val := 0.
|
|
1125 |
] ifFalse:[type == #char ifTrue:[
|
|
1126 |
val := 0.
|
|
1127 |
] ifFalse:[type == #'unsigned short' ifTrue:[
|
|
1128 |
val := 0.
|
|
1129 |
] ifFalse:[type == #boolean ifTrue:[
|
172
|
1130 |
val := 0.
|
|
1131 |
]]]]]]]].
|
|
1132 |
].
|
|
1133 |
self instVarNamed:(f name) put:val.
|
60
|
1134 |
].
|
626
|
1135 |
! !
|
|
1136 |
|
|
1137 |
!JavaClass methodsFor:'java instance creation'!
|
29
|
1138 |
|
626
|
1139 |
initValueFor:instVarName
|
|
1140 |
|idx field|
|
|
1141 |
|
|
1142 |
idx := fields findFirst:[:field | field name = instVarName].
|
|
1143 |
idx == 0 ifTrue:[
|
|
1144 |
superclass ~~ JavaObject ifTrue:[
|
172
|
1145 |
^ superclass initValueFor:instVarName
|
|
1146 |
].
|
|
1147 |
self halt
|
52
|
1148 |
] ifFalse:[
|
172
|
1149 |
field := fields at:idx.
|
|
1150 |
^ field initialValue
|
52
|
1151 |
].
|
|
1152 |
!
|
|
1153 |
|
626
|
1154 |
new
|
|
1155 |
"create a new instance, preset its fields,
|
|
1156 |
and call its JAVA init function"
|
|
1157 |
|
|
1158 |
|newJavaObject|
|
|
1159 |
|
|
1160 |
newJavaObject := self newCleared.
|
|
1161 |
newJavaObject perform:#'<init>()V'.
|
|
1162 |
^ newJavaObject
|
|
1163 |
|
|
1164 |
"
|
|
1165 |
(Java classNamed:'java.lang.String') basicNew inspect
|
|
1166 |
(Java classNamed:'java.lang.String') newCleared inspect
|
52
|
1167 |
(Java classNamed:'java.lang.String') new inspect
|
|
1168 |
"
|
|
1169 |
|
415
|
1170 |
"Modified: / 4.11.1998 / 18:04:34 / cg"
|
52
|
1171 |
!
|
|
1172 |
|
626
|
1173 |
newCleared
|
|
1174 |
"create a new cleared JAVA instance.
|
|
1175 |
Its instVars are cleared to the corresponding typed values;
|
|
1176 |
however, <init> is not invoked for it."
|
|
1177 |
|
|
1178 |
|newJavaObject sz "{ Class: SmallInteger }" |
|
|
1179 |
|
|
1180 |
(accessFlags bitAnd:A_ABSTRACT_OR_INTERFACE) ~~ 0 ifTrue:[
|
|
1181 |
JavaVM throwInstantiationExceptionFor:self.
|
|
1182 |
^ nil
|
|
1183 |
].
|
|
1184 |
|
|
1185 |
newJavaObject := super basicNew.
|
|
1186 |
initValues notNil ifTrue:[
|
|
1187 |
sz := self instSize.
|
|
1188 |
1 to:sz do:[:i |
|
|
1189 |
newJavaObject instVarAt:i put:(initValues at:i)
|
|
1190 |
].
|
|
1191 |
].
|
|
1192 |
|
|
1193 |
^ newJavaObject
|
|
1194 |
|
|
1195 |
"
|
|
1196 |
(Java classNamed:'java.lang.String') basicNew inspect
|
|
1197 |
(Java classNamed:'java.lang.String') newCleared inspect
|
43
|
1198 |
(Java classNamed:'java.lang.String') new inspect
|
|
1199 |
"
|
148
|
1200 |
|
451
|
1201 |
"Modified: / 13.11.1998 / 14:10:45 / cg"
|
|
1202 |
!
|
|
1203 |
|
626
|
1204 |
newWith_String:argString
|
|
1205 |
"create a new instance, preset its fields,
|
|
1206 |
and call its JAVA init function passing a String arg"
|
|
1207 |
|
|
1208 |
|newJavaObject|
|
|
1209 |
|
|
1210 |
newJavaObject := self newCleared.
|
|
1211 |
newJavaObject
|
|
1212 |
perform:#'<init>(Ljava/lang/String;)V'
|
|
1213 |
with:(Java as_String:argString).
|
|
1214 |
^ newJavaObject
|
|
1215 |
|
|
1216 |
"
|
|
1217 |
((Java classNamed:'java.lang.ArrayStoreException') newWith_String:'foo') inspect
|
|
1218 |
"
|
|
1219 |
|
|
1220 |
"Modified: / 4.11.1998 / 18:04:34 / cg"
|
|
1221 |
"Created: / 13.11.1998 / 14:17:01 / cg"
|
|
1222 |
!
|
|
1223 |
|
|
1224 |
newWith_int:arg
|
|
1225 |
"create a new instance, preset its fields,
|
|
1226 |
and call its JAVA init function passing an int arg"
|
|
1227 |
|
|
1228 |
|newJavaObject|
|
|
1229 |
|
|
1230 |
newJavaObject := self newCleared.
|
|
1231 |
newJavaObject perform:#'<init>(I)V' with:arg.
|
|
1232 |
^ newJavaObject
|
|
1233 |
|
|
1234 |
"
|
|
1235 |
((Java classNamed:'java.lang.Integer') newWith_int:123) inspect
|
451
|
1236 |
"
|
|
1237 |
|
|
1238 |
"Modified: / 4.11.1998 / 18:04:34 / cg"
|
|
1239 |
"Created: / 13.11.1998 / 14:17:01 / cg"
|
43
|
1240 |
! !
|
|
1241 |
|
229
|
1242 |
!JavaClass methodsFor:'message sending'!
|
43
|
1243 |
|
626
|
1244 |
doesNotUnderstand:aMessage
|
|
1245 |
"as a courtesy to the smalltalker, try to map static methods as
|
|
1246 |
Smalltalk-class methods"
|
|
1247 |
|
|
1248 |
|r args numArgs methods javaMethod sel anyMethodsFound argType
|
|
1249 |
argSignature newArgs oArgIdx nArgIdx canConvert
|
|
1250 |
retVal|
|
|
1251 |
|
|
1252 |
args := aMessage arguments.
|
|
1253 |
numArgs := args size.
|
|
1254 |
sel := aMessage selector.
|
|
1255 |
|
|
1256 |
methods := JavaClass lookupMethods:sel numArgs:numArgs in:self static:true.
|
|
1257 |
methods size == 1 ifTrue:[
|
|
1258 |
javaMethod := methods first.
|
|
1259 |
"/ there is only one - try that one.
|
|
1260 |
] ifFalse:[
|
|
1261 |
methods size > 1 ifTrue:[
|
|
1262 |
"/ more than one - select the ones that could be used.
|
|
1263 |
methods := methods select:[:aMethod |
|
|
1264 |
|argSignature|
|
|
1265 |
|
|
1266 |
argSignature := aMethod argSignature.
|
|
1267 |
(JavaClass canConvertArgsToJava:args asSpecifiedIn:argSignature)
|
|
1268 |
].
|
|
1269 |
methods size == 1 ifTrue:[
|
|
1270 |
javaMethod := methods first.
|
|
1271 |
]
|
|
1272 |
]
|
|
1273 |
].
|
79
|
1274 |
|
626
|
1275 |
javaMethod notNil ifTrue:[
|
|
1276 |
(ArgumentConversionErrorSignal catch:[
|
|
1277 |
args notNil ifTrue:[
|
|
1278 |
args := JavaClass
|
|
1279 |
convertArgsToJava:args
|
|
1280 |
asSpecifiedIn:(javaMethod argSignature)
|
|
1281 |
numArgs:numArgs.
|
|
1282 |
].
|
|
1283 |
]) ifFalse:[
|
|
1284 |
retVal := javaMethod
|
|
1285 |
valueWithReceiver:self "/ (javaMethod javaClass)
|
|
1286 |
arguments:args
|
|
1287 |
selector:(javaMethod selector)
|
|
1288 |
search:self "/ (javaMethod javaClass class)
|
|
1289 |
sender:nil.
|
|
1290 |
^ JavaClass convertToSmalltalk:retVal type:(javaMethod returnType).
|
|
1291 |
].
|
|
1292 |
^ MessageNotUnderstoodSignal
|
|
1293 |
raiseRequestWith:aMessage
|
|
1294 |
errorString:'no method for given argument(s)'
|
|
1295 |
in:thisContext "sender"
|
|
1296 |
].
|
|
1297 |
|
|
1298 |
anyMethodsFound := false.
|
|
1299 |
|
|
1300 |
"/ try all with that name (the number of args could be different ...
|
415
|
1301 |
|
626
|
1302 |
methods := JavaClass lookupMethods:sel numArgs:nil in:self static:true.
|
|
1303 |
methods size > 0 ifTrue:[
|
|
1304 |
anyMethodsFound := true.
|
|
1305 |
numArgs > 0 ifTrue:[
|
|
1306 |
methods do:[:methodToTry |
|
|
1307 |
(ArgumentConversionErrorSignal catch:[
|
|
1308 |
newArgs := JavaClass
|
|
1309 |
convertArgsToJava:args
|
|
1310 |
asSpecifiedIn:(methodToTry argSignature)
|
|
1311 |
numArgs:methodToTry numArgs.
|
|
1312 |
]) ifFalse:[
|
|
1313 |
retVal := methodToTry
|
|
1314 |
valueWithReceiver:self "/ (methodToTry javaClass)
|
|
1315 |
arguments:newArgs
|
|
1316 |
selector:(methodToTry selector)
|
|
1317 |
search:self "/ (methodToTry javaClass class)
|
|
1318 |
sender:nil.
|
|
1319 |
^ JavaClass convertToSmalltalk:retVal type:(methodToTry returnType).
|
|
1320 |
].
|
|
1321 |
].
|
|
1322 |
]
|
|
1323 |
].
|
|
1324 |
|
|
1325 |
anyMethodsFound ifTrue:[
|
|
1326 |
methods size == 1 ifTrue:[
|
|
1327 |
javaMethod := methods first.
|
|
1328 |
|
|
1329 |
^ MessageNotUnderstoodSignal
|
|
1330 |
raiseRequestWith:aMessage
|
|
1331 |
errorString:(sel , ' expects ' , javaMethod argSignature size printString , ' argument(s)')
|
|
1332 |
in:thisContext "sender"
|
|
1333 |
].
|
|
1334 |
^ MessageNotUnderstoodSignal
|
|
1335 |
raiseRequestWith:aMessage
|
|
1336 |
errorString:'no method for given argument count or type'
|
|
1337 |
in:thisContext "sender"
|
415
|
1338 |
].
|
|
1339 |
^ super doesNotUnderstand:aMessage
|
|
1340 |
|
426
|
1341 |
"Modified: / 6.11.1998 / 00:57:22 / cg"
|
79
|
1342 |
!
|
|
1343 |
|
626
|
1344 |
lookupMethodFor:selector
|
|
1345 |
|method cls sel|
|
|
1346 |
|
|
1347 |
sel := selector asSymbolIfInterned.
|
|
1348 |
sel notNil ifTrue:[
|
|
1349 |
cls := self.
|
|
1350 |
[cls notNil] whileTrue:[
|
172
|
1351 |
method := cls compiledMethodAt:sel.
|
|
1352 |
method notNil ifTrue:[ ^ method ].
|
|
1353 |
cls := cls superclass.
|
|
1354 |
].
|
43
|
1355 |
].
|
|
1356 |
|
|
1357 |
^ nil
|
438
|
1358 |
!
|
|
1359 |
|
626
|
1360 |
performStatic:selector
|
|
1361 |
"send a static message, without args."
|
|
1362 |
|
|
1363 |
|javaMethod sel|
|
|
1364 |
|
|
1365 |
sel := selector asSymbolIfInterned.
|
|
1366 |
sel notNil ifTrue:[
|
|
1367 |
javaMethod := methodDictionary at:sel.
|
|
1368 |
javaMethod notNil ifTrue:[
|
|
1369 |
javaMethod isStatic ifTrue:[
|
|
1370 |
^ javaMethod
|
|
1371 |
valueWithReceiver:self
|
|
1372 |
arguments:#()
|
|
1373 |
]
|
|
1374 |
].
|
|
1375 |
].
|
|
1376 |
|
|
1377 |
^ self doesNotUnderstand:(Message selector:selector)
|
438
|
1378 |
|
|
1379 |
"Modified: / 15.1.1998 / 00:31:27 / cg"
|
|
1380 |
"Created: / 12.11.1998 / 16:29:20 / cg"
|
626
|
1381 |
!
|
|
1382 |
|
|
1383 |
performStatic:selector with:arg
|
|
1384 |
"send a static message, with one args."
|
|
1385 |
|
|
1386 |
|javaMethod sel|
|
|
1387 |
|
|
1388 |
sel := selector asSymbolIfInterned.
|
|
1389 |
sel notNil ifTrue:[
|
|
1390 |
javaMethod := methodDictionary at:sel.
|
|
1391 |
javaMethod notNil ifTrue:[
|
|
1392 |
javaMethod isStatic ifTrue:[
|
|
1393 |
^ javaMethod
|
|
1394 |
valueWithReceiver:self
|
|
1395 |
arguments:(Array with:arg)
|
|
1396 |
]
|
|
1397 |
].
|
|
1398 |
].
|
|
1399 |
|
|
1400 |
^ self doesNotUnderstand:(Message selector:selector argument:arg)
|
|
1401 |
|
|
1402 |
"Modified: / 15.1.1998 / 00:31:27 / cg"
|
|
1403 |
"Created: / 10.12.1998 / 21:50:29 / cg"
|
29
|
1404 |
! !
|
|
1405 |
|
160
|
1406 |
!JavaClass methodsFor:'printOut'!
|
|
1407 |
|
626
|
1408 |
printNameInHierarchy
|
|
1409 |
"return my name as printed in the hierarchy"
|
160
|
1410 |
|
626
|
1411 |
^ self displayString
|
|
1412 |
|
|
1413 |
"Modified: 22.3.1997 / 14:16:55 / cg"
|
160
|
1414 |
!
|
|
1415 |
|
626
|
1416 |
printOutOn:aStream
|
|
1417 |
self warn:'printOut not yet supported'
|
160
|
1418 |
|
626
|
1419 |
"Created: 22.3.1997 / 14:36:12 / cg"
|
|
1420 |
!
|
160
|
1421 |
|
626
|
1422 |
printOutProtocolOn:aStream
|
160
|
1423 |
self warn:'printOut not yet supported'
|
|
1424 |
|
|
1425 |
"Created: 22.3.1997 / 14:36:28 / cg"
|
|
1426 |
! !
|
|
1427 |
|
626
|
1428 |
!JavaClass methodsFor:'printing & storing'!
|
1
|
1429 |
|
626
|
1430 |
displayString
|
|
1431 |
^ fullName copyReplaceAll:$/ with:$.
|
|
1432 |
|
|
1433 |
"/ ^ 'JAVA-' , name .
|
|
1434 |
"/ ^ name , '(Java)' "/ 'JavaClass(' , name , ')'
|
1
|
1435 |
|
360
|
1436 |
"Created: / 15.4.1996 / 16:02:48 / cg"
|
|
1437 |
"Modified: / 18.7.1998 / 22:56:30 / cg"
|
626
|
1438 |
! !
|
|
1439 |
|
|
1440 |
!JavaClass methodsFor:'private accessing'!
|
|
1441 |
|
|
1442 |
addMethod:m name:name signature:signature
|
|
1443 |
|sel|
|
63
|
1444 |
|
626
|
1445 |
sel := (name , signature) asSymbol.
|
|
1446 |
self addSelector:sel withMethod:m.
|
|
1447 |
^ self.
|
|
1448 |
|
|
1449 |
"/ selectorArray isNil ifTrue:[
|
|
1450 |
"/ selectorArray := #().
|
|
1451 |
"/ methodArray := #()
|
|
1452 |
"/ ].
|
|
1453 |
"/ selectorArray := selectorArray copyWith:(name , signature) asSymbol. "/ name.
|
|
1454 |
"/"/ selectorArray := selectorArray copyWith:name asSymbol. "/ name.
|
98
|
1455 |
"/ methodArray := methodArray copyWith:m
|
5
|
1456 |
|
|
1457 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
98
|
1458 |
|
|
1459 |
|
5
|
1460 |
!
|
|
1461 |
|
626
|
1462 |
addSelector:newSelector withMethod:newMethod
|
|
1463 |
"redefined to not flush smalltalk caches and send NO smalltalk-class
|
|
1464 |
change notification. Will eventually flush Java caches."
|
|
1465 |
|
|
1466 |
|nargs oldMethod|
|
|
1467 |
|
|
1468 |
oldMethod := self compiledMethodAt:newSelector.
|
130
|
1469 |
(self primAddSelector:newSelector withMethod:newMethod) ifFalse:[^ false].
|
|
1470 |
|
|
1471 |
^ true
|
|
1472 |
|
|
1473 |
"Created: 20.1.1997 / 13:00:48 / cg"
|
|
1474 |
!
|
|
1475 |
|
626
|
1476 |
makeObsolete
|
|
1477 |
accessFlags := accessFlags bitOr:A_OBSOLETE
|
|
1478 |
|
|
1479 |
"Created: 7.8.1997 / 19:04:48 / cg"
|
204
|
1480 |
!
|
|
1481 |
|
626
|
1482 |
markUninitialized
|
|
1483 |
(accessFlags bitAnd:A_INITIALIZED) ~~ 0 ifTrue:[
|
|
1484 |
accessFlags := accessFlags bitXor:A_INITIALIZED
|
252
|
1485 |
].
|
43
|
1486 |
!
|
|
1487 |
|
626
|
1488 |
setAccessFlags:flags
|
3
|
1489 |
accessFlags := flags.
|
1
|
1490 |
|
|
1491 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
5
|
1492 |
!
|
|
1493 |
|
626
|
1494 |
setBinaryFilePath:aPathName
|
73
|
1495 |
binaryFilePath := aPathName
|
|
1496 |
!
|
|
1497 |
|
626
|
1498 |
setConstantPool:anArray
|
|
1499 |
constantPool := anArray.
|
|
1500 |
|
|
1501 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
|
1502 |
!
|
|
1503 |
|
|
1504 |
setFields:f
|
|
1505 |
|vals|
|
|
1506 |
|
|
1507 |
JavaClass setInstanceVariableStringFromFields:f in:self.
|
|
1508 |
|
|
1509 |
instSize := superclass instSize + f size.
|
|
1510 |
|
|
1511 |
fields := f.
|
|
1512 |
vals := self allInstVarNames
|
|
1513 |
collect:[:nm |
|
|
1514 |
self initValueFor:nm
|
|
1515 |
].
|
|
1516 |
vals isEmpty ifTrue:[
|
|
1517 |
initValues := nil
|
|
1518 |
] ifFalse:[
|
|
1519 |
(vals detect:[:el | el notNil] ifNone:nil) isNil ifTrue:[
|
|
1520 |
initValues := nil
|
|
1521 |
] ifFalse:[
|
426
|
1522 |
initValues := vals asArray
|
|
1523 |
]
|
|
1524 |
]
|
27
|
1525 |
|
426
|
1526 |
"Created: / 15.4.1996 / 16:42:52 / cg"
|
|
1527 |
"Modified: / 6.11.1998 / 01:53:01 / cg"
|
27
|
1528 |
!
|
|
1529 |
|
626
|
1530 |
setFullName:aString
|
|
1531 |
|nameComponents|
|
|
1532 |
|
|
1533 |
fullName := aString asSymbol.
|
686
|
1534 |
"/ nameComponents := aString asCollectionOfSubstringsSeparatedBy:$/.
|
|
1535 |
"/ name := nameComponents last asSymbol.
|
|
1536 |
name := fullName.
|
7
|
1537 |
|
423
|
1538 |
"Created: / 15.4.1996 / 16:42:52 / cg"
|
|
1539 |
"Modified: / 5.11.1998 / 19:14:39 / cg"
|
7
|
1540 |
!
|
|
1541 |
|
626
|
1542 |
setInterfaces:i
|
|
1543 |
i size > 0 ifTrue:[
|
|
1544 |
interfaces := i
|
|
1545 |
] ifFalse:[
|
|
1546 |
interfaces := nil
|
110
|
1547 |
]
|
|
1548 |
|
168
|
1549 |
"Modified: 7.4.1997 / 15:44:53 / cg"
|
110
|
1550 |
!
|
|
1551 |
|
626
|
1552 |
setSourceFile:aFilename
|
|
1553 |
sourceFile := aFilename.
|
|
1554 |
|
|
1555 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
|
1556 |
!
|
|
1557 |
|
|
1558 |
setStaticFields:f
|
|
1559 |
JavaClass setInstanceVariableStringFromFields:f in:self class.
|
|
1560 |
|
|
1561 |
staticFields := f.
|
|
1562 |
|
|
1563 |
|
|
1564 |
!
|
60
|
1565 |
|
626
|
1566 |
setSuperclass:aClass
|
|
1567 |
|iVars numIvars|
|
247
|
1568 |
|
626
|
1569 |
aClass isNil ifTrue:[
|
|
1570 |
super setSuperclass:JavaObject
|
|
1571 |
] ifFalse:[
|
|
1572 |
(aClass isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
1573 |
self halt.
|
|
1574 |
].
|
|
1575 |
super setSuperclass:aClass.
|
|
1576 |
].
|
|
1577 |
|
|
1578 |
iVars := self instVarNames.
|
|
1579 |
((numIvars := iVars size) > 0) ifTrue:[
|
|
1580 |
(superclass notNil and:[(superclass isMemberOf:JavaUnresolvedClassConstant) not]) ifTrue:[
|
|
1581 |
instSize := superclass instSize + numIvars
|
|
1582 |
] ifFalse:[
|
|
1583 |
instSize := numIvars
|
252
|
1584 |
]
|
29
|
1585 |
].
|
27
|
1586 |
|
|
1587 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
247
|
1588 |
"Modified: 22.8.1997 / 15:06:45 / cg"
|
626
|
1589 |
! !
|
1
|
1590 |
|
626
|
1591 |
!JavaClass methodsFor:'queries'!
|
|
1592 |
|
|
1593 |
canBeSubclassed
|
|
1594 |
"return true, if its allowed to create subclasses of the receiver."
|
426
|
1595 |
|
|
1596 |
self isFinal ifTrue:[^ false].
|
|
1597 |
self isInterface ifTrue:[^ false].
|
|
1598 |
^ true
|
|
1599 |
|
|
1600 |
"Created: / 5.11.1998 / 23:04:50 / cg"
|
|
1601 |
!
|
|
1602 |
|
626
|
1603 |
hasInterface:aJavaInterface
|
|
1604 |
"return true, if I respond to all methods as
|
|
1605 |
required by the argument, an aJavaInterface"
|
|
1606 |
|
|
1607 |
interfaces size > 0 ifTrue:[
|
|
1608 |
self interfaces do:[:if |
|
|
1609 |
aJavaInterface == if ifTrue:[
|
|
1610 |
^ true
|
|
1611 |
].
|
|
1612 |
]
|
|
1613 |
].
|
|
1614 |
superclass isJavaClass ifTrue:[
|
|
1615 |
^ superclass hasInterface:aJavaInterface
|
|
1616 |
].
|
|
1617 |
^ false.
|
|
1618 |
|
|
1619 |
"/ aJavaInterface methodDictionary keysAndValuesDo:[:sel :mthd |
|
587
|
1620 |
"/ (self canUnderstand:sel) ifFalse:[
|
|
1621 |
"/ ^ false.
|
|
1622 |
"/ ]
|
|
1623 |
"/ ].
|
53
|
1624 |
^ true
|
281
|
1625 |
|
|
1626 |
"Modified: / 28.1.1998 / 01:46:16 / cg"
|
587
|
1627 |
|
52
|
1628 |
!
|
|
1629 |
|
626
|
1630 |
isAbstract
|
|
1631 |
"return true, if the receiver is abstract
|
345
|
1632 |
(i.e. may not have instances)"
|
83
|
1633 |
|
345
|
1634 |
^ (accessFlags bitAnd:A_ABSTRACT) ~~ 0
|
|
1635 |
|
|
1636 |
"Modified: / 7.5.1998 / 12:24:42 / cg"
|
27
|
1637 |
!
|
|
1638 |
|
626
|
1639 |
isFinal
|
|
1640 |
"return true, if the receiver is final
|
345
|
1641 |
(i.e. may not be subclassed)"
|
|
1642 |
|
252
|
1643 |
^ (accessFlags bitAnd:A_FINAL) ~~ 0
|
345
|
1644 |
|
|
1645 |
"Modified: / 7.5.1998 / 12:24:21 / cg"
|
18
|
1646 |
!
|
|
1647 |
|
626
|
1648 |
isInitialized
|
345
|
1649 |
"return true, if the receiver is initialized"
|
|
1650 |
|
252
|
1651 |
^ (accessFlags bitAnd:A_INITIALIZED) ~~ 0
|
345
|
1652 |
|
|
1653 |
"Modified: / 7.5.1998 / 12:23:54 / cg"
|
43
|
1654 |
!
|
|
1655 |
|
626
|
1656 |
isInterface
|
345
|
1657 |
"return true, if the receiver is an interface"
|
|
1658 |
|
252
|
1659 |
^ (accessFlags bitAnd:A_INTERFACE) ~~ 0
|
345
|
1660 |
|
|
1661 |
"Modified: / 7.5.1998 / 12:23:39 / cg"
|
18
|
1662 |
!
|
|
1663 |
|
626
|
1664 |
isJavaClass
|
148
|
1665 |
^ self ~~ JavaClass
|
|
1666 |
|
|
1667 |
"Created: 18.3.1997 / 17:48:01 / cg"
|
|
1668 |
!
|
|
1669 |
|
626
|
1670 |
isJavaMethodRef
|
|
1671 |
^ false
|
|
1672 |
|
|
1673 |
"Created: / 9.11.1999 / 15:42:10 / cg"
|
|
1674 |
!
|
|
1675 |
|
|
1676 |
isObsolete
|
|
1677 |
"return true, if the receiver is obsolete
|
71
|
1678 |
Java classes are never."
|
|
1679 |
|
252
|
1680 |
^ (accessFlags bitAnd:A_OBSOLETE) ~~ 0.
|
71
|
1681 |
|
204
|
1682 |
"Modified: 7.8.1997 / 19:04:28 / cg"
|
71
|
1683 |
!
|
|
1684 |
|
626
|
1685 |
isPublic
|
|
1686 |
"return true, if the receiver is public"
|
|
1687 |
|
|
1688 |
^ (accessFlags bitAnd:A_PUBLIC) ~~ 0
|
|
1689 |
|
|
1690 |
"Modified: / 7.5.1998 / 12:22:44 / cg"
|
90
|
1691 |
!
|
21
|
1692 |
|
626
|
1693 |
isUnresolved
|
|
1694 |
"return true, if the receiver is unresolved;
|
345
|
1695 |
javaClasses are never; JavaUnresolvedClasses are always"
|
|
1696 |
|
90
|
1697 |
^ false
|
345
|
1698 |
|
|
1699 |
"Modified: / 7.5.1998 / 12:23:14 / cg"
|
175
|
1700 |
!
|
|
1701 |
|
679
|
1702 |
nameInBrowser
|
|
1703 |
"return a nameString as shown in browsers"
|
|
1704 |
|
|
1705 |
^ self name copyReplaceAll:$/ with:$.
|
|
1706 |
!
|
|
1707 |
|
626
|
1708 |
nameSpacePath
|
|
1709 |
|parts s|
|
|
1710 |
|
|
1711 |
parts := self fullName asCollectionOfSubstringsSeparatedBy:$/.
|
|
1712 |
s := '' writeStream.
|
|
1713 |
s nextPutAll:'JAVA'.
|
|
1714 |
parts from:1 to:(parts size - 1) do:[:aPart |
|
|
1715 |
s nextPutAll:'::'.
|
|
1716 |
s nextPutAll:aPart
|
|
1717 |
].
|
|
1718 |
^ s contents
|
|
1719 |
|
|
1720 |
"
|
|
1721 |
JAVA::java::lang::Object fullName
|
|
1722 |
JAVA::java::lang::Object nameSpacePath
|
393
|
1723 |
JAVA::java::lang::Object name
|
|
1724 |
"
|
|
1725 |
|
|
1726 |
"Modified: / 19.10.1998 / 20:07:24 / cg"
|
|
1727 |
!
|
|
1728 |
|
626
|
1729 |
supportsMethodCategories
|
|
1730 |
^ self isJavaClass not
|
175
|
1731 |
|
626
|
1732 |
"Created: / 30.7.1997 / 14:58:58 / cg"
|
|
1733 |
"Modified: / 7.5.1998 / 12:25:54 / cg"
|
|
1734 |
!
|
321
|
1735 |
|
626
|
1736 |
typeName
|
|
1737 |
^ 'L' , self fullName
|
321
|
1738 |
|
|
1739 |
"
|
|
1740 |
(Java at:'java.util.Stack') typeName
|
|
1741 |
"
|
|
1742 |
|
|
1743 |
"Modified: / 10.2.1998 / 17:13:26 / cg"
|
626
|
1744 |
! !
|
|
1745 |
|
|
1746 |
!JavaClass methodsFor:'special'!
|
|
1747 |
|
|
1748 |
arrayClass
|
|
1749 |
"/ self halt.
|
|
1750 |
^ Array
|
|
1751 |
|
|
1752 |
"Created: / 10.11.1998 / 02:07:32 / cg"
|
|
1753 |
"Modified: / 8.1.1999 / 14:11:34 / cg"
|
|
1754 |
!
|
|
1755 |
|
|
1756 |
asClassPointerRef
|
|
1757 |
"/ self halt.
|
|
1758 |
^ self
|
|
1759 |
|
|
1760 |
"Created: / 10.11.1998 / 02:07:01 / cg"
|
|
1761 |
"Modified: / 8.1.1999 / 14:11:26 / cg"
|
428
|
1762 |
!
|
|
1763 |
|
626
|
1764 |
deref
|
|
1765 |
^ self
|
428
|
1766 |
|
626
|
1767 |
"Created: / 10.11.1998 / 02:08:06 / cg"
|
428
|
1768 |
!
|
|
1769 |
|
626
|
1770 |
updateClassRefsFrom:oldClass to:newClass
|
|
1771 |
self == oldClass ifTrue:[
|
|
1772 |
self makeObsolete.
|
|
1773 |
^ self
|
|
1774 |
].
|
|
1775 |
|
|
1776 |
constantPool updateClassRefsFrom:oldClass to:newClass.
|
|
1777 |
interfaces notNil ifTrue:[
|
|
1778 |
interfaces := interfaces collect:[:anInterface |
|
|
1779 |
anInterface == oldClass ifTrue:[
|
|
1780 |
newClass isNil ifTrue:[
|
|
1781 |
nil "/ replace by an unresolvedInterface
|
|
1782 |
] ifFalse:[
|
|
1783 |
newClass
|
|
1784 |
]
|
|
1785 |
] ifFalse:[
|
|
1786 |
anInterface
|
|
1787 |
]
|
|
1788 |
]
|
|
1789 |
]
|
|
1790 |
|
|
1791 |
"Modified: / 4.2.1998 / 22:08:19 / cg"
|
203
|
1792 |
! !
|
|
1793 |
|
130
|
1794 |
!JavaClass class methodsFor:'documentation'!
|
1
|
1795 |
|
|
1796 |
version
|
691
|
1797 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClass.st,v 1.118 2000/09/21 11:40:55 cg Exp $'
|
1
|
1798 |
! !
|
52
|
1799 |
JavaClass initialize!
|