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