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