author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 02 Jan 2013 16:10:11 +0100 | |
branch | development |
changeset 1919 | d2f931428d34 |
parent 1876 | 482ad5ebe5da |
child 1941 | 021634f2b5a2 |
permissions | -rw-r--r-- |
752 | 1 |
" |
877 | 2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
1152 | 3 |
|
1155 | 4 |
New code and modifications done at SWING Research Group [1]: |
1152 | 5 |
|
877 | 6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
7 |
SWING Research Group, Czech Technical University in Prague |
|
8 |
||
752 | 9 |
This software is furnished under a license and may be used |
10 |
only in accordance with the terms of that license and with the |
|
11 |
inclusion of the above copyright notice. This software may not |
|
12 |
be provided or otherwise made available to, or used by, any |
|
13 |
other person. No title to or ownership of the software is |
|
14 |
hereby transferred. |
|
877 | 15 |
|
1155 | 16 |
[1] Code written at SWING Research Group contains a signature |
17 |
of one of the above copright owners. For exact set of such code, |
|
18 |
see the differences between this version and version stx:libjava |
|
1152 | 19 |
as of 1.9.2010 |
752 | 20 |
" |
21 |
"{ Package: 'stx:libjava' }" |
|
22 |
||
23 |
JavaBehavior subclass:#JavaClass |
|
1368 | 24 |
instanceVariableNames:'classLoader fullName sourceFile sourceString binaryFilePath |
1793 | 25 |
fields staticFields annotations protectionDomain signatureJ' |
752 | 26 |
classVariableNames:'ArgumentConversionErrorSignal OrderOfClassInits' |
1523
f5ffdad83ab9
Access to ACC_* and ACX_* constants unified. The only definition is in JavaConstants
vranyj1
parents:
1511
diff
changeset
|
27 |
poolDictionaries:'JavaConstants' |
752 | 28 |
category:'Languages-Java-Classes' |
29 |
! |
|
30 |
||
31 |
!JavaClass class methodsFor:'documentation'! |
|
32 |
||
33 |
copyright |
|
34 |
" |
|
877 | 35 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
1152 | 36 |
|
1155 | 37 |
New code and modifications done at SWING Research Group [1]: |
1152 | 38 |
|
877 | 39 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
40 |
SWING Research Group, Czech Technical University in Prague |
|
41 |
||
752 | 42 |
This software is furnished under a license and may be used |
43 |
only in accordance with the terms of that license and with the |
|
44 |
inclusion of the above copyright notice. This software may not |
|
45 |
be provided or otherwise made available to, or used by, any |
|
46 |
other person. No title to or ownership of the software is |
|
47 |
hereby transferred. |
|
877 | 48 |
|
1155 | 49 |
[1] Code written at SWING Research Group contains a signature |
50 |
of one of the above copright owners. For exact set of such code, |
|
51 |
see the differences between this version and version stx:libjava |
|
1152 | 52 |
as of 1.9.2010 |
877 | 53 |
|
752 | 54 |
" |
55 |
! |
|
56 |
||
57 |
examples |
|
58 |
" |
|
59 |
(Java at:'java.util.Stack') new inspect |
|
60 |
(Java at:'java.util.Vector') new inspect |
|
61 |
" |
|
62 |
! ! |
|
63 |
||
64 |
!JavaClass class methodsFor:'instance creation'! |
|
65 |
||
66 |
fullName:aString |
|
67 |
self shouldNotImplement. |
|
68 |
^ self new flags:0; setFullName:aString |
|
69 |
||
70 |
! |
|
71 |
||
72 |
fullName:aString numStatic:nStatic |
|
1453 | 73 |
|meta cls classLoader | |
752 | 74 |
|
75 |
"/ check for a JAVA nameSpace to exist |
|
76 |
JAVA isNil ifTrue:[ |
|
1390
4a623c4ec05f
- improvements in JavaPackage (towards nicer interop)
vranyj1
parents:
1385
diff
changeset
|
77 |
JavaPackage name:'JAVA' |
752 | 78 |
]. |
79 |
||
1368 | 80 |
classLoader := JavaClassReader classLoaderQuerySignal query. |
81 |
||
752 | 82 |
"create the metaclass first" |
83 |
||
1453 | 84 |
meta := JavaMetaclass new. |
1372
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1368
diff
changeset
|
85 |
meta setSuperclass:self. |
1368 | 86 |
meta instSize:(meta superclass instSize + nStatic). |
752 | 87 |
"/ meta setName:(aString , 'class') asSymbol. |
88 |
"/ meta setClassVariableString:''. |
|
89 |
meta flags:(meta flags bitOr:Behavior flagJavaClass). |
|
90 |
"/ meta setSuperclass:JavaObject class. |
|
91 |
||
92 |
"then let the new meta create the class" |
|
93 |
cls := meta new. |
|
94 |
cls setSuperclass:JavaObject. |
|
95 |
cls instSize:0. |
|
96 |
cls setName:('JAVA::' , aString). |
|
97 |
cls flags:0. |
|
98 |
||
99 |
cls setAccessFlags:0. |
|
100 |
"/ cls setClassVariableString:''. |
|
101 |
cls setInstanceVariableString:''. |
|
102 |
cls setCategory:#java. |
|
103 |
cls setFullName:aString. |
|
104 |
||
105 |
^ cls |
|
106 |
||
107 |
"Created: / 15-04-1996 / 15:52:55 / cg" |
|
108 |
"Modified: / 03-01-1998 / 22:32:25 / cg" |
|
1453 | 109 |
"Modified: / 04-04-2012 / 09:36:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 110 |
! |
111 |
||
112 |
name:aString |
|
113 |
self shouldNotImplement |
|
114 |
||
115 |
"Created: 15.4.1996 / 15:52:55 / cg" |
|
116 |
! ! |
|
117 |
||
1001 | 118 |
!JavaClass class methodsFor:'boxing-unboxing'! |
119 |
||
1006 | 120 |
box: stArgumentsCollection to: typesCollection |
121 |
" box smalltalk arguments collection to Java arguments " |
|
122 |
^ stArgumentsCollection with: typesCollection collect: [ :stObject :javaType | |
|
123 |
(JavaTypeBox typeBoxForJava: javaType) box: stObject. |
|
124 |
] |
|
125 |
||
126 |
"Created: / 25-09-2011 / 20:20:35 / Jan Kurs <kursjan@fit.cvut.cz>" |
|
127 |
! |
|
128 |
||
1001 | 129 |
unbox:jObj returnType: returnType |
130 |
||
131 |
"JV@2011-02-04" |
|
132 |
"Hack for primitive types" |
|
133 |
"/ JK: it is hack, but it is fast :) |
|
134 |
(JavaDescriptor baseTypesByTypeName keys includes: returnType) ifTrue:[^jObj]. |
|
135 |
||
1006 | 136 |
^ (JavaTypeBox typeBoxForJava: returnType) unbox: jObj. |
1001 | 137 |
|
138 |
"Created: / 30-08-2011 / 22:13:41 / Jan Kurs <kursjan@fit.cvut.cz>" |
|
139 |
! ! |
|
140 |
||
752 | 141 |
!JavaClass class methodsFor:'class initialization'! |
142 |
||
143 |
initialize |
|
144 |
||
145 |
ArgumentConversionErrorSignal := Signal new notifierString:'argument conversion error'. |
|
146 |
||
147 |
"Created: / 20-10-2010 / 11:11:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
148 |
! ! |
|
149 |
||
150 |
!JavaClass class methodsFor:'method lookup'! |
|
151 |
||
152 |
canConvertArgsToJava:argArray asSpecifiedIn:argSigSpecArray |
|
153 |
"given a smalltalk argument array, return true, if these can be converted to java objects as appropriate." |
|
154 |
||
155 |
argArray |
|
156 |
with:argSigSpecArray |
|
157 |
do:[:arg :type | |
|
158 |
self |
|
159 |
convertToJava:arg |
|
160 |
type:type |
|
161 |
ifFail:[:msg :default| ^ false]]. |
|
162 |
^ true |
|
163 |
||
164 |
"Created: / 5.11.1998 / 18:25:05 / cg" |
|
165 |
"Modified: / 6.11.1998 / 00:45:58 / cg" |
|
166 |
! |
|
167 |
||
168 |
convertArgsToJava:argArray asSpecifiedIn:argSigSpecArray numArgs:na |
|
169 |
"given a smalltalk argument array, convert to java objects as appropriate. |
|
170 |
Currently, only Strings and booleans are converted." |
|
171 |
||
172 |
|sigIndex newArgIndex newArgArray| |
|
173 |
||
174 |
sigIndex := newArgIndex := 1. |
|
175 |
||
176 |
newArgArray := Array new:na. |
|
177 |
argArray do:[:arg | |
|
178 |
|type newArg| |
|
179 |
||
180 |
type := argSigSpecArray at:sigIndex. |
|
181 |
sigIndex := sigIndex + 1. |
|
182 |
newArg := self convertToJava:arg type:type. |
|
183 |
newArgArray at:newArgIndex put:newArg. |
|
184 |
newArgIndex := newArgIndex + 1. |
|
185 |
(type == #long or:[type == #double]) ifTrue:[ |
|
186 |
newArgIndex > na ifTrue:[ |
|
187 |
self halt:'should not happen' |
|
188 |
]. |
|
189 |
newArgArray at:newArgIndex put:nil. |
|
190 |
newArgIndex := newArgIndex + 1. |
|
191 |
] |
|
192 |
]. |
|
193 |
||
194 |
^ newArgArray |
|
195 |
||
196 |
"Created: / 5.11.1998 / 18:30:57 / cg" |
|
197 |
"Modified: / 6.11.1998 / 00:45:00 / cg" |
|
198 |
! |
|
199 |
||
200 |
convertToJava:arg type:type |
|
201 |
"given a smalltalk argument, convert to a java object as appropriate." |
|
202 |
||
203 |
^ self |
|
204 |
convertToJava:arg |
|
205 |
type:type |
|
206 |
ifFail:[:msg :default | |
|
207 |
ArgumentConversionErrorSignal |
|
208 |
raiseWith:arg |
|
209 |
errorString:msg. |
|
210 |
default |
|
211 |
] |
|
212 |
||
213 |
"Created: / 06-11-1998 / 00:45:13 / cg" |
|
214 |
"Modified: / 20-10-2010 / 11:08:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
215 |
! |
|
216 |
||
1033 | 217 |
convertToJava: arg type: type ifFail: failBlock |
752 | 218 |
"given a smalltalk argument, convert to a java object as appropriate. |
219 |
Currently, only a few types are converted." |
|
1033 | 220 |
|
221 |
| expectedCls f failValue | |
|
222 |
||
223 |
type == #boolean ifTrue: [ |
|
224 |
arg == true ifTrue: [ ^ 1 ]. |
|
225 |
arg == false ifTrue: [ ^ 0 ]. |
|
226 |
^ failBlock value: ('cannot convert argument to ' , type) value: 0 |
|
227 |
]. |
|
228 |
type == #int ifTrue: [ |
|
229 |
arg isInteger ifTrue: [ |
|
230 |
(arg between: (16r8000000 * -1) and: 16r7FFFFFFF) ifTrue: [ ^ arg ]. |
|
231 |
^ failBlock value: ('integer range; cannot convert argument to ' , type) |
|
232 |
value: 0. |
|
752 | 233 |
]. |
1033 | 234 |
^ failBlock value: ('cannot convert argument to ' , type) value: 0 |
752 | 235 |
]. |
1033 | 236 |
type == #long ifTrue: [ |
237 |
arg isInteger ifTrue: [ |
|
238 |
(arg "(-1 * 16r800000000000000) -->" between: -576460752303423488 |
|
239 |
and: 16r7FFFFFFFFFFFFFFF) ifTrue: [ ^ arg ]. |
|
240 |
^ failBlock value: ('integer range; cannot convert argument to ' , type) |
|
241 |
value: 0 |
|
752 | 242 |
]. |
1033 | 243 |
^ failBlock value: ('cannot convert argument to ' , type) value: 0 |
244 |
]. |
|
245 |
(type == #float) ifTrue: [ |
|
246 |
arg isLimitedPrecisionReal ifTrue: [ ^ arg asShortFloat ]. |
|
247 |
^ failBlock value: ('cannot convert argument to ' , type) value: 0.0. |
|
752 | 248 |
]. |
1033 | 249 |
(type = 'java.lang.Float') ifTrue: [ |
250 |
arg isLimitedPrecisionReal ifTrue: [ |
|
251 |
f := (Java at: 'java.lang.Float') new. |
|
252 |
f perform: #'<init>(F)V' with: (arg asShortFloat). |
|
253 |
self halt. |
|
752 | 254 |
^ f. |
255 |
]. |
|
1033 | 256 |
^ failBlock value: ('cannot convert argument to ' , type) value: 0.0. |
752 | 257 |
]. |
1033 | 258 |
(type = 'java.lang.Double') ifTrue: [ |
259 |
arg isLimitedPrecisionReal ifTrue: [ |
|
260 |
f := (Java at: 'java.lang.Double') new. |
|
261 |
f perform: #'<init>(D)V' with: (arg asFloat). |
|
262 |
self halt. |
|
263 |
^ f. |
|
752 | 264 |
]. |
1033 | 265 |
^ failBlock value: ('cannot convert argument to ' , type) value: 0.0. |
266 |
]. |
|
267 |
(type == #double) ifTrue: [ |
|
268 |
arg isLimitedPrecisionReal ifTrue: [ ^ arg asFloat ]. |
|
269 |
^ failBlock value: ('cannot convert argument to ' , type) value: 0.0. |
|
752 | 270 |
]. |
1033 | 271 |
(type == #char) ifTrue: [ |
272 |
arg isCharacter ifTrue: [ ^ arg asciiValue ]. |
|
273 |
^ failBlock value: ('cannot convert argument to ' , type) value: 0 |
|
752 | 274 |
]. |
1033 | 275 |
(type = 'char[]') ifTrue: [ |
276 |
arg isString ifTrue: [ ^ arg ]. |
|
277 |
^ failBlock value: ('cannot convert argument to ' , type) value: '' |
|
278 |
]. |
|
279 |
(type = 'int[]') ifTrue: [ |
|
280 |
(arg isArray or: [ arg isMemberOf: SignedIntegerArray ]) ifTrue: [ ^ arg ]. |
|
281 |
^ failBlock value: ('cannot convert argument to ' , type) value: '' |
|
752 | 282 |
]. |
1033 | 283 |
(type = 'long[]') ifTrue: [ |
284 |
(arg isArray or: [ arg isMemberOf: SignedIntegerArray ]) ifTrue: [ ^ arg ]. |
|
285 |
^ failBlock value: ('cannot convert argument to ' , type) value: '' |
|
286 |
]. |
|
287 |
(type = 'float[]') ifTrue: [ |
|
288 |
(arg isArray or: [ arg isMemberOf: FloatArray ]) ifTrue: [ ^ arg ]. |
|
289 |
^ failBlock value: ('cannot convert argument to ' , type) value: '' |
|
752 | 290 |
]. |
1033 | 291 |
(type = 'double[]') ifTrue: [ |
292 |
(arg isArray or: [ arg isMemberOf: DoubleArray ]) ifTrue: [ ^ arg ]. |
|
293 |
^ failBlock value: ('cannot convert argument to ' , type) value: '' |
|
752 | 294 |
]. |
1033 | 295 |
(type endsWith: '[]') ifTrue: [ |
296 |
(arg isArray or: [ arg isNil ]) ifTrue: [ ^ arg ]. |
|
297 |
^ failBlock value: ('cannot convert argument to ' , type) value: '' |
|
298 |
]. |
|
299 |
expectedCls := JavaVM classForName: type. |
|
300 |
(arg isKindOf: expectedCls) ifTrue: [ |
|
752 | 301 |
"/ matches class and subclasses |
302 |
^ arg |
|
303 |
]. |
|
1033 | 304 |
(type = 'java.lang.Object') ifTrue: [ |
752 | 305 |
"/ matches any |
306 |
^ arg |
|
307 |
]. |
|
1033 | 308 |
(type = 'java.lang.String') ifTrue: [ |
309 |
arg isString ifTrue: [ ^ Java as_String: arg ]. |
|
752 | 310 |
failValue := '' |
311 |
]. |
|
1033 | 312 |
arg isNil ifTrue: [ |
752 | 313 |
"/ matches any |
314 |
^ arg |
|
315 |
]. |
|
1033 | 316 |
self halt. |
317 |
^ failBlock value: ('cannot convert argument to ' , type) value: failValue |
|
752 | 318 |
|
319 |
"Created: / 06-11-1998 / 00:46:19 / cg" |
|
320 |
"Modified: / 06-11-2001 / 13:28:29 / cg" |
|
321 |
"Modified: / 17-01-2011 / 10:08:04 / kursjan <kursjan@fit.cvut.cz>" |
|
322 |
"Modified: / 17-03-2011 / 14:09:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
323 |
! |
|
324 |
||
325 |
convertToSmalltalk:jObj type:type |
|
326 |
"given a java return value, convert to a smalltalk object as appropriate. |
|
327 |
Currently, only a few types are converted." |
|
328 |
||
329 |
"JV@2011-02-04" |
|
330 |
"Hack for primitive types" |
|
331 |
(JavaDescriptor baseTypesByTypeName keys includes: type) ifTrue:[^jObj]. |
|
332 |
"jObj is registered for the specified type?" |
|
333 |
||
756 | 334 |
" |
752 | 335 |
(JavaObjectDictionary new reflectionOf: jObj class name) = (Java classForName: type) ifTrue: [ |
336 |
^ jObj |
|
337 |
]. |
|
756 | 338 |
" |
752 | 339 |
|
340 |
type == #boolean ifTrue:[ |
|
341 |
jObj == 0 ifTrue:[ |
|
342 |
^ false |
|
343 |
]. |
|
344 |
^ true |
|
345 |
]. |
|
346 |
||
347 |
type == #void ifTrue:[ |
|
348 |
^ nil |
|
349 |
]. |
|
350 |
||
351 |
(type = 'java.lang.String') ifTrue:[ |
|
352 |
^ Java as_ST_String:jObj |
|
353 |
]. |
|
354 |
||
355 |
"/ (type = 'java.lang.Float') ifTrue:[ |
|
356 |
"/ ^ jObj instVarNamed:'value' |
|
357 |
"/ ]. |
|
358 |
"/ (type = 'java.lang.Double') ifTrue:[ |
|
359 |
"/ ^ jObj instVarNamed:'value' |
|
360 |
"/ ]. |
|
361 |
||
362 |
(type == #char) ifTrue:[ |
|
363 |
jObj isInteger ifTrue:[ |
|
364 |
^ Character value:jObj |
|
365 |
]. |
|
366 |
]. |
|
367 |
||
368 |
^ jObj |
|
369 |
||
370 |
"Created: / 06-11-1998 / 00:49:53 / cg" |
|
371 |
"Modified: / 11-11-1998 / 02:08:11 / cg" |
|
372 |
"Modified: / 17-01-2011 / 10:42:56 / kursjan <kursjan@fit.cvut.cz>" |
|
756 | 373 |
"Modified: / 08-04-2011 / 17:04:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 374 |
! |
375 |
||
376 |
lookupMethod:selector numArgs:nargs in:aClass static:staticMethod |
|
377 |
"lookup a method" |
|
378 |
||
379 |
|method cls sel| |
|
380 |
||
381 |
sel := selector. |
|
382 |
(sel includes:$:) ifTrue:[ |
|
383 |
sel := sel copyTo:(sel indexOf:$:)-1 |
|
384 |
]. |
|
385 |
||
386 |
sel := sel asSymbolIfInterned. |
|
387 |
sel notNil ifTrue:[ |
|
388 |
cls := aClass. |
|
389 |
||
390 |
[cls notNil |
|
391 |
and:[cls ~~ JavaObject |
|
392 |
and:[cls ~~ JavaClass]]] whileTrue:[ |
|
393 |
cls methodDictionary keysAndValuesDo:[:jSel :m | |
|
394 |
|aMethod| |
|
395 |
||
396 |
aMethod := m. |
|
397 |
aMethod isWrapped ifTrue:[ |
|
398 |
aMethod := aMethod originalMethod |
|
399 |
]. |
|
400 |
||
401 |
((jSel == sel) |
|
402 |
or:[aMethod name = sel |
|
403 |
or:[aMethod signatureNameWithoutReturnType = sel]]) |
|
404 |
ifTrue:[ |
|
405 |
aMethod numArgs == nargs ifTrue:[ |
|
406 |
staticMethod == (aMethod isStatic) ifTrue:[ |
|
407 |
^ m |
|
408 |
] |
|
409 |
] |
|
410 |
] |
|
411 |
]. |
|
412 |
||
413 |
cls := cls superclass. |
|
414 |
]. |
|
415 |
]. |
|
416 |
"/ self halt. |
|
417 |
^ nil |
|
418 |
||
419 |
"Created: / 17.8.1997 / 18:25:47 / cg" |
|
420 |
"Modified: / 16.11.1998 / 16:46:48 / cg" |
|
421 |
! |
|
422 |
||
423 |
lookupMethods:selector numArgs:nargs in:aClass static:staticMethod |
|
424 |
"lookup methods matching a selector. |
|
425 |
This is a special entry for doesNotUnderstand redirection |
|
426 |
(the caller must select the one method which fits the argument(s) best." |
|
427 |
||
428 |
|methods cls sel| |
|
429 |
||
430 |
sel := selector. |
|
431 |
(sel includes:$:) ifTrue:[ |
|
432 |
sel := sel copyTo:(sel indexOf:$:)-1 |
|
433 |
]. |
|
434 |
||
435 |
sel := sel asSymbolIfInterned. |
|
436 |
sel notNil ifTrue:[ |
|
437 |
cls := aClass. |
|
438 |
||
439 |
[cls notNil |
|
440 |
and:[cls ~~ JavaObject |
|
441 |
and:[cls ~~ JavaClass]]] whileTrue:[ |
|
442 |
cls methodDictionary keysAndValuesDo:[:jSel :aMethod | |
|
443 |
((jSel == sel) |
|
444 |
or:[aMethod name = sel |
|
445 |
or:[aMethod signatureNameWithoutReturnType = sel]]) |
|
446 |
ifTrue:[ |
|
447 |
(nargs isNil |
|
448 |
or:[aMethod numArgs == nargs]) ifTrue:[ |
|
449 |
staticMethod == (aMethod isStatic) ifTrue:[ |
|
450 |
methods isNil ifTrue:[ |
|
451 |
methods := OrderedCollection new |
|
452 |
]. |
|
453 |
methods add:aMethod |
|
454 |
] |
|
455 |
] |
|
456 |
] |
|
457 |
]. |
|
458 |
||
459 |
cls := cls superclass. |
|
460 |
]. |
|
461 |
]. |
|
462 |
^ methods ? #() |
|
463 |
||
464 |
"Created: / 4.11.1998 / 19:04:51 / cg" |
|
465 |
"Modified: / 4.11.1998 / 19:31:33 / cg" |
|
466 |
! ! |
|
467 |
||
468 |
!JavaClass class methodsFor:'signature parsing'! |
|
469 |
||
470 |
initialValueFromSignature:aSignature |
|
471 |
"given a signature, return an initializer value" |
|
472 |
||
473 |
|s| |
|
474 |
||
475 |
s := aSignature readStream. |
|
476 |
^ self initialValueFromStream:s. |
|
477 |
||
478 |
" |
|
479 |
JavaClass initialValueFromSignature:'LObject;' |
|
480 |
JavaClass initialValueFromSignature:'B' |
|
481 |
JavaClass initialValueFromSignature:'I' |
|
482 |
" |
|
483 |
||
484 |
||
485 |
! ! |
|
486 |
||
487 |
!JavaClass class methodsFor:'special'! |
|
488 |
||
489 |
deinitClasses |
|
490 |
||
491 |
Smalltalk allClassesDo: |
|
492 |
[:cls|cls isJavaClass ifTrue:[cls deinit]]. |
|
493 |
self flushClassesInitOrder. |
|
494 |
||
495 |
" |
|
496 |
JavaClass deinitClasses |
|
497 |
" |
|
498 |
||
499 |
"Created: / 25-10-2010 / 16:47:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
500 |
! |
|
501 |
||
502 |
flushClassesInitOrder |
|
503 |
OrderOfClassInits := nil |
|
504 |
||
505 |
"Created: / 6.11.2001 / 09:49:49 / cg" |
|
506 |
! |
|
507 |
||
508 |
orderOfClassInits |
|
509 |
^ OrderOfClassInits |
|
510 |
||
511 |
"Created: / 12.11.1998 / 15:35:57 / cg" |
|
512 |
! |
|
513 |
||
514 |
setInstanceVariableStringFromFields:f in:aClass |
|
515 |
|varNames| |
|
516 |
||
517 |
varNames := ''. |
|
518 |
f do:[:aField | |
|
519 |
varNames := varNames , aField name , ' ' |
|
520 |
]. |
|
521 |
aClass setInstanceVariableString:varNames. |
|
522 |
||
523 |
"Created: 15.4.1996 / 16:42:52 / cg" |
|
524 |
! |
|
525 |
||
526 |
startRememberingOrderOfClassInits |
|
527 |
OrderOfClassInits := OrderedCollection new. |
|
528 |
||
529 |
"Created: / 12.11.1998 / 15:26:32 / cg" |
|
530 |
"Modified: / 12.11.1998 / 15:29:10 / cg" |
|
531 |
! ! |
|
532 |
||
533 |
!JavaClass methodsFor:'accessing'! |
|
534 |
||
1453 | 535 |
allFields |
536 |
"Returns all fields, including those inherited from |
|
537 |
a superclass" |
|
538 |
| cls all | |
|
539 |
||
540 |
cls := self. |
|
541 |
all := OrderedCollection new. |
|
542 |
[ cls isJavaClass ] whileTrue:[ |
|
543 |
all addAll: cls fields. |
|
544 |
cls := cls superclass |
|
545 |
]. |
|
546 |
^all. |
|
547 |
||
548 |
"Created: / 04-04-2012 / 01:37:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
549 |
! |
|
550 |
||
752 | 551 |
allInterfaces |
552 |
||
553 |
| ifaces cls | |
|
554 |
||
555 |
ifaces := Set new. |
|
556 |
cls := self. |
|
557 |
[ cls isJavaClass ] whileTrue: |
|
558 |
[cls interfaces do:[:iface| ifaces add: iface; addAll: iface allInterfaces]. |
|
559 |
cls := cls superclass]. |
|
560 |
^ifaces. |
|
561 |
||
562 |
"Created: / 05-02-2011 / 23:51:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
563 |
! |
|
564 |
||
1453 | 565 |
allStaticFields |
566 |
"Returns all fields, including those inherited from |
|
567 |
a superclass" |
|
568 |
| cls all | |
|
569 |
||
570 |
cls := self. |
|
571 |
all := OrderedCollection new. |
|
572 |
[ cls isJavaClass ] whileTrue:[ |
|
573 |
all addAll: cls staticFields. |
|
574 |
cls := cls superclass |
|
575 |
]. |
|
576 |
^all. |
|
577 |
||
578 |
"Created: / 04-04-2012 / 01:37:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
579 |
! |
|
580 |
||
752 | 581 |
annotations |
582 |
^ annotations ifNil:[JavaClassAnnotationContainer empty]. |
|
583 |
||
584 |
"Modified: / 03-03-2011 / 22:52:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
585 |
! |
|
586 |
||
587 |
annotations:something |
|
588 |
annotations := something. |
|
589 |
! |
|
590 |
||
591 |
binaryFile |
|
592 |
^ binaryFilePath |
|
593 |
! |
|
594 |
||
595 |
classLoader |
|
596 |
^ classLoader |
|
597 |
! |
|
598 |
||
1368 | 599 |
classLoader:classLoaderOrNil |
600 |
classLoader := classLoaderOrNil. |
|
601 |
||
602 |
"Modified: / 18-02-2012 / 20:21:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 603 |
! |
604 |
||
605 |
compiledMethodAt:name |
|
606 |
"redefined to find the constructor" |
|
607 |
||
608 |
|m| |
|
609 |
||
610 |
m := super compiledMethodAt:name. |
|
611 |
m isNil ifTrue:[ |
|
612 |
name = self lastName ifTrue:[ |
|
613 |
^ super compiledMethodAt:#'<init>()V' |
|
614 |
]. |
|
615 |
]. |
|
616 |
^ m |
|
617 |
||
618 |
" |
|
619 |
JAVA::java::lang::Object compiledMethodAt:#Object |
|
620 |
" |
|
621 |
||
622 |
"Created: / 24.12.1999 / 02:02:50 / cg" |
|
623 |
"Modified: / 24.12.1999 / 02:04:46 / cg" |
|
624 |
! |
|
625 |
||
626 |
compiledMethodAt:name signature:sig |
|
627 |
"lookup the classes methodDictionary" |
|
628 |
||
629 |
methodDictionary keysAndValuesDo:[:mFullSelector :aMethod | |
|
630 |
aMethod name == name ifTrue:[ |
|
631 |
aMethod signature == sig ifTrue:[ |
|
632 |
^ aMethod |
|
633 |
] |
|
634 |
] |
|
635 |
]. |
|
636 |
^ nil |
|
637 |
||
638 |
"Created: 1.8.1997 / 00:01:58 / cg" |
|
639 |
! |
|
640 |
||
641 |
constantPool |
|
642 |
^ constantPool |
|
643 |
! |
|
644 |
||
645 |
ensureHasAnnotations |
|
646 |
annotations ifNil: [ annotations := JavaAnnotationContainer for: self ]. |
|
647 |
^ annotations |
|
648 |
||
649 |
"Created: / 25-02-2011 / 16:02:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
650 |
"Modified: / 16-03-2011 / 17:13:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
651 |
! |
|
652 |
||
653 |
fields |
|
654 |
^ fields |
|
655 |
! |
|
656 |
||
657 |
fullName |
|
658 |
^ fullName |
|
659 |
! |
|
660 |
||
661 |
interfaces |
|
662 |
interfaces notNil |
|
663 |
ifTrue: |
|
664 |
[ interfaces := interfaces collect: |
|
824 | 665 |
[:clsRef | clsRef javaClass ] ]. |
666 |
||
752 | 667 |
^ interfaces ? #() |
668 |
||
824 | 669 |
"Modified: / 31-05-2011 / 09:40:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 670 |
! |
671 |
||
672 |
javaClass |
|
808
6116e95d8d4b
- JavaBehavior>>#setConstantPool: set CP owner to class itself
vranyj1
parents:
796
diff
changeset
|
673 |
|
752 | 674 |
^ self |
808
6116e95d8d4b
- JavaBehavior>>#setConstantPool: set CP owner to class itself
vranyj1
parents:
796
diff
changeset
|
675 |
|
6116e95d8d4b
- JavaBehavior>>#setConstantPool: set CP owner to class itself
vranyj1
parents:
796
diff
changeset
|
676 |
"Modified: / 22-05-2011 / 13:32:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 677 |
! |
678 |
||
679 |
javaComponentClass |
|
822 | 680 |
^self. |
752 | 681 |
|
682 |
"Created: / 20-12-2010 / 22:02:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
822 | 683 |
"Modified: / 30-05-2011 / 23:26:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 684 |
! |
685 |
||
686 |
javaName |
|
687 |
"the javaname - as seen by a java programmer. |
|
688 |
(with '/'s replaced by dots) extract from the fullName" |
|
689 |
||
690 |
^ fullName copyReplaceAll:$/ with:$. |
|
691 |
||
692 |
" |
|
693 |
Java allClasses first fullName |
|
694 |
Java allClasses first name |
|
695 |
Java allClasses first javaName |
|
696 |
Java allClasses first javaPackage |
|
697 |
Java allClasses first package |
|
698 |
" |
|
699 |
! |
|
700 |
||
701 |
javaPackage |
|
702 |
"the javaPackage - as seen by a java programmer. |
|
703 |
(with '/'s replaced by dots) extract from the fullName" |
|
704 |
||
705 |
|components| |
|
706 |
||
707 |
components := fullName asCollectionOfSubstringsSeparatedBy:$/. |
|
708 |
components size > 1 ifTrue:[ |
|
709 |
^ (components copyWithoutLast:1) asStringWith:$. |
|
710 |
]. |
|
711 |
^ fullName |
|
712 |
||
713 |
" |
|
714 |
Java allClasses first fullName |
|
715 |
Java allClasses first javaPackage |
|
716 |
Java allClasses first package |
|
717 |
" |
|
718 |
! |
|
719 |
||
720 |
javaPackageAsDirname |
|
721 |
"the javaPackage - as directory in class path" |
|
722 |
||
723 |
|components| |
|
724 |
||
725 |
components := fullName asCollectionOfSubstringsSeparatedBy:$/. |
|
726 |
components size > 1 ifTrue:[ |
|
727 |
^ (components copyWithoutLast:1) asStringWith: Filename separator |
|
728 |
]. |
|
729 |
^ fullName |
|
730 |
||
731 |
" |
|
732 |
Java allClasses first fullName |
|
733 |
Java allClasses first javaPackage |
|
734 |
Java allClasses first package |
|
735 |
" |
|
736 |
||
737 |
"Created: / 30-11-2010 / 12:17:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
738 |
! |
|
739 |
||
1483 | 740 |
javaWrapperClass |
741 |
||
742 |
fullName == #'java/lang/String' ifTrue:[ ^ String ]. |
|
743 |
self error:'Should not happen' |
|
744 |
||
745 |
"Created: / 20-04-2012 / 20:03:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
746 |
! |
|
747 |
||
752 | 748 |
lastName |
749 |
^ fullName copyFrom:(fullName lastIndexOf:$/)+1 |
|
750 |
||
751 |
"Created: / 5.11.1998 / 19:16:00 / cg" |
|
752 |
! |
|
753 |
||
754 |
name |
|
755 |
^ name "/ fullName |
|
756 |
! |
|
757 |
||
758 |
nameSpace |
|
1468 | 759 |
^ NameSpace name:#JAVA |
760 |
||
761 |
"Created: / 20-01-1997 / 13:04:30 / cg" |
|
762 |
"Modified: / 11-04-2012 / 23:25:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 763 |
! |
764 |
||
765 |
nameWithoutNameSpacePrefix |
|
766 |
^ fullName |
|
767 |
||
768 |
"Created: 20.1.1997 / 13:05:30 / cg" |
|
769 |
! |
|
770 |
||
771 |
nameWithoutPrefix |
|
1483 | 772 |
^ self lastName |
773 |
||
774 |
"Created: / 20-01-1997 / 13:06:06 / cg" |
|
775 |
"Modified: / 20-04-2012 / 18:35:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 776 |
! |
777 |
||
778 |
package |
|
779 |
"the package (as seen by a smalltalk programmer) |
|
780 |
extract from the fullName, (with '/'s) and prepend 'java:'" |
|
781 |
||
782 |
|components p i| |
|
783 |
||
784 |
i := fullName lastIndexOf:$/. |
|
785 |
p := fullName copyTo:i - 1. |
|
786 |
p size == 0 ifTrue:[ |
|
787 |
^ 'java' |
|
788 |
]. |
|
789 |
"/ components := fullName asCollectionOfSubstringsSeparatedBy:$/. |
|
790 |
"/ components size > 1 ifTrue:[ |
|
791 |
"/ p := (components copyWithoutLast:1) asStringWith:$/ |
|
792 |
"/ ] ifFalse:[ |
|
793 |
"/ p := fullName |
|
794 |
"/ ]. |
|
795 |
||
796 |
^ 'java:' , p |
|
797 |
||
798 |
" |
|
799 |
Java allClasses first fullName |
|
800 |
Java allClasses first package |
|
801 |
Java allClasses first javaPackage |
|
802 |
" |
|
803 |
! |
|
804 |
||
903 | 805 |
protectionDomain |
806 |
^ protectionDomain |
|
807 |
! |
|
808 |
||
809 |
protectionDomain:something |
|
810 |
protectionDomain := something. |
|
811 |
! |
|
812 |
||
752 | 813 |
runtimeVisibleAnnotationsAsBytesOrNil |
814 |
annotations ifNil:[ ^ nil ]. |
|
815 |
annotations runtimeVisible ifNil:[ ^ nil ]. |
|
816 |
^ annotations runtimeVisible bytes |
|
817 |
||
818 |
"Created: / 25-02-2011 / 16:48:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
819 |
! |
|
820 |
||
912
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
821 |
setSignature: aSymbol |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
822 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
823 |
signatureJ := aSymbol |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
824 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
825 |
"Created: / 13-08-2011 / 00:30:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
826 |
! |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
827 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
828 |
signatureJ |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
829 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
830 |
"stupid naming, but superclass defines signature too" |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
831 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
832 |
^signatureJ |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
833 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
834 |
"Created: / 13-08-2011 / 00:30:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
835 |
! |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
836 |
|
752 | 837 |
source |
1368 | 838 |
^ sourceString notNil |
839 |
ifTrue: [ sourceString ] |
|
840 |
ifFalse:[ Java classSourceOf:self ] |
|
752 | 841 |
|
842 |
" |
|
843 |
(Java at:'java.awt.Frame') source |
|
844 |
(Java at:'ArcTest') source |
|
845 |
(Java at:'ArcCanvas') source |
|
846 |
" |
|
847 |
||
1368 | 848 |
"Modified: / 30-07-1997 / 14:31:01 / cg" |
849 |
"Modified: / 18-02-2012 / 19:10:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 850 |
! |
851 |
||
852 |
sourceFile |
|
853 |
^ sourceFile |
|
854 |
! |
|
855 |
||
856 |
staticFields |
|
857 |
^ staticFields |
|
858 |
! |
|
859 |
||
860 |
superinterface |
|
861 |
||
862 |
| ifaces | |
|
863 |
||
864 |
self assert: self isInterface message: 'Type must be an interface'. |
|
865 |
(ifaces := self interfaces) size == 0 ifTrue:[^nil]. |
|
866 |
ifaces size = 1 ifTrue:[^ifaces first]. |
|
867 |
||
868 |
self error: 'Should not happen!!'. |
|
869 |
^nil |
|
870 |
||
871 |
"Created: / 04-02-2011 / 12:35:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
872 |
! |
|
873 |
||
874 |
typeOfField:aFieldName |
|
875 |
||
876 |
fields do:[:aField | |
|
877 |
aField name = aFieldName ifTrue:[ |
|
878 |
^ aField type |
|
879 |
] |
|
880 |
]. |
|
881 |
self error:'no such field' |
|
882 |
||
883 |
" |
|
884 |
(JAVA at:#'java/awt/image/ColorModel') typeOfField:'pixel_bits' |
|
885 |
" |
|
886 |
||
887 |
"Modified: 21.1.1997 / 22:48:28 / cg" |
|
888 |
! ! |
|
889 |
||
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
890 |
!JavaClass methodsFor:'accessing - java'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
891 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
892 |
javaMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
893 |
^self javaMirrorClass forClass: self. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
894 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
895 |
"Created: / 01-08-2012 / 00:18:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
896 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
897 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
898 |
javaMirrorClass |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
899 |
^JavaMirror mirrorClassForJavaClass |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
900 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
901 |
"Created: / 31-07-2012 / 17:39:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
902 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1527
diff
changeset
|
903 |
|
752 | 904 |
!JavaClass methodsFor:'adding / removing'! |
905 |
||
906 |
removeFromSystem |
|
907 |
Java removeClass:self |
|
908 |
||
909 |
"Created: 12.8.1997 / 02:46:51 / cg" |
|
910 |
! ! |
|
911 |
||
915 | 912 |
!JavaClass methodsFor:'autoboxing'! |
913 |
||
914 |
javaBox:anObject |
|
915 |
^ anObject |
|
916 |
||
917 |
"Created: / 14-08-2011 / 22:58:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1263 | 918 |
! |
919 |
||
920 |
javaUnwrap: object |
|
921 |
||
922 |
| nm | |
|
923 |
nm := object class name. |
|
924 |
||
925 |
nm == #'java/lang/Byte' ifTrue:[ |
|
926 |
^object instVarNamed: #value. |
|
927 |
]. |
|
928 |
nm == #'java/lang/Short' ifTrue:[ |
|
929 |
^object instVarNamed: #value. |
|
930 |
]. |
|
931 |
nm == #'java/lang/Integer' ifTrue:[ |
|
932 |
^object instVarNamed: #value. |
|
933 |
]. |
|
934 |
nm == #'java/lang/Long' ifTrue:[ |
|
935 |
^object instVarNamed: #value. |
|
936 |
]. |
|
937 |
nm == #'java/lang/Character' ifTrue:[ |
|
938 |
^Character codePoint: (object instVarNamed: #value) |
|
939 |
]. |
|
940 |
nm == #'java/lang/Boolean' ifTrue:[ |
|
941 |
^(object instVarNamed: #value) == 1 |
|
942 |
]. |
|
1271 | 943 |
nm == #'java/lang/String' ifTrue:[ |
944 |
^ Java as_ST_String: object |
|
945 |
]. |
|
1639 | 946 |
nm == #'java/lang/Class' ifTrue:[ |
947 |
^ JavaVM classForJavaClassObject: object |
|
948 |
]. |
|
1263 | 949 |
|
950 |
^object |
|
951 |
||
952 |
"Created: / 10-12-2011 / 19:54:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1271 | 953 |
"Modified: / 12-12-2011 / 18:05:29 / kursjan <kursjan@fit.cvut.cz>" |
1639 | 954 |
"Modified: / 21-08-2012 / 13:16:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1385 | 955 |
! |
956 |
||
957 |
javaWrap: object |
|
958 |
||
1652 | 959 |
object isNil ifTrue:[ ^ nil ]. |
1385 | 960 |
|
961 |
object class isJavaPrimitiveType ifTrue:[ |
|
962 |
(self name == #'java/lang/Object' or:[self == object class javaWrapperClass]) ifTrue:[ |
|
963 |
^object class javaWrapperClass newCleared |
|
964 |
instVarNamed: #value put: object; |
|
965 |
yourself |
|
966 |
]. |
|
967 |
]. |
|
968 |
||
969 |
object isString ifTrue:[ |
|
970 |
(self name == #'java/lang/Object' or:[ |
|
971 |
self name == #'java/lang/String']) ifTrue:[ |
|
972 |
^ Java as_String: object |
|
973 |
]. |
|
974 |
]. |
|
975 |
||
976 |
^object |
|
977 |
||
978 |
"Modified: / 12-12-2011 / 18:05:29 / kursjan <kursjan@fit.cvut.cz>" |
|
979 |
"Created: / 24-02-2012 / 19:32:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
915 | 980 |
! ! |
981 |
||
752 | 982 |
!JavaClass methodsFor:'browser interface'! |
983 |
||
984 |
isVisualStartable |
|
985 |
"return true, if this is an application class, |
|
986 |
which can be started via #open" |
|
987 |
"/ if I have a main() method, I am |
|
1033 | 988 |
|
989 |
(self compiledMethodAt: #'main([Ljava/lang/String;)V') notNil ifTrue: [ |
|
1028
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1027
diff
changeset
|
990 |
^ true |
752 | 991 |
]. |
1033 | 992 |
(self isSubclassOf: (JavaVM at: 'java/applet/Applet')) ifTrue: [ |
1028
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1027
diff
changeset
|
993 |
^ true. |
752 | 994 |
]. |
995 |
^ false |
|
996 |
! |
|
997 |
||
998 |
open |
|
999 |
"start a thread for my main method" |
|
1000 |
||
1001 |
"/ if I have a main, call it ... |
|
1002 |
||
1003 |
(self compiledMethodAt:#'main([Ljava/lang/String;)V') notNil ifTrue:[ |
|
1004 |
^ self startMain |
|
1005 |
]. |
|
1006 |
||
1007 |
"/ otherwise, create a frame and wrap me; |
|
1008 |
"/ as in: |
|
1009 |
||
1010 |
"/ public static void main(String args[]) { |
|
1011 |
"/ Frame f = new Frame("myName"); |
|
1012 |
"/ mySelf me = new mySelf(); |
|
1013 |
"/ |
|
1014 |
"/ me.init(); |
|
1015 |
"/ me.start(); |
|
1016 |
"/ |
|
1017 |
"/ f.add("Center", me); |
|
1018 |
"/ f.setSize(300, 300); |
|
1019 |
"/ f.show(); |
|
1020 |
"/ } |
|
1021 |
||
1022 |
^ self startApplet |
|
1023 |
||
1024 |
"Created: / 15.1.1998 / 17:18:30 / cg" |
|
1025 |
"Modified: / 3.11.1998 / 22:51:47 / cg" |
|
1026 |
! ! |
|
1027 |
||
1028 |
!JavaClass methodsFor:'compiler interface'! |
|
1029 |
||
1030 |
browserClass |
|
1031 |
"return the browser to use for this class - |
|
1032 |
this can be redefined in special classes, to get different browsers" |
|
1033 |
||
1034 |
"/ ^ JavaBrowser |
|
1035 |
^ super browserClass. |
|
1036 |
||
1037 |
"Modified: / 14.10.1998 / 15:28:38 / cg" |
|
1365 | 1038 |
! |
1039 |
||
1040 |
syntaxHighlighterClass |
|
1041 |
"return the class to use for syntaxHighlighting (prettyPrinting) this class - |
|
1042 |
this can be redefined in special classes, to highlight classes with |
|
1043 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
1044 |
||
1045 |
^ self class == JavaClass ifTrue:[ |
|
1046 |
super syntaxHighlighterClass |
|
1047 |
] ifFalse:[ |
|
1048 |
JavaLanguage instance syntaxHighlighterClass |
|
1049 |
] |
|
1050 |
||
1051 |
"Created: / 15-02-2012 / 01:43:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 1052 |
! ! |
1053 |
||
1054 |
!JavaClass methodsFor:'compiling'! |
|
1055 |
||
1056 |
recompileMethodsAccessingGlobal:aGlobalKey |
|
1057 |
"/ dummy for now |
|
1058 |
||
1059 |
"Created: / 9.11.1999 / 16:42:09 / cg" |
|
1060 |
! ! |
|
1061 |
||
1062 |
!JavaClass methodsFor:'documentation support'! |
|
1063 |
||
1064 |
htmlDocumentation |
|
1065 |
^ nil "/ replace by access to javadoc-generated documentation later |
|
1066 |
||
1067 |
"Modified: 22.3.1997 / 14:18:50 / cg" |
|
1068 |
! ! |
|
1069 |
||
1427
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1070 |
!JavaClass methodsFor:'exception handling support'! |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1071 |
|
1428
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1072 |
accepts: signal |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1073 |
"Return true, iff receicer is a throwable and |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1074 |
handles given signal (presumably another throwable class)" |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1075 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1076 |
| cls | |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1077 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1078 |
signal isJavaClass ifFalse:[ ^ false ]. |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1079 |
self == signal ifTrue:[ ^ true ]. |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1080 |
cls := signal. |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1081 |
[ cls ~~ JavaObject ] whileTrue:[ |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1082 |
self == cls ifTrue:[ ^ true ]. |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1083 |
cls := cls superclass. |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1084 |
]. |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1085 |
^false |
1427
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1086 |
|
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1087 |
"Created: / 18-03-2012 / 14:19:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1088 |
! |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1089 |
|
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1090 |
handles: anObject |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1091 |
|
1428
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1092 |
Transcript showCR:'>>>> JavaClass>>handles: ' , anObject printString. |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1093 |
Transcript showCR:' from: ', thisContext sender printString. |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1094 |
^false |
1427
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1095 |
|
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1096 |
"Created: / 18-03-2012 / 14:19:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1097 |
! |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1098 |
|
1626 | 1099 |
isControlInterrupt |
1100 |
^false |
|
1101 |
||
1102 |
"Created: / 20-08-2012 / 14:17:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1103 |
! |
|
1104 |
||
1428
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1105 |
isExceptionCreator |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1106 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1107 |
"/ ^false |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1108 |
^self isThrowable |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1109 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1110 |
"Created: / 18-03-2012 / 20:34:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1111 |
! |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1112 |
|
1427
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1113 |
isExceptionHandler |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1114 |
|
1428
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1115 |
"/ ^false |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1116 |
^self isThrowable |
1427
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1117 |
|
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1118 |
"Created: / 18-03-2012 / 14:18:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1119 |
! |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1120 |
|
1428
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1121 |
isQuerySignal |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1122 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1123 |
^false |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1124 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1125 |
"Created: / 18-03-2012 / 22:18:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1126 |
! |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1127 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1128 |
isThrowable |
1427
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1129 |
"Returns true, if the receiver is an instance |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1130 |
of java.lang.Throwable, false otherwise" |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1131 |
|
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1132 |
| cls | |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1133 |
cls := self. |
1481 | 1134 |
[ cls ~~ JavaObject ] whileTrue:[ |
1427
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1135 |
cls name == #'java/lang/Throwable' ifTrue:[ |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1136 |
^true |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1137 |
]. |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1138 |
cls := cls superclass. |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1139 |
]. |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1140 |
^false |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1141 |
|
1428
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1142 |
"Created: / 18-03-2012 / 20:35:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1143 |
! |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1144 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1145 |
mapyProceed |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1146 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1147 |
"Created: / 18-03-2012 / 20:35:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1148 |
! |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1149 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1150 |
parent |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1151 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1152 |
^nil |
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1153 |
|
902a1435f4ca
Initial support for handling Java exceptions in Smalltalk
vranyj1
parents:
1427
diff
changeset
|
1154 |
"Created: / 18-03-2012 / 22:19:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1507 | 1155 |
! |
1156 |
||
1157 |
signal |
|
1158 |
||
1159 |
^self class. |
|
1160 |
||
1161 |
"Created: / 05-07-2012 / 08:56:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1427
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1162 |
! ! |
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1163 |
|
752 | 1164 |
!JavaClass methodsFor:'executing programs'! |
1165 |
||
1166 |
startApplet |
|
1167 |
|f me stub top appFrame| |
|
1168 |
||
1169 |
top := StandardSystemView new. |
|
1170 |
appFrame := JavaEmbeddedFrameView new. |
|
1171 |
appFrame origin:0.0@0.0 corner:1.0@1.0. |
|
1172 |
top addSubView:appFrame. |
|
1173 |
||
1174 |
appFrame appletIsPreloaded:true. |
|
1175 |
appFrame codeURL:'file:/dummy'. |
|
1176 |
appFrame codeBaseURL:'file:/dummy'. |
|
1177 |
appFrame autoSetupApplet:true. |
|
1178 |
appFrame autoStartApplet:true. |
|
1179 |
appFrame autoDestroyApplet:true. |
|
1180 |
||
1181 |
||
1182 |
top open. |
|
1183 |
^ self. |
|
1184 |
||
1185 |
"/ TODO: setup embeddedAppletFrame correctly |
|
1186 |
"/ (for getParameter to work ...) |
|
1187 |
||
1188 |
"/ create a frame and wrap me; |
|
1189 |
"/ as in: |
|
1190 |
||
1191 |
"/ public static void main(String args[]) { |
|
1192 |
"/ Frame f = new Frame("myName"); |
|
1193 |
"/ mySelf me = new mySelf(); |
|
1194 |
"/ |
|
1195 |
"/ me.init(); |
|
1196 |
"/ me.start(); |
|
1197 |
"/ |
|
1198 |
"/ f.add("Center", me); |
|
1199 |
"/ f.setSize(300, 300); |
|
1200 |
"/ f.show(); |
|
1201 |
"/ } |
|
1202 |
f := (Java at:'java.awt.Frame') basicNew. |
|
1203 |
f perform:#'<init>(Ljava/lang/String;)V' with:(Java as_String:self name). |
|
1204 |
self halt. |
|
1205 |
me := self basicNew. |
|
1206 |
me perform:#'<init>()V'. |
|
1207 |
self halt. |
|
1208 |
||
1209 |
stub := (Java at:'netscape.applet.EmbeddedAppletFrame') new. |
|
1210 |
me instVarNamed:'stub' put:stub. |
|
1211 |
self halt. |
|
1212 |
||
1213 |
me perform:#'init()V'. |
|
1214 |
me perform:#'start()V'. |
|
1215 |
self halt. |
|
1216 |
||
1217 |
f perform:#'add(Ljava/lang/String;Ljava/awt/Component;)Ljava/awt/Component;' |
|
1218 |
with:(Java as_String:'Center') |
|
1219 |
with:me. |
|
1220 |
self halt. |
|
1221 |
f perform:#'setSize(II)V' with:300 with:300. |
|
1222 |
self halt. |
|
1223 |
f perform:#'show()V'. |
|
1224 |
self halt. |
|
1225 |
||
1226 |
"Modified: / 3.11.1998 / 23:04:41 / cg" |
|
1227 |
"/ TODO: setup embeddedAppletFrame correctly |
|
1228 |
"/ (for getParameter to work ...) |
|
1229 |
||
1230 |
"/ create a frame and wrap me; |
|
1231 |
"/ as in: |
|
1232 |
||
1233 |
"/ public static void main(String args[]) { |
|
1234 |
"/ Frame f = new Frame("myName"); |
|
1235 |
"/ mySelf me = new mySelf(); |
|
1236 |
"/ |
|
1237 |
"/ me.init(); |
|
1238 |
"/ me.start(); |
|
1239 |
"/ |
|
1240 |
"/ f.add("Center", me); |
|
1241 |
"/ f.setSize(300, 300); |
|
1242 |
"/ f.show(); |
|
1243 |
"/ } |
|
1244 |
f := (Java at:'java.awt.Frame') basicNew. |
|
1245 |
f perform:#'<init>(Ljava/lang/String;)V' with:(Java as_String:self name). |
|
1246 |
self halt. |
|
1247 |
me := self basicNew. |
|
1248 |
me perform:#'<init>()V'. |
|
1249 |
self halt. |
|
1250 |
||
1251 |
stub := (Java at:'netscape.applet.EmbeddedAppletFrame') new. |
|
1252 |
me instVarNamed:'stub' put:stub. |
|
1253 |
self halt. |
|
1254 |
||
1255 |
me perform:#'init()V'. |
|
1256 |
me perform:#'start()V'. |
|
1257 |
self halt. |
|
1258 |
||
1259 |
f perform:#'add(Ljava/lang/String;Ljava/awt/Component;)Ljava/awt/Component;' |
|
1260 |
with:(Java as_String:'Center') |
|
1261 |
with:me. |
|
1262 |
self halt. |
|
1263 |
f perform:#'setSize(II)V' with:300 with:300. |
|
1264 |
self halt. |
|
1265 |
f perform:#'show()V'. |
|
1266 |
self halt. |
|
1267 |
||
1268 |
"Modified: / 3.11.1998 / 23:04:41 / cg" |
|
1269 |
! |
|
1270 |
||
1271 |
startMain |
|
1272 |
"start a thread for my main() method" |
|
1273 |
||
1274 |
^ self startMainWithArgumentString:nil |
|
1275 |
||
1276 |
"Modified: / 30.12.1998 / 20:24:58 / cg" |
|
1277 |
! |
|
1278 |
||
1279 |
startMainWithArgumentString:aCommandLineString |
|
1280 |
"start a thread for my main() method, passing a string with arguments" |
|
1281 |
||
1282 |
|p| |
|
1283 |
||
1284 |
p := Java javaProcessForMainOf:self argumentString:aCommandLineString. |
|
1285 |
p notNil ifTrue:[ |
|
1286 |
p resume. |
|
1287 |
Object abortSignal handle:[:ex | |
|
1288 |
p == JavaVM javaScreenUpdaterThread ifTrue:[self halt]. |
|
1289 |
p == JavaVM javaEventQueueThread ifTrue:[self halt]. |
|
1290 |
p terminate. |
|
1291 |
ex reject. |
|
1292 |
] do:[ |
|
1293 |
p waitUntilTerminated |
|
1294 |
]. |
|
1295 |
] |
|
1296 |
||
1297 |
"Modified: / 24.12.1999 / 02:35:04 / cg" |
|
1298 |
! ! |
|
1299 |
||
1300 |
!JavaClass methodsFor:'fileOut'! |
|
1301 |
||
1302 |
basicFileOutDefinitionOn:aStream withNameSpace:nameSpaceBoolean |
|
1281 | 1303 |
|
1304 |
| source | |
|
1305 |
source := self theNonMetaclass source. |
|
1306 |
source notNil ifTrue:[ |
|
1307 |
aStream nextPutAll: source |
|
1308 |
] ifFalse:[ |
|
1309 |
JavaDecompiler definitionOf:self on:aStream |
|
1310 |
] |
|
1311 |
||
1312 |
"Modified: / 22-03-1997 / 14:30:28 / cg" |
|
1313 |
"Modified: / 14-12-2011 / 22:22:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 1314 |
! |
1315 |
||
1316 |
fileOut |
|
1317 |
self warn:'fileOut not yet supported' |
|
1318 |
||
1319 |
"Modified: 22.3.1997 / 14:30:28 / cg" |
|
1320 |
"Created: 22.3.1997 / 14:35:43 / cg" |
|
1697
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1321 |
! |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1322 |
|
1868 | 1323 |
fileOutInto: directory |
1324 |
"writes itself into the given directory including package hierarchy" |
|
1325 |
||
1326 |
| packageDir | |
|
1327 |
packageDir := directory / self javaPackageAsDirname. |
|
1328 |
packageDir recursiveMakeDirectory. |
|
1329 |
packageDir / (self lastName , '.java') |
|
1330 |
writingFileDo: [:out | self fileOutOn: out ]. |
|
1331 |
||
1332 |
"Created: / 08-12-2012 / 22:32:19 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>" |
|
1333 |
"Modified: / 09-12-2012 / 09:07:58 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>" |
|
1334 |
! |
|
1335 |
||
1697
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1336 |
fileOutMethod:aMethod on:aStream |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1337 |
"file out aMethod onto aStream. Used for example to write individual changeChunks" |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1338 |
|
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1339 |
|cat source privacy| |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1340 |
|
1812 | 1341 |
self assert: aMethod programmingLanguage isSmalltalk. |
1342 |
||
1697
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1343 |
aStream nextPutChunkSeparator. |
1812 | 1344 |
"/ aStream nextPutAll: 'JAVA'. |
1345 |
"/ (self name tokensBasedOn: $/) do:[:each| |
|
1346 |
"/ aStream space; nextPutAll: each. |
|
1347 |
"/ ]. |
|
1348 |
aStream nextPutAll:'(Java classForName:'''. |
|
1349 |
aStream nextPutAll:(self name copyReplaceAll:$/ with: $.). |
|
1350 |
aStream nextPutAll:''')'. |
|
1351 |
||
1697
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1352 |
(privacy := aMethod privacy) ~~ #public ifTrue:[ |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1353 |
aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'. |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1354 |
] ifFalse:[ |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1355 |
aStream nextPutAll:' methodsFor:'. |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1356 |
]. |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1357 |
|
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1358 |
cat := aMethod category ? ''. |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1359 |
aStream nextPutAll:cat asString storeString. |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1360 |
aStream nextPutChunkSeparator; cr; cr. |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1361 |
|
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1362 |
source := aMethod source. |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1363 |
source isNil ifTrue:[ |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1364 |
FileOutErrorSignal |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1365 |
raiseRequestWith:self |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1366 |
errorString:(' - no source for method: ' , |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1367 |
self name , '>>' , |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1368 |
(self selectorAtMethod:aMethod)) |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1369 |
] ifFalse:[ |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1370 |
aStream nextChunkPut:source. |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1371 |
]. |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1372 |
aStream space. |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1373 |
aStream nextPutChunkSeparator. |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1374 |
aStream cr |
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1375 |
|
0a9d598a6408
- Initial support for fileouting Java extension methods
vranyj1
parents:
1691
diff
changeset
|
1376 |
"Created: / 05-09-2012 / 00:01:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1812 | 1377 |
"Modified: / 07-11-2012 / 23:43:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1868 | 1378 |
! |
1379 |
||
1380 |
fileOutOn: aWriteStream |
|
1381 |
aWriteStream nextPutAll: self theNonMetaclass source. |
|
1382 |
||
1383 |
"Created: / 08-12-2012 / 22:25:28 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>" |
|
752 | 1384 |
! ! |
1385 |
||
1468 | 1386 |
!JavaClass methodsFor:'interop support'! |
1387 |
||
1388 |
perform:aMessage onReceiver:receiver from:sender ifNotFound:aBlock |
|
1389 |
||
1390 |
| lo method selector class args| |
|
1391 |
selector := aMessage selector. |
|
1392 |
args := aMessage arguments. |
|
1393 |
||
1394 |
(selector includes: $() ifTrue:[ |
|
1395 |
"Java selector, search static methods" |
|
1495
e661836af8e6
Interop fixes for long and double arguments (take two slots in arg vector)
vranyj1
parents:
1483
diff
changeset
|
1396 |
method := methodDictionary at:selector ifAbsent:[nil]. |
1468 | 1397 |
method notNil ifTrue:[ |
1398 |
method isStatic ifTrue:[ |
|
1399 |
^ method |
|
1400 |
valueWithReceiver:self |
|
1401 |
arguments:args |
|
1402 |
]. |
|
1403 |
]. |
|
1404 |
]. |
|
1405 |
||
1406 |
class := self class. |
|
1407 |
||
1408 |
JavaLookup isNil ifTrue:[ |
|
1409 |
(Smalltalk loadPackage: 'stx:libjava/experiments') ifFalse:[ |
|
1410 |
self error: 'You should load package stx:libjava/experiments if you want some interop - still experimental' mayProceed: true. |
|
1411 |
^nil |
|
1412 |
] |
|
1413 |
]. |
|
1414 |
||
1415 |
||
1639 | 1416 |
lo := class getLookupObject isNil ifTrue: [ JavaLookup instance ] ifFalse: [ class lookupObject ]. |
1468 | 1417 |
|
1418 |
method := lo lookupMethodForSelector: selector |
|
1419 |
directedTo: class |
|
1420 |
for: receiver |
|
1421 |
withArguments: args |
|
1422 |
from: thisContext sender |
|
1423 |
ilc: nil. |
|
1424 |
||
1425 |
method isNil ifTrue:[ |
|
1426 |
^aBlock value. |
|
1427 |
] ifFalse:[ |
|
1428 |
^ method valueWithReceiver: receiver arguments: args |
|
1429 |
]. |
|
1430 |
||
1431 |
"Created: / 19-09-2011 / 23:33:06 / Jan Kurs <kursjan@fit.cvut.cz>" |
|
1432 |
"Modified: / 10-04-2012 / 16:47:31 / kursjan" |
|
1639 | 1433 |
"Modified: / 21-08-2012 / 13:32:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1468 | 1434 |
! ! |
1435 |
||
752 | 1436 |
!JavaClass methodsFor:'java initialization'! |
1437 |
||
1438 |
classInit |
|
1439 |
"call the classes JAVA clinit function" |
|
1246
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1440 |
|
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1441 |
| m | |
1523
f5ffdad83ab9
Access to ACC_* and ACX_* constants unified. The only definition is in JavaConstants
vranyj1
parents:
1511
diff
changeset
|
1442 |
(accessFlags bitAnd: ACX_INITIALIZED) ~~ 0 ifTrue: [ ^ self ]. |
1526 | 1443 |
(accessFlags bitAnd: ACX_INITIALIZING) ~~ 0 ifTrue: [ ^ self ]. |
1444 |
accessFlags := accessFlags bitOr: ACX_INITIALIZING. |
|
1246
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1445 |
superclass ~~ JavaObject ifTrue: [ superclass classInit ]. |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1446 |
"JV@2011-12-03: Also call initializeStaticFields" |
1205 | 1447 |
self initializeStaticFields. |
1246
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1448 |
m := self compiledMethodAt: #'<clinit>()V'. |
1526 | 1449 |
m notNil ifTrue: [ |
1450 |
"/Logger log: ('calling <clinit>()V of %1' bindWith: self name) severity: #trace facility: 'JVM'. |
|
1246
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1451 |
OrderOfClassInits notNil ifTrue: [ OrderOfClassInits add: self. ]. |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1452 |
m |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1453 |
valueWithReceiver: self |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1454 |
arguments: #() |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1455 |
selector: #'<clinit>()V' |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1456 |
search: self class |
1526 | 1457 |
sender: nil. |
1458 |
"/Logger log: ('calling <clinit>()V of %1 done' bindWith: self name) severity: #trace facility: 'JVM'. |
|
752 | 1459 |
]. |
1526 | 1460 |
accessFlags := accessFlags bitOr: ACX_INITIALIZED. |
1461 |
accessFlags := accessFlags bitAnd: ACX_INITIALIZING bitInvert32. |
|
1462 |
||
1246
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1463 |
(JavaVM booted and: [JavaVM eagerResolvingEnabled] )ifTrue: [ |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1464 |
JavaClassReader classLoaderQuerySignal answer: classLoader |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1465 |
do: [ self resolveAll. ] |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1466 |
]. |
752 | 1467 |
|
1468 |
" |
|
1469 |
JavaVM instructionTrace:true. |
|
1470 |
JavaVM callTrace:true. |
|
1471 |
||
1472 |
(Java classNamed:'java.lang.String') classInit |
|
1473 |
(Java classNamed:'java.lang.System') classInit |
|
1474 |
||
1475 |
(Java classNamed:'java/io/FileDescriptor') classInit |
|
1246
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1476 |
(Java classNamed:'java.util.Properties') classInit" |
752 | 1477 |
|
1478 |
"Modified: / 12-11-1998 / 15:41:11 / cg" |
|
920 | 1479 |
"Modified: / 18-08-2011 / 19:37:33 / jv" |
1205 | 1480 |
"Modified: / 03-12-2011 / 12:19:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1246
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
1481 |
"Modified: / 08-12-2011 / 21:05:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1482 |
! |
1483 |
||
1732 | 1484 |
classInitInternal |
1485 |
"Called by the JIT-compiled code when a class needs to be initialized" |
|
1486 |
||
1487 |
self classInit. |
|
1488 |
"Force recompilation" |
|
1489 |
thisContext sender method flushCode. |
|
1490 |
||
1491 |
! |
|
1492 |
||
1362 | 1493 |
classInitSpecial |
1527 | 1494 |
"Called by the VM when a class needs to be initialized" |
1495 |
||
1362 | 1496 |
self classInit. |
1497 |
||
1498 |
"Created: / 08-02-2012 / 23:43:57 / mh <hlopik@gmail.com>" |
|
1527 | 1499 |
"Modified: / 17-07-2012 / 20:54:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1362 | 1500 |
! |
1501 |
||
752 | 1502 |
initializeStaticFields |
1503 |
staticFields isNil ifTrue:[^ self]. |
|
1504 |
||
1505 |
staticFields do:[:f | |
|
1205 | 1506 |
|val type| |
1507 |
||
1508 |
(val := f constantValue) isNil ifTrue:[ |
|
1509 |
"/ careful: int/long etc. constants must be initialized |
|
1510 |
"/ with correct type. |
|
1511 |
type := f type. |
|
1512 |
type == #long ifTrue:[ |
|
1513 |
val := 0. |
|
1514 |
] ifFalse:[type == #int ifTrue:[ |
|
1515 |
val := 0. |
|
1516 |
] ifFalse:[type == #float ifTrue:[ |
|
1517 |
val := 0.0 asShortFloat |
|
1518 |
] ifFalse:[type == #double ifTrue:[ |
|
1519 |
val := 0.0 |
|
1520 |
] ifFalse:[type == #byte ifTrue:[ |
|
1521 |
val := 0. |
|
1522 |
] ifFalse:[type == #char ifTrue:[ |
|
1523 |
val := 0. |
|
1524 |
] ifFalse:[type == #'unsigned short' ifTrue:[ |
|
1525 |
val := 0. |
|
1526 |
] ifFalse:[type == #boolean ifTrue:[ |
|
1527 |
val := 0. |
|
1528 |
]]]]]]]]. |
|
1529 |
] ifFalse:[ |
|
1530 |
val class == JavaStringRef2 ifTrue:[ |
|
1531 |
val := val resolve |
|
1532 |
]. |
|
1533 |
]. |
|
1534 |
self instVarNamed:(f name) put:val. |
|
752 | 1535 |
]. |
1205 | 1536 |
|
1537 |
"Modified: / 03-12-2011 / 12:28:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1135
79bdd1501934
java.lang.ClassLoader>>resolveClass0 native method now resolves whole constant pool
hlopkmar
parents:
1109
diff
changeset
|
1538 |
! |
79bdd1501934
java.lang.ClassLoader>>resolveClass0 native method now resolves whole constant pool
hlopkmar
parents:
1109
diff
changeset
|
1539 |
|
79bdd1501934
java.lang.ClassLoader>>resolveClass0 native method now resolves whole constant pool
hlopkmar
parents:
1109
diff
changeset
|
1540 |
resolveAll |
79bdd1501934
java.lang.ClassLoader>>resolveClass0 native method now resolves whole constant pool
hlopkmar
parents:
1109
diff
changeset
|
1541 |
"resolve every ref in constantPool" |
1247
59574ba88702
making eager resolving less eager - not calling classInit on each class (because then it does not boot :P)
hlopkmar
parents:
1246
diff
changeset
|
1542 |
|
1149 | 1543 |
constantPool do: [ |
1544 |
:each | |
|
1378 | 1545 |
(each isJavaRef or: [ each isJavaNameAndType ]) ifTrue: [ |
1546 |
each resolve: false |
|
1547 |
] |
|
1149 | 1548 |
]. |
1135
79bdd1501934
java.lang.ClassLoader>>resolveClass0 native method now resolves whole constant pool
hlopkmar
parents:
1109
diff
changeset
|
1549 |
|
79bdd1501934
java.lang.ClassLoader>>resolveClass0 native method now resolves whole constant pool
hlopkmar
parents:
1109
diff
changeset
|
1550 |
"Created: / 18-11-2011 / 15:26:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1378 | 1551 |
"Modified: / 23-02-2012 / 17:14:09 / Marcel Hlopko <hlopik@gmail.com>" |
752 | 1552 |
! ! |
1553 |
||
1554 |
!JavaClass methodsFor:'java instance creation'! |
|
1555 |
||
1793 | 1556 |
basicNew |
1557 |
"Create a new cleared JAVA instance. Its instVars are cleared to the |
|
1558 |
corresponding typed values; however, constructor is not invoked." |
|
1796 | 1559 |
|
1560 |
"/ Reimplemeted for speed as a C function. That function is |
|
1561 |
"/ also called from JIT-compiled code, resulting in 40-50% speedup |
|
1562 |
"/ when running Java code |
|
1563 |
||
1564 |
%{ |
|
1565 |
extern OBJ ___new(); |
|
1566 |
RETURN ( ___new(self) ); |
|
1567 |
%}. |
|
1568 |
" |
|
1569 |
memory allocation failed. |
|
1570 |
When we arrive here, there was no memory, even after |
|
1571 |
a garbage collect. |
|
1572 |
This means, that the VM wanted to get some more memory from the |
|
1573 |
Operatingsystem, which was not kind enough to give it. |
|
1574 |
Bad luck - you should increase the swap space on your machine. |
|
1575 |
" |
|
1576 |
^ ObjectMemory allocationFailureSignal raise. |
|
1577 |
||
1578 |
||
1579 |
"/ Following code is original Smalltalk implementation" |
|
1580 |
||
1581 |
||
1582 |
"/| newJavaObject |
|
1583 |
"/ sz "{ Class: SmallInteger }" |
|
1584 |
"/ offs "{ Class: SmallInteger }" |
|
1585 |
"/| |
|
1586 |
" |
|
1793 | 1587 |
(accessFlags bitAnd: ACX_ABSTRACT_OR_INTERFACE) ~~ 0 ifTrue: [ |
1588 |
JavaVM throwInstantiationExceptionFor: self. |
|
1589 |
^ nil |
|
1590 |
]. |
|
1591 |
newJavaObject := super basicNew. |
|
1794 | 1592 |
offs := JavaObject instSize. |
1593 |
offs > 0 ifTrue:[ |
|
1594 |
"Assume first is lockword" |
|
1595 |
newJavaObject instVarAt: 1 put: 0. |
|
1793 | 1596 |
]. |
1794 | 1597 |
initValues notNil ifTrue: [ |
1598 |
sz := self instSize. |
|
1795 | 1599 |
offs + 1 to: sz do: [:i | newJavaObject instVarAt: i put: (initValues at: i - offs) ]. |
1793 | 1600 |
]. |
1794 | 1601 |
self hasFinalize ifTrue:[ |
1602 |
newJavaObject registerForFinalization |
|
1603 |
]. |
|
1604 |
||
1605 |
||
1793 | 1606 |
^ newJavaObject |
1796 | 1607 |
" |
1793 | 1608 |
|
1609 |
" |
|
1610 |
(Java classNamed:'java.lang.String') basicNew inspect |
|
1611 |
(Java classNamed:'java.lang.String') newCleared inspect |
|
1796 | 1612 |
(Java classNamed:'java.lang.String') new inspect |
1613 |
" |
|
1793 | 1614 |
|
1615 |
"Created: / 02-11-2012 / 21:02:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1616 |
! |
|
1617 |
||
752 | 1618 |
initValueFor:instVarName |
1619 |
|idx field| |
|
1620 |
||
1621 |
idx := fields findFirst:[:field | field name = instVarName]. |
|
1622 |
idx == 0 ifTrue:[ |
|
1691 | 1623 |
superclass ~~ JavaObject ifTrue:[ |
1624 |
^ superclass initValueFor:instVarName |
|
1625 |
]. |
|
1626 |
^0 "/lockWord" |
|
752 | 1627 |
] ifFalse:[ |
1691 | 1628 |
field := fields at:idx. |
1629 |
^ field initialValue |
|
752 | 1630 |
]. |
1691 | 1631 |
|
1632 |
"Modified: / 26-08-2012 / 20:08:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 1633 |
! |
1634 |
||
1635 |
newCleared |
|
1793 | 1636 |
<resource: #obsolete> |
1637 |
"Use #basicNew" |
|
1638 |
||
1639 |
^self basicNew |
|
752 | 1640 |
|
1641 |
"Modified: / 13-11-1998 / 14:10:45 / cg" |
|
1642 |
"Modified: / 10-03-2011 / 22:38:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1793 | 1643 |
"Modified: / 02-11-2012 / 21:08:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1644 |
! |
1645 |
||
1646 |
newWith_String:argString |
|
1647 |
"create a new instance, preset its fields, |
|
1648 |
and call its JAVA init function passing a String arg" |
|
1649 |
||
1650 |
|newJavaObject| |
|
1651 |
||
1793 | 1652 |
newJavaObject := self basicNew. |
752 | 1653 |
newJavaObject |
1793 | 1654 |
perform:#'<init>(Ljava/lang/String;)V' |
1655 |
with:(Java as_String:argString). |
|
752 | 1656 |
^ newJavaObject |
1657 |
||
1658 |
" |
|
1659 |
((Java classNamed:'java.lang.ArrayStoreException') newWith_String:'foo') inspect |
|
1660 |
" |
|
1661 |
||
1793 | 1662 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
1663 |
"Created: / 13-11-1998 / 14:17:01 / cg" |
|
1664 |
"Modified: / 02-11-2012 / 21:11:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 1665 |
! |
1666 |
||
1667 |
newWith_int:arg |
|
1668 |
"create a new instance, preset its fields, |
|
1669 |
and call its JAVA init function passing an int arg" |
|
1670 |
||
1671 |
|newJavaObject| |
|
1672 |
||
1793 | 1673 |
newJavaObject := self basicNew. |
752 | 1674 |
newJavaObject perform:#'<init>(I)V' with:arg. |
1675 |
^ newJavaObject |
|
1676 |
||
1677 |
" |
|
1678 |
((Java classNamed:'java.lang.Integer') newWith_int:123) inspect |
|
1679 |
" |
|
1680 |
||
1793 | 1681 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
1682 |
"Created: / 13-11-1998 / 14:17:01 / cg" |
|
1683 |
"Modified: / 02-11-2012 / 21:11:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 1684 |
! ! |
1685 |
||
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1686 |
!JavaClass methodsFor:'java instance creation-proxying'! |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1687 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1688 |
new |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1689 |
"create a new instance, preset its fields, |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1690 |
and call its JAVA init function" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1691 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1692 |
|newJavaObject| |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1693 |
|
1793 | 1694 |
newJavaObject := self basicNew. |
1502
8caaac85827f
Initialization of Java Classes changed to be compatible with TO (I hope I did not broke anything!)
kursjan
parents:
1495
diff
changeset
|
1695 |
newJavaObject initialize. |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1696 |
^ newJavaObject |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1697 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1698 |
" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1699 |
(Java classNamed:'java.lang.String') basicNew inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1700 |
(Java classNamed:'java.lang.String') newCleared inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1701 |
(Java classNamed:'java.lang.String') new inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1702 |
" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1703 |
|
1502
8caaac85827f
Initialization of Java Classes changed to be compatible with TO (I hope I did not broke anything!)
kursjan
parents:
1495
diff
changeset
|
1704 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
8caaac85827f
Initialization of Java Classes changed to be compatible with TO (I hope I did not broke anything!)
kursjan
parents:
1495
diff
changeset
|
1705 |
"Modified: / 09-06-2012 / 21:48:36 / Jan Kurs (kursjan@fit.cvut.cz)" |
1793 | 1706 |
"Modified: / 02-11-2012 / 21:10:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1707 |
! |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1708 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1709 |
new: arg1 |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1710 |
"create a new instance and call one-arg constructor" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1711 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1712 |
|newJavaObject| |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1713 |
|
1793 | 1714 |
newJavaObject := self basicNew. |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1715 |
newJavaObject perform:#'<init>:' with: arg1. |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1716 |
^ newJavaObject |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1717 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1718 |
" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1719 |
(Java classNamed:'java.lang.String') basicNew inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1720 |
(Java classNamed:'java.lang.String') newCleared inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1721 |
(Java classNamed:'java.lang.String') new inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1722 |
" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1723 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1724 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1725 |
"Created: / 17-03-2012 / 15:09:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1793 | 1726 |
"Modified: / 02-11-2012 / 21:10:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1727 |
! |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1728 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1729 |
new: arg1 _: arg2 |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1730 |
^self new: arg1 with: arg2 |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1731 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1732 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1733 |
"Created: / 17-03-2012 / 15:12:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1734 |
! |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1735 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1736 |
new: arg1 _: arg2 _: arg3 |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1737 |
^self new: arg1 with: arg2 with: arg3 |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1738 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1739 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1740 |
"Created: / 17-03-2012 / 15:13:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1741 |
! |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1742 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1743 |
new: arg1 _: arg2 _: arg3 _: arg4 |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1744 |
^self new: arg1 with: arg2 with: arg3 with: arg4 |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1745 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1746 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1747 |
"Created: / 17-03-2012 / 15:13:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1748 |
! |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1749 |
|
1449 | 1750 |
new: arg1 _: arg2 _: arg3 _: arg4 _: arg5 |
1751 |
^ self |
|
1752 |
new: arg1 |
|
1753 |
with: arg2 |
|
1754 |
with: arg3 |
|
1755 |
with: arg4 |
|
1756 |
with: arg5 |
|
1757 |
||
1758 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
|
1759 |
"Created: / 17-03-2012 / 15:13:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1760 |
"Created: / 03-04-2012 / 12:17:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1761 |
! |
|
1762 |
||
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1763 |
new: arg1 with: arg2 |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1764 |
"create a new instance and call 2-arg constructor" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1765 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1766 |
|newJavaObject| |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1767 |
|
1793 | 1768 |
newJavaObject := self basicNew. |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1769 |
newJavaObject perform:#'<init>:_:' with: arg1 with: arg2. |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1770 |
^ newJavaObject |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1771 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1772 |
" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1773 |
(Java classNamed:'java.lang.String') basicNew inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1774 |
(Java classNamed:'java.lang.String') newCleared inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1775 |
(Java classNamed:'java.lang.String') new inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1776 |
" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1777 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1778 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1779 |
"Created: / 17-03-2012 / 15:12:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1793 | 1780 |
"Modified: / 02-11-2012 / 21:10:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1781 |
! |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1782 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1783 |
new: arg1 with: arg2 with: arg3 |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1784 |
"create a new instance and call 3-arg constructor" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1785 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1786 |
|newJavaObject| |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1787 |
|
1793 | 1788 |
newJavaObject := self basicNew. |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1789 |
newJavaObject perform:#'<init>:_:_:' with: arg1 with: arg2 with: arg3. |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1790 |
^ newJavaObject |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1791 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1792 |
" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1793 |
(Java classNamed:'java.lang.String') basicNew inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1794 |
(Java classNamed:'java.lang.String') newCleared inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1795 |
(Java classNamed:'java.lang.String') new inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1796 |
" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1797 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1798 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1799 |
"Created: / 17-03-2012 / 15:12:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1793 | 1800 |
"Modified: / 02-11-2012 / 21:10:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1801 |
! |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1802 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1803 |
new: arg1 with: arg2 with: arg3 with: arg4 |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1804 |
"create a new instance and call 4-arg constructor" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1805 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1806 |
|newJavaObject| |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1807 |
|
1793 | 1808 |
newJavaObject := self basicNew. |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1809 |
newJavaObject perform:#'<init>:_:_:_:' with: arg1 with: arg2 with: arg3 with: arg4. |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1810 |
^ newJavaObject |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1811 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1812 |
" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1813 |
(Java classNamed:'java.lang.String') basicNew inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1814 |
(Java classNamed:'java.lang.String') newCleared inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1815 |
(Java classNamed:'java.lang.String') new inspect |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1816 |
" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1817 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1818 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1819 |
"Created: / 17-03-2012 / 15:12:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1793 | 1820 |
"Modified: / 02-11-2012 / 21:10:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1447 | 1821 |
! |
1822 |
||
1823 |
new: arg1 with: arg2 with: arg3 with: arg4 with: arg5 |
|
1824 |
"create a new instance and call 4-arg constructor" |
|
1825 |
||
1826 |
| newJavaObject | |
|
1793 | 1827 |
newJavaObject := self basicNew. |
1447 | 1828 |
newJavaObject |
1829 |
perform: #'<init>:_:_:_:_:' |
|
1830 |
with: arg1 |
|
1831 |
with: arg2 |
|
1832 |
with: arg3 |
|
1833 |
with: arg4 |
|
1834 |
with: arg5. |
|
1835 |
^ newJavaObject |
|
1836 |
||
1837 |
" |
|
1838 |
(Java classNamed:'java.lang.String') basicNew inspect |
|
1839 |
(Java classNamed:'java.lang.String') newCleared inspect |
|
1840 |
(Java classNamed:'java.lang.String') new inspect" |
|
1841 |
||
1842 |
"Modified: / 04-11-1998 / 18:04:34 / cg" |
|
1843 |
"Created: / 17-03-2012 / 15:12:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1844 |
"Created: / 02-04-2012 / 10:52:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1793 | 1845 |
"Modified: / 02-11-2012 / 21:10:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1846 |
! ! |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1847 |
|
752 | 1848 |
!JavaClass methodsFor:'message sending'! |
1849 |
||
1850 |
doesNotUnderstand:aMessage |
|
1344 | 1851 |
| sender | |
1852 |
sender := thisContext sender. |
|
1853 |
^self |
|
1854 |
perform: aMessage |
|
1855 |
onReceiver: self |
|
1856 |
from: sender |
|
1857 |
ifNotFound: [ super doesNotUnderstand: aMessage ]. |
|
752 | 1858 |
|
1281 | 1859 |
"Modified: / 16-11-1998 / 16:50:56 / cg" |
1860 |
"Modified: / 19-09-2011 / 23:43:56 / Jan Kurs <kursjan@fit.cvut.cz>" |
|
1344 | 1861 |
"Modified (comment): / 01-01-2012 / 19:36:41 / kursjan <kursjan@fit.cvut.cz>" |
1862 |
"Modified: / 03-01-2012 / 21:02:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1863 |
! |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1864 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1865 |
lookupFieldFor:fname static: searchStatic onlyPublic: publicOnly |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1866 |
"Lookup a field with given name in class and all |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1867 |
its subclasses, return an instance of JavaField |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1868 |
or nil, if none is found. |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1869 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1870 |
If searchStatic is true, static fields are searched, |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1871 |
otherwise it searches inst and interface fields. |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1872 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1873 |
If publicOnly is true, only public field are searched" |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1874 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1875 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1876 |
| cls field | |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1877 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1878 |
cls := self. |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1879 |
[ cls ~~ JavaObject ] whileTrue:[ |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1880 |
searchStatic ifTrue:[ |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1881 |
field := cls findStaticFieldByName: fname. |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1882 |
field isNil ifTrue:[ |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1883 |
field := cls findInterfaceFieldByName: fname |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1884 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1885 |
] |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1886 |
] ifFalse:[ |
1452
69dcb9c33742
Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents:
1449
diff
changeset
|
1887 |
field := cls findInstFieldByName: fname |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1888 |
]. |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1889 |
field notNil ifTrue:[ |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1890 |
(publicOnly and:[field isPublic not]) ifTrue:[ |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1891 |
^ nil |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1892 |
] ifFalse:[ |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1893 |
^ field |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1894 |
] |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1895 |
]. |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1896 |
cls := cls superclass. |
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1897 |
]. |
1427
13f3765a9bba
Some experiments with Exceptions, not that easy :-)
vranyj1
parents:
1425
diff
changeset
|
1898 |
^nil. |
1425
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1899 |
|
820078605f73
- Improvements in interop - now can generate getters to public field.
vranyj1
parents:
1393
diff
changeset
|
1900 |
"Created: / 17-03-2012 / 16:41:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1901 |
! ! |
1902 |
||
1903 |
||
1904 |
!JavaClass methodsFor:'printOut'! |
|
1905 |
||
1906 |
printNameInHierarchy |
|
1907 |
"return my name as printed in the hierarchy" |
|
1908 |
||
1909 |
^ self displayString |
|
1910 |
||
1911 |
"Modified: 22.3.1997 / 14:16:55 / cg" |
|
1912 |
! |
|
1913 |
||
1914 |
printOutOn:aStream |
|
1915 |
self warn:'printOut not yet supported' |
|
1916 |
||
1917 |
"Created: 22.3.1997 / 14:36:12 / cg" |
|
1918 |
! |
|
1919 |
||
1920 |
printOutProtocolOn:aStream |
|
1921 |
self warn:'printOut not yet supported' |
|
1922 |
||
1923 |
"Created: 22.3.1997 / 14:36:28 / cg" |
|
1924 |
! ! |
|
1925 |
||
1926 |
!JavaClass methodsFor:'printing & storing'! |
|
1927 |
||
1928 |
displayString |
|
1929 |
^ fullName copyReplaceAll:$/ with:$. |
|
1930 |
||
1931 |
"/ ^ 'JAVA-' , name . |
|
1932 |
"/ ^ name , '(Java)' "/ 'JavaClass(' , name , ')' |
|
1933 |
||
1934 |
"Created: / 15.4.1996 / 16:02:48 / cg" |
|
1935 |
"Modified: / 18.7.1998 / 22:56:30 / cg" |
|
1936 |
! ! |
|
1937 |
||
1938 |
!JavaClass methodsFor:'private accessing'! |
|
1939 |
||
1940 |
addMethod:m name:name signature:signature |
|
1941 |
|sel| |
|
1942 |
||
1943 |
sel := (name , signature) asSymbol. |
|
1453 | 1944 |
self primAddSelector:sel withMethod:m. |
752 | 1945 |
^ self. |
1946 |
||
1947 |
"/ selectorArray isNil ifTrue:[ |
|
1948 |
"/ selectorArray := #(). |
|
1949 |
"/ methodArray := #() |
|
1950 |
"/ ]. |
|
1951 |
"/ selectorArray := selectorArray copyWith:(name , signature) asSymbol. "/ name. |
|
1952 |
"/"/ selectorArray := selectorArray copyWith:name asSymbol. "/ name. |
|
1953 |
"/ methodArray := methodArray copyWith:m |
|
1954 |
||
1453 | 1955 |
"Created: / 15-04-1996 / 16:42:52 / cg" |
1956 |
"Modified: / 04-04-2012 / 01:18:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 1957 |
! |
1958 |
||
1959 |
addSelector:newSelector withMethod:newMethod |
|
1483 | 1960 |
|
1961 |
^super addSelector:newSelector withMethod:newMethod |
|
1962 |
||
1963 |
"/ "redefined to not flush smalltalk caches and send NO smalltalk-class |
|
1964 |
"/ change notification. Will eventually flush Java caches." |
|
1965 |
"/ |
|
1966 |
"/ |nargs oldMethod| |
|
1967 |
"/ |
|
1968 |
"/ oldMethod := self compiledMethodAt:newSelector. |
|
1969 |
"/ (self primAddSelector:newSelector withMethod:newMethod) ifFalse:[^ false]. |
|
1970 |
"/ |
|
1971 |
"/ ^ true |
|
1972 |
"/ |
|
1973 |
"/ |
|
1974 |
||
1975 |
"Created: / 20-01-1997 / 13:00:48 / cg" |
|
1976 |
"Modified: / 20-04-2012 / 20:27:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 1977 |
! |
1978 |
||
1979 |
setAccessFlags:flags |
|
1980 |
accessFlags := flags. |
|
1981 |
||
1982 |
"Created: 15.4.1996 / 16:42:52 / cg" |
|
1983 |
! |
|
1984 |
||
1985 |
setBinaryFilePath:aPathName |
|
1986 |
binaryFilePath := aPathName |
|
1987 |
! |
|
1988 |
||
1989 |
setFields:f |
|
1794 | 1990 |
| nignored nvals vals names | |
752 | 1991 |
|
1992 |
JavaClass setInstanceVariableStringFromFields:f in:self. |
|
1993 |
||
1994 |
instSize := superclass instSize + f size. |
|
1995 |
fields := f. |
|
1996 |
||
1997 |
f withIndexDo:[:field :index| |
|
1998 |
field setClass: self. |
|
1999 |
field setIndex: superclass instSize + index. |
|
2000 |
]. |
|
2001 |
||
1794 | 2002 |
"Now, collect initValues. Ignore the lockword, if any" |
2003 |
nignored := JavaObject instSize. "/except possible instvars in JavaObject (lockword) |
|
2004 |
nvals := self instSize - nignored. |
|
2005 |
nvals > 0 ifTrue:[ |
|
2006 |
vals := Array new: nvals. |
|
2007 |
names := self allInstVarNames. |
|
2008 |
JavaObject instSize + 1 to: names size do:[:i| |
|
2009 |
| val | |
|
2010 |
val := self initValueFor: (names at: i). |
|
2011 |
val notNil ifTrue:[ |
|
2012 |
vals at: i - nignored put: val. |
|
2013 |
initValues := vals. |
|
2014 |
] |
|
2015 |
]. |
|
752 | 2016 |
] |
2017 |
||
2018 |
"Created: / 15-04-1996 / 16:42:52 / cg" |
|
2019 |
"Modified: / 06-11-1998 / 01:53:01 / cg" |
|
1794 | 2020 |
"Modified: / 02-11-2012 / 21:49:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 2021 |
! |
2022 |
||
2023 |
setFullName:aString |
|
2024 |
|nameComponents| |
|
2025 |
||
2026 |
fullName := aString asSymbol. |
|
2027 |
"/ nameComponents := aString asCollectionOfSubstringsSeparatedBy:$/. |
|
2028 |
"/ name := nameComponents last asSymbol. |
|
2029 |
name := fullName. |
|
2030 |
||
2031 |
"Created: / 15.4.1996 / 16:42:52 / cg" |
|
2032 |
"Modified: / 5.11.1998 / 19:14:39 / cg" |
|
2033 |
! |
|
2034 |
||
1372
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1368
diff
changeset
|
2035 |
setInterfaces: i |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1368
diff
changeset
|
2036 |
|
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1368
diff
changeset
|
2037 |
super setInterfaces: i. |
752 | 2038 |
i size > 0 ifTrue:[ |
1372
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1368
diff
changeset
|
2039 |
i do:[:iface| |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1368
diff
changeset
|
2040 |
iface name = 'groovy/lang/GroovyObject' ifTrue:[ |
1453 | 2041 |
self class changeClassTo: GroovyMetaclass. |
1372
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1368
diff
changeset
|
2042 |
self class setSuperclass: GroovyClass. |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1368
diff
changeset
|
2043 |
] |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1368
diff
changeset
|
2044 |
] |
752 | 2045 |
] |
2046 |
||
1372
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1368
diff
changeset
|
2047 |
"Created: / 20-02-2012 / 22:47:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 2048 |
! |
2049 |
||
1368 | 2050 |
setSource: aString |
2051 |
self assert: aString isString. |
|
2052 |
sourceString := aString |
|
2053 |
||
2054 |
"Created: / 15-04-1996 / 16:42:52 / cg" |
|
2055 |
"Created: / 18-02-2012 / 19:10:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2056 |
! |
|
2057 |
||
752 | 2058 |
setSourceFile:aFilename |
2059 |
sourceFile := aFilename. |
|
2060 |
||
2061 |
"Created: 15.4.1996 / 16:42:52 / cg" |
|
2062 |
! |
|
2063 |
||
2064 |
setStaticFields:f |
|
2065 |
JavaClass setInstanceVariableStringFromFields:f in:self class. |
|
2066 |
||
2067 |
staticFields := f. |
|
2068 |
||
918 | 2069 |
"Modified: / 17-08-2011 / 09:26:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 2070 |
! |
2071 |
||
2072 |
setSuperclass:aClass |
|
2073 |
|iVars numIvars| |
|
2074 |
||
2075 |
aClass isNil ifTrue:[ |
|
2076 |
super setSuperclass:JavaObject |
|
2077 |
] ifFalse:[ |
|
2078 |
(aClass isMemberOf:JavaUnresolvedClassConstant) ifTrue:[ |
|
2079 |
self halt. |
|
2080 |
]. |
|
2081 |
super setSuperclass:aClass. |
|
2082 |
]. |
|
2083 |
||
2084 |
iVars := self instVarNames. |
|
2085 |
((numIvars := iVars size) > 0) ifTrue:[ |
|
2086 |
(superclass notNil and:[(superclass isMemberOf:JavaUnresolvedClassConstant) not]) ifTrue:[ |
|
2087 |
instSize := superclass instSize + numIvars |
|
2088 |
] ifFalse:[ |
|
2089 |
instSize := numIvars |
|
2090 |
] |
|
2091 |
]. |
|
2092 |
||
2093 |
"Created: 15.4.1996 / 16:42:52 / cg" |
|
2094 |
"Modified: 22.8.1997 / 15:06:45 / cg" |
|
2095 |
! ! |
|
2096 |
||
2097 |
!JavaClass methodsFor:'private-changes management'! |
|
2098 |
||
2099 |
writingChangeWithTimeStamp:doStampIt do:aBlock |
|
2100 |
||
2101 |
"No changes for Java classes now" |
|
2102 |
||
2103 |
"Created: / 14-12-2010 / 18:07:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2104 |
! ! |
|
2105 |
||
2106 |
!JavaClass methodsFor:'queries'! |
|
2107 |
||
2108 |
canBeSubclassed |
|
2109 |
"return true, if its allowed to create subclasses of the receiver." |
|
2110 |
||
2111 |
self isFinal ifTrue:[^ false]. |
|
2112 |
self isInterface ifTrue:[^ false]. |
|
2113 |
^ true |
|
2114 |
||
2115 |
"Created: / 5.11.1998 / 23:04:50 / cg" |
|
2116 |
! |
|
2117 |
||
1478 | 2118 |
canHaveExtensions |
2119 |
^false |
|
2120 |
||
2121 |
"Created: / 13-04-2012 / 18:55:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2122 |
! |
|
2123 |
||
752 | 2124 |
containsMethodsAnnotatedWith:aJavaTypeName |
2125 |
| methods | |
|
2126 |
||
2127 |
methods := self selectMethodsAnnotatedWith:aJavaTypeName. |
|
2128 |
methods size > 0 ifTrue:[ ^ true ]. |
|
2129 |
(self name ~= #'java/lang/Object') |
|
2130 |
ifTrue:[ ^ superclass containsMethodsAnnotatedWith:aJavaTypeName. ]. |
|
2131 |
^ false. |
|
2132 |
||
2133 |
"Created: / 02-03-2011 / 23:01:14 / Marcel Hlopko <hlopik@gmail.com>" |
|
2134 |
! |
|
2135 |
||
1794 | 2136 |
hasFinalize |
2137 |
^ (accessFlags bitAnd:ACX_HASFINALIZE) ~~ 0 |
|
2138 |
||
2139 |
"Created: / 02-11-2012 / 18:50:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2140 |
! |
|
2141 |
||
752 | 2142 |
hasInterface:aJavaInterface |
2143 |
"return true, if I respond to all methods as |
|
2144 |
required by the argument, an aJavaInterface" |
|
2145 |
||
2146 |
interfaces size > 0 ifTrue:[ |
|
2147 |
self interfaces do:[:if | |
|
2148 |
aJavaInterface == if ifTrue:[ |
|
2149 |
^ true |
|
2150 |
]. |
|
2151 |
] |
|
2152 |
]. |
|
2153 |
superclass isJavaClass ifTrue:[ |
|
2154 |
^ superclass hasInterface:aJavaInterface |
|
2155 |
]. |
|
2156 |
^ false. |
|
2157 |
||
2158 |
"/ aJavaInterface methodDictionary keysAndValuesDo:[:sel :mthd | |
|
2159 |
"/ (self canUnderstand:sel) ifFalse:[ |
|
2160 |
"/ ^ false. |
|
2161 |
"/ ] |
|
2162 |
"/ ]. |
|
2163 |
^ true |
|
2164 |
||
2165 |
"Modified: / 28.1.1998 / 01:46:16 / cg" |
|
2166 |
||
2167 |
! |
|
2168 |
||
1830
ef4a91a5d32c
MagicAccessorImpl has his magic now (permissions not checked for subclasses)
hlopkmar
parents:
1818
diff
changeset
|
2169 |
hasMagicAccessRights |
ef4a91a5d32c
MagicAccessorImpl has his magic now (permissions not checked for subclasses)
hlopkmar
parents:
1818
diff
changeset
|
2170 |
"Classes subclassing from sun.reflect.MagicAccessorImpl are not subject to access rights checks. Another non-documented gem found in openjdk sources :)" |
ef4a91a5d32c
MagicAccessorImpl has his magic now (permissions not checked for subclasses)
hlopkmar
parents:
1818
diff
changeset
|
2171 |
|
ef4a91a5d32c
MagicAccessorImpl has his magic now (permissions not checked for subclasses)
hlopkmar
parents:
1818
diff
changeset
|
2172 |
| magicAccessor | |
ef4a91a5d32c
MagicAccessorImpl has his magic now (permissions not checked for subclasses)
hlopkmar
parents:
1818
diff
changeset
|
2173 |
magicAccessor := Java classNamed: 'sun.reflect.MagicAccessorImpl'. |
ef4a91a5d32c
MagicAccessorImpl has his magic now (permissions not checked for subclasses)
hlopkmar
parents:
1818
diff
changeset
|
2174 |
^ magicAccessor notNil and: [ self includesBehavior: magicAccessor ]. |
ef4a91a5d32c
MagicAccessorImpl has his magic now (permissions not checked for subclasses)
hlopkmar
parents:
1818
diff
changeset
|
2175 |
|
ef4a91a5d32c
MagicAccessorImpl has his magic now (permissions not checked for subclasses)
hlopkmar
parents:
1818
diff
changeset
|
2176 |
"Created: / 18-11-2012 / 16:11:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
ef4a91a5d32c
MagicAccessorImpl has his magic now (permissions not checked for subclasses)
hlopkmar
parents:
1818
diff
changeset
|
2177 |
! |
ef4a91a5d32c
MagicAccessorImpl has his magic now (permissions not checked for subclasses)
hlopkmar
parents:
1818
diff
changeset
|
2178 |
|
884 | 2179 |
isAnonymous |
2180 |
||
2181 |
| i | |
|
2182 |
i := name lastIndexOf: $$. |
|
2183 |
i ~~ 0 ifTrue:[ |
|
2184 |
i + 1 to: name size do:[:i| |
|
2185 |
(name at:i) isDigit ifFalse:[^false]. |
|
2186 |
]. |
|
2187 |
^true |
|
2188 |
]. |
|
2189 |
^false |
|
2190 |
||
2191 |
" |
|
2192 |
(Java at:'java.io.Console') isAnonymous |
|
2193 |
(Java at:'java.io.Console$1') isAnonymous |
|
2194 |
(Java at:'java.io.Console$1$1') isAnonymous |
|
2195 |
(Java at:'sun.misc.Launcher$ExtClassLoader') isAnonymous |
|
2196 |
||
2197 |
" |
|
2198 |
||
2199 |
"Created: / 18-03-1997 / 17:48:01 / cg" |
|
2200 |
"Created: / 07-08-2011 / 15:50:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2201 |
! |
|
2202 |
||
1246
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
2203 |
isFullyResolved |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
2204 |
constantPool do: [:each | (each isJavaRef and: [each isResolved not]) ifTrue: [^false]]. |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
2205 |
^ true. |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
2206 |
|
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
2207 |
"Created: / 08-12-2011 / 20:44:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
2208 |
! |
2e7d85df01f8
resolveClass native resolves whole CP, for even more eager resolving, run JavaVM enableEagerResolving :)
hlopkmar
parents:
1241
diff
changeset
|
2209 |
|
752 | 2210 |
isJavaArrayClass |
2211 |
||
2212 |
^false |
|
2213 |
||
2214 |
"Created: / 05-02-2011 / 22:20:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2215 |
! |
|
2216 |
||
2217 |
isJavaClass |
|
2218 |
^ self ~~ JavaClass |
|
2219 |
||
2220 |
"Created: 18.3.1997 / 17:48:01 / cg" |
|
2221 |
! |
|
2222 |
||
2223 |
isJavaClassType |
|
2224 |
||
2225 |
^self isInterface not |
|
2226 |
||
2227 |
" |
|
2228 |
(Java classForName:'java.lang.Class') isJavaClassType |
|
2229 |
" |
|
2230 |
||
2231 |
"Created: / 11-02-2011 / 08:09:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2232 |
! |
|
2233 |
||
2234 |
isJavaInterfaceType |
|
2235 |
||
2236 |
^self isInterface |
|
2237 |
||
2238 |
" |
|
2239 |
(Java classForName:'java.lang.Class') isJavaInterfaceType |
|
2240 |
" |
|
2241 |
||
2242 |
"Created: / 11-02-2011 / 08:09:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2243 |
! |
|
2244 |
||
2245 |
isJavaMethodRef |
|
2246 |
^ false |
|
2247 |
||
2248 |
"Created: / 9.11.1999 / 15:42:10 / cg" |
|
2249 |
! |
|
2250 |
||
2251 |
isJavaPrimitiveType |
|
2252 |
||
2253 |
^false |
|
2254 |
||
2255 |
" |
|
2256 |
(Java classForName:'java.lang.Class') isJavaPrimitiveType |
|
2257 |
ByteArray isJavaPrimitiveType |
|
2258 |
" |
|
2259 |
||
2260 |
"Created: / 21-12-2010 / 23:03:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2261 |
! |
|
2262 |
||
2263 |
isJavaReferenceType |
|
2264 |
||
2265 |
^true |
|
2266 |
||
2267 |
" |
|
2268 |
(Java classForName:'java.lang.Class') isJavaReferenceType |
|
2269 |
" |
|
2270 |
||
2271 |
"Created: / 20-12-2010 / 21:54:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2272 |
! |
|
2273 |
||
2274 |
isJavaType |
|
2275 |
||
2276 |
^true |
|
2277 |
||
2278 |
" |
|
2279 |
(Java classForName:'java.lang.Class') isJavaType |
|
2280 |
" |
|
2281 |
||
2282 |
"Created: / 20-12-2010 / 21:53:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2283 |
! |
|
2284 |
||
1332 | 2285 |
isJavaWrapperClass |
2286 |
"Returns true, iff receiver is one of the Java wrapper classes or String" |
|
2287 |
||
2288 |
name == #'java/lang/Byte' ifTrue:[^true]. |
|
2289 |
name == #'java/lang/Short' ifTrue:[^true]. |
|
2290 |
name == #'java/lang/Integer' ifTrue:[^true]. |
|
2291 |
name == #'java/lang/Long' ifTrue:[^true]. |
|
2292 |
name == #'java/lang/Character' ifTrue:[^true]. |
|
2293 |
name == #'java/lang/Boolean' ifTrue:[^true]. |
|
2294 |
name == #'java/lang/String' ifTrue:[^true]."/Not really a wrapper, but..." |
|
2295 |
||
2296 |
^false. |
|
2297 |
||
2298 |
"Created: / 26-12-2011 / 22:03:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2299 |
! |
|
2300 |
||
752 | 2301 |
isUnresolved |
2302 |
"return true, if the receiver is unresolved; |
|
2303 |
javaClasses are never; JavaUnresolvedClasses are always" |
|
2304 |
||
2305 |
^ false |
|
2306 |
||
2307 |
"Modified: / 07-05-1998 / 12:23:14 / cg" |
|
2308 |
"Created: / 06-03-2011 / 22:57:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
2309 |
! |
|
2310 |
||
2311 |
nameInBrowser |
|
2312 |
"return a nameString as shown in browsers" |
|
2313 |
||
2314 |
^ self name copyReplaceAll:$/ with:$. |
|
2315 |
! |
|
2316 |
||
2317 |
nameSpacePath |
|
2318 |
|parts s| |
|
2319 |
||
2320 |
parts := self fullName asCollectionOfSubstringsSeparatedBy:$/. |
|
2321 |
s := '' writeStream. |
|
2322 |
s nextPutAll:'JAVA'. |
|
2323 |
parts from:1 to:(parts size - 1) do:[:aPart | |
|
2324 |
s nextPutAll:'::'. |
|
2325 |
s nextPutAll:aPart |
|
2326 |
]. |
|
2327 |
^ s contents |
|
2328 |
||
2329 |
" |
|
2330 |
JAVA::java::lang::Object fullName |
|
2331 |
JAVA::java::lang::Object nameSpacePath |
|
2332 |
JAVA::java::lang::Object name |
|
2333 |
" |
|
2334 |
||
2335 |
"Modified: / 19.10.1998 / 20:07:24 / cg" |
|
2336 |
! |
|
2337 |
||
2338 |
selectMethodsAnnotatedWith:aJavaTypeName |
|
2339 |
^ self methodDictionary values select: |
|
2340 |
[:method | |
|
1281 | 2341 |
(method isJavaMethod |
2342 |
and:[method annotations notNil |
|
2343 |
and:[(method annotations runtimeVisible at:aJavaTypeName ifAbsent:nil) notNil]])]. |
|
752 | 2344 |
|
2345 |
"Created: / 02-03-2011 / 23:06:42 / Marcel Hlopko <hlopik@gmail.com>" |
|
1281 | 2346 |
"Modified: / 14-12-2011 / 22:35:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 2347 |
! |
2348 |
||
2349 |
supportsMethodCategories |
|
2350 |
^ self isJavaClass not |
|
2351 |
||
2352 |
"Created: / 30.7.1997 / 14:58:58 / cg" |
|
2353 |
"Modified: / 7.5.1998 / 12:25:54 / cg" |
|
2354 |
! |
|
2355 |
||
2356 |
typeName |
|
2357 |
^ 'L' , self fullName , ';'. |
|
2358 |
||
2359 |
" |
|
2360 |
(Java at:'java.util.Stack') typeName" |
|
2361 |
||
2362 |
"Modified: / 10-02-1998 / 17:13:26 / cg" |
|
2363 |
"Modified: / 02-03-2011 / 22:48:40 / Marcel Hlopko <hlopik@gmail.com>" |
|
2364 |
! ! |
|
2365 |
||
2366 |
!JavaClass methodsFor:'queries-protocol'! |
|
2367 |
||
821
560f60ad3a2a
fixed (hopefully:) bug in permissions (new resolving)
hlopkmar
parents:
820
diff
changeset
|
2368 |
equalsOrIsSubclassOf: aJavaClass |
560f60ad3a2a
fixed (hopefully:) bug in permissions (new resolving)
hlopkmar
parents:
820
diff
changeset
|
2369 |
self = aJavaClass ifTrue: [^true]. |
560f60ad3a2a
fixed (hopefully:) bug in permissions (new resolving)
hlopkmar
parents:
820
diff
changeset
|
2370 |
^ self isSubclassOf:aJavaClass. |
560f60ad3a2a
fixed (hopefully:) bug in permissions (new resolving)
hlopkmar
parents:
820
diff
changeset
|
2371 |
|
560f60ad3a2a
fixed (hopefully:) bug in permissions (new resolving)
hlopkmar
parents:
820
diff
changeset
|
2372 |
"Created: / 30-05-2011 / 23:07:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
560f60ad3a2a
fixed (hopefully:) bug in permissions (new resolving)
hlopkmar
parents:
820
diff
changeset
|
2373 |
! |
560f60ad3a2a
fixed (hopefully:) bug in permissions (new resolving)
hlopkmar
parents:
820
diff
changeset
|
2374 |
|
1033 | 2375 |
includesBehavior: aClass |
2376 |
^ (aClass isJavaClass not or: [ aClass isInterface not ]) |
|
2377 |
ifTrue: [ self name == aClass name or:[ super includesBehavior: aClass ]] |
|
2378 |
ifFalse: [ |
|
2379 |
self name == aClass name or: [ self allInterfaces includes: aClass ] |
|
2380 |
]. |
|
752 | 2381 |
|
2382 |
"Created: / 05-02-2011 / 23:44:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1033 | 2383 |
"Modified: / 11-02-2011 / 09:12:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
761 | 2384 |
! |
2385 |
||
1031 | 2386 |
isSubclassOf: aClass |
2387 |
||
2388 |
| cls | |
|
2389 |
aClass isNil ifTrue:[^false]. |
|
2390 |
cls := self. |
|
2391 |
[ cls notNil ] whileTrue:[ |
|
2392 |
"JV-2011-10-20: Q: is one subclass of another if its |
|
2393 |
are subclass but loaded using different classloader?" |
|
2394 |
cls == aClass ifTrue:[ |
|
2395 |
^true |
|
2396 |
]. |
|
2397 |
cls := cls superclass. |
|
2398 |
]. |
|
2399 |
^false |
|
2400 |
||
2401 |
"Created: / 20-10-2011 / 16:15:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
761 | 2402 |
! ! |
2403 |
||
2404 |
!JavaClass methodsFor:'reflection'! |
|
2405 |
||
1240 | 2406 |
findInstFieldByName: fieldName |
2407 |
"tries to find a field in current class (not superclasses)" |
|
2408 |
||
2409 |
| result | |
|
2410 |
result := self fields |
|
2411 |
detect: [:each | each name = fieldName ] |
|
2412 |
ifNone: [ nil ]. |
|
2413 |
^ result. |
|
1236 | 2414 |
|
1241 | 2415 |
"Created: / 07-12-2011 / 23:05:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1236 | 2416 |
! |
2417 |
||
1240 | 2418 |
findInterfaceFieldByName: fieldName |
1241 | 2419 |
| result seenIfaces ifaces | |
2420 |
ifaces := OrderedCollection withAll: self interfaces. |
|
2421 |
seenIfaces := Set new. |
|
2422 |
[ ifaces notEmpty ] whileTrue: [ |
|
2423 |
| iface | |
|
2424 |
iface := ifaces removeFirst. |
|
2425 |
result := iface staticFields |
|
2426 |
detect: [:each | each name = fieldName ] |
|
2427 |
ifNone: [ nil ]. |
|
2428 |
result notNil ifTrue: [ ^ result ]. |
|
2429 |
seenIfaces add: iface. |
|
2430 |
iface interfaces do: [ |
|
2431 |
:each | |
|
2432 |
(seenIfaces includes: each) not ifTrue: [ ifaces add: each ] |
|
2433 |
] |
|
2434 |
]. |
|
1239 | 2435 |
^ nil. |
1236 | 2436 |
|
1241 | 2437 |
"Created: / 07-12-2011 / 23:05:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1236 | 2438 |
! |
2439 |
||
1240 | 2440 |
findStaticFieldByName: fieldName |
2441 |
"tries to find a field in current class (not superclasses)" |
|
2442 |
||
2443 |
| result | |
|
2444 |
result := self staticFields |
|
2445 |
detect: [:each | each name = fieldName ] |
|
2446 |
ifNone: [ nil ]. |
|
2447 |
^ result. |
|
1236 | 2448 |
|
1241 | 2449 |
"Created: / 07-12-2011 / 23:05:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1236 | 2450 |
! |
2451 |
||
2452 |
lookupFieldByNameAndType: aJavaNameAndType |
|
1240 | 2453 |
| field cls | |
2454 |
cls := self. |
|
2455 |
[ cls ~~ JavaObject ] whileTrue: [ |
|
1241 | 2456 |
field := cls findInstFieldByName: aJavaNameAndType name. |
1240 | 2457 |
field notNil ifTrue: [ ^ field ]. |
1241 | 2458 |
field := cls findStaticFieldByName: aJavaNameAndType name. |
1240 | 2459 |
field notNil ifTrue: [ ^ field ]. |
1241 | 2460 |
field := cls findInterfaceFieldByName: aJavaNameAndType name. |
1240 | 2461 |
field notNil ifTrue: [ ^ field ]. |
2462 |
cls := cls superclass. |
|
2463 |
]. |
|
2464 |
self breakPoint: #mh. |
|
2465 |
^ nil. |
|
761 | 2466 |
|
2467 |
"Created: / 11-04-2011 / 21:27:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
912
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
905
diff
changeset
|
2468 |
"Modified: / 13-08-2011 / 00:46:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1241 | 2469 |
"Modified: / 07-12-2011 / 23:05:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
761 | 2470 |
! |
2471 |
||
2472 |
lookupMethodByNameAndType: aJavaNameAndType |
|
2473 |
^ self lookupMethodFor: aJavaNameAndType selector. |
|
2474 |
||
2475 |
"Created: / 11-04-2011 / 21:28:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
2476 |
! |
|
2477 |
||
2478 |
lookupStaticFieldByNameAndType: aJavaNameAndType |
|
1240 | 2479 |
| field cls | |
2480 |
cls := self. |
|
2481 |
[ cls ~= JavaObject ] whileTrue: [ |
|
1241 | 2482 |
field := cls findStaticFieldByName: aJavaNameAndType name. |
1240 | 2483 |
field notNil ifTrue: [ ^ field ]. |
1241 | 2484 |
field := cls findInterfaceFieldByName: aJavaNameAndType name. |
1240 | 2485 |
field notNil ifTrue: [ ^ field ]. |
2486 |
cls := cls superclass. |
|
2487 |
]. |
|
2488 |
self breakPoint: #mh. |
|
2489 |
^ nil. |
|
818 | 2490 |
|
2491 |
"Created: / 11-04-2011 / 21:27:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
927 | 2492 |
"Modified: / 26-08-2011 / 18:27:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1241 | 2493 |
"Modified: / 07-12-2011 / 23:06:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 2494 |
! ! |
2495 |
||
2496 |
!JavaClass methodsFor:'special'! |
|
2497 |
||
2498 |
asClassPointerRef |
|
2499 |
"/ self halt. |
|
2500 |
^ self |
|
2501 |
||
2502 |
"Created: / 10.11.1998 / 02:07:01 / cg" |
|
2503 |
"Modified: / 8.1.1999 / 14:11:26 / cg" |
|
2504 |
! |
|
2505 |
||
2506 |
deinit |
|
2507 |
||
1523
f5ffdad83ab9
Access to ACC_* and ACX_* constants unified. The only definition is in JavaConstants
vranyj1
parents:
1511
diff
changeset
|
2508 |
accessFlags := accessFlags bitClear: ACX_INITIALIZED. |
752 | 2509 |
|
2510 |
"Created: / 25-10-2010 / 12:28:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2511 |
! |
|
2512 |
||
2513 |
deref |
|
2514 |
^ self |
|
2515 |
||
2516 |
"Created: / 10.11.1998 / 02:08:06 / cg" |
|
2517 |
! |
|
2518 |
||
851 | 2519 |
javaArrayClass |
2520 |
"/ self halt. |
|
2521 |
"/ ^ Array |
|
2522 |
||
1511 | 2523 |
^ JavaArray javaArrayClassFor:self |
851 | 2524 |
|
2525 |
"Created: / 10-11-1998 / 02:07:32 / cg" |
|
2526 |
"Modified: / 08-01-1999 / 14:11:34 / cg" |
|
1511 | 2527 |
"Modified: / 05-07-2012 / 23:24:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
851 | 2528 |
! |
2529 |
||
752 | 2530 |
updateClassRefsFrom:oldClass to:newClass |
2531 |
self == oldClass ifTrue:[ |
|
2532 |
self makeObsolete. |
|
2533 |
^ self |
|
2534 |
]. |
|
2535 |
||
2536 |
constantPool updateClassRefsFrom:oldClass to:newClass. |
|
2537 |
interfaces notNil ifTrue:[ |
|
2538 |
interfaces := interfaces collect:[:anInterface | |
|
2539 |
anInterface == oldClass ifTrue:[ |
|
2540 |
newClass isNil ifTrue:[ |
|
2541 |
nil "/ replace by an unresolvedInterface |
|
2542 |
] ifFalse:[ |
|
2543 |
newClass |
|
2544 |
] |
|
2545 |
] ifFalse:[ |
|
2546 |
anInterface |
|
2547 |
] |
|
2548 |
] |
|
2549 |
] |
|
2550 |
||
2551 |
"Modified: / 4.2.1998 / 22:08:19 / cg" |
|
2552 |
! ! |
|
2553 |
||
2554 |
!JavaClass methodsFor:'support - refactorings'! |
|
2555 |
||
2556 |
directlyDefinesMethod: aSelector |
|
2557 |
||
2558 |
^self methodDictionary includes: aSelector. |
|
2559 |
||
2560 |
"Created: / 16-03-2011 / 14:21:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2561 |
! |
|
2562 |
||
2563 |
metaclass |
|
2564 |
||
2565 |
^self class |
|
2566 |
||
2567 |
"Created: / 16-03-2011 / 14:22:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2568 |
! ! |
|
2569 |
||
2570 |
!JavaClass methodsFor:'support - sUnit'! |
|
2571 |
||
2572 |
asTestCase |
|
761 | 2573 |
self isTestletLike |
763 | 2574 |
ifTrue: [^ TestletTestCaseProxy for: self ]. |
761 | 2575 |
^ JUnitTestCaseProxy for: self. |
752 | 2576 |
|
2577 |
"Created: / 04-03-2011 / 08:20:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
761 | 2578 |
"Modified: / 29-04-2011 / 17:52:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
763 | 2579 |
"Modified: / 07-05-2011 / 18:59:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
761 | 2580 |
! |
2581 |
||
2582 |
asTestlet |
|
2583 |
^ TestletTestCaseProxy for: self |
|
2584 |
||
2585 |
"Created: / 29-04-2011 / 16:53:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 2586 |
! |
2587 |
||
820
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
818
diff
changeset
|
2588 |
buildSuite |
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
818
diff
changeset
|
2589 |
self isTestletLike ifTrue: [ ^(TestletTestCaseProxy for: self) buildSuite ]. |
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
818
diff
changeset
|
2590 |
^ (JUnitTestCaseProxy for: self) buildSuite |
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
818
diff
changeset
|
2591 |
|
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
818
diff
changeset
|
2592 |
"Created: / 29-05-2011 / 22:45:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
818
diff
changeset
|
2593 |
! |
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
818
diff
changeset
|
2594 |
|
1041 | 2595 |
isJUnitTestCaseLike |
761 | 2596 |
| junit_framework_TestCase org_junit_Test | |
752 | 2597 |
|
2598 |
"try JUnit 4.x" |
|
1052 | 2599 |
org_junit_Test := JavaVM classForName: 'org.junit.Test'. |
1041 | 2600 |
(org_junit_Test notNil and: [ self containsMethodsAnnotatedWith: org_junit_Test typeName ]) ifTrue: [ |
2601 |
^ true |
|
2602 |
]. |
|
2603 |
||
2604 |
"Try jUnit 3.x" |
|
1052 | 2605 |
junit_framework_TestCase := JavaVM classForName: 'junit.framework.TestCase'. |
1041 | 2606 |
junit_framework_TestCase ifNotNil: [ |
2607 |
self == junit_framework_TestCase ifTrue: [ ^ false ]. |
|
2608 |
(self includesBehavior: junit_framework_TestCase) ifTrue: [ ^ true ] |
|
2609 |
]. |
|
2610 |
||
2611 |
^false |
|
2612 |
" |
|
2613 |
JAVA::java::lang::Object isTestCaseLike |
|
2614 |
JAVA::stx::libjava::tests::junit::JUnit3Tests isTestCaseLike |
|
2615 |
" |
|
2616 |
||
2617 |
"Created: / 23-10-2011 / 22:04:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2618 |
! |
|
2619 |
||
2620 |
isTestCaseLike |
|
2621 |
||
1204 | 2622 |
JavaVM booted ifFalse:[ ^ false ]. |
2623 |
||
1041 | 2624 |
^self isJUnitTestCaseLike or:[ self isTestletLike ] |
761 | 2625 |
|
752 | 2626 |
" |
2627 |
JAVA::java::lang::Object isTestCaseLike |
|
2628 |
JAVA::stx::libjava::tests::junit::JUnit3Tests isTestCaseLike" |
|
2629 |
||
2630 |
"Created: / 28-02-2011 / 21:31:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2631 |
"Modified: / 02-03-2011 / 23:08:02 / Marcel Hlopko <hlopik@gmail.com>" |
|
820
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
818
diff
changeset
|
2632 |
"Modified: / 29-05-2011 / 22:48:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1204 | 2633 |
"Modified: / 02-12-2011 / 23:09:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 2634 |
! |
2635 |
||
2636 |
isTestSelector: selector |
|
2637 |
||
2638 |
"Hack, you're right, blame on me" |
|
2639 |
||
2640 |
| junit_framework_TestCase m | |
|
899 | 2641 |
|
2642 |
((selector == #'test(Lgnu/testlet/TestHarness;)V') |
|
2643 |
and:[self ~~ (Java at:'gnu.testlet.Testlet')]) |
|
2644 |
ifTrue:[^true]. |
|
2645 |
||
2646 |
||
752 | 2647 |
junit_framework_TestCase := Java at:'junit.framework.TestCase'. |
2648 |
(junit_framework_TestCase notNil and: |
|
2649 |
[self includesBehavior:junit_framework_TestCase]) |
|
2650 |
ifTrue:[^selector startsWith: 'test']. |
|
2651 |
||
2652 |
m := self lookupSelector: selector. |
|
2653 |
"Sorry fo that, but I need this method to be fast" |
|
1090 | 2654 |
^m notNil and:[m annotations runtimeVisible includesKey: 'Lorg/junit/Test;']. |
752 | 2655 |
|
2656 |
"Modified: / 02-03-2011 / 23:08:02 / Marcel Hlopko <hlopik@gmail.com>" |
|
2657 |
"Created: / 04-03-2011 / 07:07:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
761 | 2658 |
! |
2659 |
||
2660 |
isTestletLike |
|
1039 | 2661 |
|
761 | 2662 |
| testlet | |
1263 | 2663 |
[ |
2664 |
testlet := JavaVM classForName: 'gnu.testlet.Testlet'. |
|
2665 |
] on: Error do:[ |
|
2666 |
^false. |
|
2667 |
]. |
|
761 | 2668 |
testlet ifNil:[^ false]. |
2669 |
self == testlet ifTrue: [ ^ false ]. |
|
2670 |
(self includesBehavior: testlet) ifTrue: [ ^ true ]. |
|
2671 |
^ false. |
|
2672 |
||
2673 |
"Modified: / 02-03-2011 / 23:08:02 / Marcel Hlopko <hlopik@gmail.com>" |
|
2674 |
"Created: / 29-04-2011 / 17:02:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1263 | 2675 |
"Modified: / 10-12-2011 / 20:15:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 2676 |
! ! |
2677 |
||
1098 | 2678 |
!JavaClass methodsFor:'unwind'! |
2679 |
||
2680 |
unwindHandlerInContext: aContext |
|
2681 |
"given a context which has been marked for unwind, |
|
2682 |
retrieve the handler block. This method is called when ST |
|
2683 |
exception raises and stack is unwinding. JavaClass instance |
|
2684 |
has an opportunity to clean up monitors" |
|
2685 |
||
2686 |
^ JavaVM unwindHandlerForJavaContext: aContext. |
|
2687 |
||
2688 |
"Created: / 08-11-2011 / 12:25:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
2689 |
! ! |
|
2690 |
||
752 | 2691 |
!JavaClass class methodsFor:'documentation'! |
2692 |
||
2693 |
version |
|
1876
482ad5ebe5da
Merged some fixes from jv's repo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1868
diff
changeset
|
2694 |
^ '$Header$' |
482ad5ebe5da
Merged some fixes from jv's repo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1868
diff
changeset
|
2695 |
! |
482ad5ebe5da
Merged some fixes from jv's repo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1868
diff
changeset
|
2696 |
|
482ad5ebe5da
Merged some fixes from jv's repo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1868
diff
changeset
|
2697 |
version_HG |
482ad5ebe5da
Merged some fixes from jv's repo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1868
diff
changeset
|
2698 |
|
482ad5ebe5da
Merged some fixes from jv's repo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1868
diff
changeset
|
2699 |
^ '$Changeset: <not expanded> $' |
752 | 2700 |
! |
2701 |
||
2702 |
version_SVN |
|
1876
482ad5ebe5da
Merged some fixes from jv's repo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1868
diff
changeset
|
2703 |
^ '§Id§' |
752 | 2704 |
! ! |
2705 |
||
926 | 2706 |
JavaClass initialize! |