JavaVM.st
changeset 432 68e66ba7fe49
parent 430 f8467bdf1db2
child 434 3896831a7356
equal deleted inserted replaced
431:fe362bcc1aeb 432:68e66ba7fe49
   386       (WGraphics::void close (sun.awt.windows.WPrintJob))
   386       (WGraphics::void close (sun.awt.windows.WPrintJob))
   387       (JPEGImageDecoder::void readImage (java.io.InputStream byte[]))
   387       (JPEGImageDecoder::void readImage (java.io.InputStream byte[]))
   388     o (OffScreenImageSource::void sendPixels ())
   388     o (OffScreenImageSource::void sendPixels ())
   389 "
   389 "
   390 
   390 
       
   391 !
       
   392 
       
   393 performance
       
   394     "
       
   395      JAVA::BenchMark new loopmark    
       
   396      JAVA::BenchMark new logicmark  
       
   397      JAVA::BenchMark new sievemark    
       
   398      JAVA::BenchMark new methodmark   
       
   399      JAVA::BenchMark new stringmark  
       
   400      JAVA::BenchMark new newstringmark                
       
   401      JAVA::BenchMark new neweststringmark               
       
   402 
       
   403 
       
   404     "
       
   405 "
       
   406                 loopmark  logicmark  sievemark  methodmark  stringmark  newstringmark  neweststringmark
       
   407    586 No JIT      84         87        90          40          22           17              10
       
   408    586 JIT                                         467          28           21              12
       
   409 "
       
   410 
   391 ! !
   411 ! !
   392 
   412 
   393 !JavaVM class methodsFor:'initialization'!
   413 !JavaVM class methodsFor:'initialization'!
   394 
   414 
   395 compile:source selector:smalltalkSelector asJavaMethod:javaSelector fakedSource:fakedSource in:aClass
   415 compile:source selector:smalltalkSelector asJavaMethod:javaSelector fakedSource:fakedSource in:aClass
   665 
   685 
   666 initializeSimulatedLibs
   686 initializeSimulatedLibs
   667     "return a collection of native libs which are considered 
   687     "return a collection of native libs which are considered 
   668      being already loaded. (used with jdk < 1.2)"
   688      being already loaded. (used with jdk < 1.2)"
   669 
   689 
   670     LibPath := #('__builtIn__' '/usr/local/lib' '/usr/local/lib/java'). 
   690     LibPath := #(
   671     SimulatedLibs := #('__builtIn__/net' 
   691                         '__builtIn__' 
   672                        '__builtIn__/awt' 
   692                         '/usr/local/lib' 
   673                        '__builtIn__/tawt' 
   693                         '/usr/local/lib/java'
   674                        '__builtIn__/winawt' 
   694                 ).
   675                        '__builtIn__/jpeg'
   695 
   676                        '__builtIn__/mmedia'
   696     SimulatedLibs := #(
   677                        '__builtIn__/zip'
   697                         '__builtIn__/net' 
   678                        '__builtIn__/math'
   698                         '__builtIn__/awt' 
       
   699                         '__builtIn__/tawt' 
       
   700                         '__builtIn__/winawt' 
       
   701                         '__builtIn__/jpeg'
       
   702                         '__builtIn__/mmedia'
       
   703                         '__builtIn__/zip'
       
   704                         '__builtIn__/math'
       
   705 
       
   706                            "/ KAVA ... 
       
   707                         '__builtIn__/agent'
   679                       ).
   708                       ).
   680 
   709 
   681     "Created: / 4.1.1998 / 19:05:03 / cg"
   710     "Created: / 4.1.1998 / 19:05:03 / cg"
   682     "Modified: / 27.1.1998 / 18:43:03 / cg"
   711     "Modified: / 11.11.1998 / 15:02:14 / cg"
   683 !
   712 !
   684 
   713 
   685 initializeSimulatedNativeLibs
   714 initializeSimulatedNativeLibs
   686     "return a collection of native libs which are considered 
   715     "return a collection of native libs which are considered 
   687      being already loaded (used with jdk >= 1.2)"
   716      being already loaded (used with jdk >= 1.2)"
  1742     bytes class isBytes ifFalse:[
  1771     bytes class isBytes ifFalse:[
  1743         self halt.
  1772         self halt.
  1744     ].
  1773     ].
  1745     stream == Stdin ifTrue:[
  1774     stream == Stdin ifTrue:[
  1746         self halt:'reading from standardInput ...'.
  1775         self halt:'reading from standardInput ...'.
  1747         ^ 0
  1776         ^ -1 "/ 0
  1748     ].
  1777     ].
  1749 
  1778 
  1750     FileIOTrace ifTrue:[
  1779     FileIOTrace ifTrue:[
  1751         ('JAVA: read ' , count printString , ' bytes from ' , stream pathName) infoPrintCR.
  1780         ('JAVA: read ' , count printString , ' bytes from ' , stream pathName) infoPrintCR.
  1752     ].
  1781     ].
  1776         ]
  1805         ]
  1777     ].
  1806     ].
  1778     ^ nRead
  1807     ^ nRead
  1779 
  1808 
  1780     "Created: / 4.2.1998 / 15:20:00 / cg"
  1809     "Created: / 4.2.1998 / 15:20:00 / cg"
  1781     "Modified: / 4.2.1998 / 19:42:40 / cg"
  1810     "Modified: / 10.11.1998 / 19:56:47 / cg"
  1782 !
  1811 !
  1783 
  1812 
  1784 anyStream_writeBytes:nativeContext
  1813 anyStream_writeBytes:nativeContext
  1785     |bytes offset count stream|
  1814     |bytes offset count stream|
  1786 
  1815 
  3203     "arc cosine"
  3232     "arc cosine"
  3204 
  3233 
  3205     |dVal|
  3234     |dVal|
  3206 
  3235 
  3207     dVal := nativeContext argAt:1.
  3236     dVal := nativeContext argAt:1.
  3208     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3237 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3209         dVal isReal ifTrue:[
  3238 "/        dVal isReal ifTrue:[
  3210             'JAVAVM [info]: missing double flag in Math>>acos' infoPrintCR.
  3239 "/            'JAVAVM [info]: missing double flag in Math>>acos' infoPrintCR.
  3211         ] ifFalse:[
  3240 "/        ] ifFalse:[
  3212             self halt:'expected double arg'
  3241 "/            self halt:'expected double arg'
  3213         ]
  3242 "/        ]
  3214     ].
  3243 "/    ].
  3215     ^ dVal arcCos
  3244     ^ dVal arcCos
  3216 
  3245 
  3217     "Created: / 7.5.1998 / 00:34:50 / cg"
  3246     "Created: / 7.5.1998 / 00:34:50 / cg"
  3218     "Modified: / 4.11.1998 / 22:08:36 / cg"
  3247     "Modified: / 11.11.1998 / 15:08:20 / cg"
  3219 !
  3248 !
  3220 
  3249 
  3221 _Math_asin:nativeContext
  3250 _Math_asin:nativeContext
  3222     "arc sine"
  3251     "arc sine"
  3223 
  3252 
  3224     |dVal|
  3253     |dVal|
  3225 
  3254 
  3226     dVal := nativeContext argAt:1.
  3255     dVal := nativeContext argAt:1.
  3227     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3256 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3228         dVal isReal ifTrue:[
  3257 "/        dVal isReal ifTrue:[
  3229             'JAVAVM [info]: missing double flag in Math>>asin' infoPrintCR.
  3258 "/            'JAVAVM [info]: missing double flag in Math>>asin' infoPrintCR.
  3230         ] ifFalse:[
  3259 "/        ] ifFalse:[
  3231             self halt:'expected double arg'
  3260 "/            self halt:'expected double arg'
  3232         ]
  3261 "/        ]
  3233     ].
  3262 "/    ].
  3234     ^ dVal arcSin
  3263     ^ dVal arcSin
  3235 
  3264 
  3236     "Created: / 7.5.1998 / 00:34:26 / cg"
  3265     "Created: / 7.5.1998 / 00:34:26 / cg"
  3237     "Modified: / 4.11.1998 / 22:08:48 / cg"
  3266     "Modified: / 11.11.1998 / 15:08:15 / cg"
  3238 !
  3267 !
  3239 
  3268 
  3240 _Math_atan:nativeContext
  3269 _Math_atan:nativeContext
  3241     "arc tangens"
  3270     "arc tangens"
  3242 
  3271 
  3243     |dVal|
  3272     |dVal|
  3244 
  3273 
  3245     dVal := nativeContext argAt:1.
  3274     dVal := nativeContext argAt:1.
  3246     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3275 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3247         dVal isReal ifTrue:[
  3276 "/        dVal isReal ifTrue:[
  3248             'JAVAVM [info]: missing double flag in Math>>atan' infoPrintCR.
  3277 "/            'JAVAVM [info]: missing double flag in Math>>atan' infoPrintCR.
  3249         ] ifFalse:[
  3278 "/        ] ifFalse:[
  3250             self halt:'expected double arg'
  3279 "/            self halt:'expected double arg'
  3251         ]
  3280 "/        ]
  3252     ].
  3281 "/    ].
  3253     ^ dVal arcTan
  3282     ^ dVal arcTan
  3254 
  3283 
  3255     "Created: / 6.2.1998 / 01:24:12 / cg"
  3284     "Created: / 6.2.1998 / 01:24:12 / cg"
  3256     "Modified: / 4.11.1998 / 22:08:44 / cg"
  3285     "Modified: / 11.11.1998 / 15:08:11 / cg"
  3257 !
  3286 !
  3258 
  3287 
  3259 _Math_ceil:nativeContext
  3288 _Math_ceil:nativeContext
  3260     "ceiling"
  3289     "ceiling"
  3261 
  3290 
  3262     |dVal|
  3291     |dVal|
  3263 
  3292 
  3264     dVal := nativeContext argAt:1.
  3293     dVal := nativeContext argAt:1.
  3265     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3294 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3266         dVal isReal ifTrue:[
  3295 "/        dVal isReal ifTrue:[
  3267             'JAVAVM [info]: missing double flag in Math>>ceil' infoPrintCR.
  3296 "/            'JAVAVM [info]: missing double flag in Math>>ceil' infoPrintCR.
  3268         ] ifFalse:[
  3297 "/        ] ifFalse:[
  3269             self halt:'expected double arg'
  3298 "/            self halt:'expected double arg'
  3270         ]
  3299 "/        ]
  3271     ].
  3300 "/    ].
  3272     ^ dVal ceilingAsFloat
  3301     ^ dVal ceilingAsFloat
  3273 
  3302 
  3274     "Created: / 7.1.1998 / 15:43:00 / cg"
  3303     "Created: / 7.1.1998 / 15:43:00 / cg"
  3275     "Modified: / 4.11.1998 / 22:08:59 / cg"
  3304     "Modified: / 11.11.1998 / 15:08:04 / cg"
  3276 !
  3305 !
  3277 
  3306 
  3278 _Math_cos:nativeContext
  3307 _Math_cos:nativeContext
  3279     "cosine"
  3308     "cosine"
  3280 
  3309 
  3281     |dVal|
  3310     |dVal|
  3282 
  3311 
  3283     dVal := nativeContext argAt:1.
  3312     dVal := nativeContext argAt:1.
  3284     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3313 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3285         dVal isReal ifTrue:[
  3314 "/        dVal isReal ifTrue:[
  3286             'JAVAVM [info]: missing double flag in Math>>cos' infoPrintCR.
  3315 "/            'JAVAVM [info]: missing double flag in Math>>cos' infoPrintCR.
  3287         ] ifFalse:[
  3316 "/        ] ifFalse:[
  3288             self halt:'expected double arg'
  3317 "/            self halt:'expected double arg'
  3289         ]
  3318 "/        ]
  3290     ].
  3319 "/    ].
  3291     ^ dVal cos
  3320     ^ dVal cos
  3292 
  3321 
  3293     "Created: / 7.1.1998 / 15:41:30 / cg"
  3322     "Created: / 7.1.1998 / 15:41:30 / cg"
  3294     "Modified: / 4.11.1998 / 22:08:32 / cg"
  3323     "Modified: / 11.11.1998 / 15:07:59 / cg"
  3295 !
  3324 !
  3296 
  3325 
  3297 _Math_exp:nativeContext
  3326 _Math_exp:nativeContext
  3298     "exponential"
  3327     "exponential"
  3299 
  3328 
  3300     |dVal|
  3329     |dVal|
  3301 
  3330 
  3302     dVal := nativeContext argAt:1.
  3331     dVal := nativeContext argAt:1.
  3303     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3332 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3304         dVal isReal ifTrue:[
  3333 "/        dVal isReal ifTrue:[
  3305             'JAVAVM [info]: missing double flag in Math>>exp' infoPrintCR.
  3334 "/            'JAVAVM [info]: missing double flag in Math>>exp' infoPrintCR.
  3306         ] ifFalse:[
  3335 "/        ] ifFalse:[
  3307             self halt:'expected double arg'
  3336 "/            self halt:'expected double arg'
  3308         ]
  3337 "/        ]
  3309     ].
  3338 "/    ].
  3310     ^ dVal exp
  3339     ^ dVal exp
  3311 
  3340 
  3312     "Created: / 7.5.1998 / 00:36:19 / cg"
  3341     "Created: / 7.5.1998 / 00:36:19 / cg"
  3313     "Modified: / 4.11.1998 / 22:09:05 / cg"
  3342     "Modified: / 11.11.1998 / 15:07:50 / cg"
  3314 !
  3343 !
  3315 
  3344 
  3316 _Math_floor:nativeContext
  3345 _Math_floor:nativeContext
  3317     "floor"
  3346     "floor"
  3318 
  3347 
  3319     |dVal|
  3348     |dVal|
  3320 
  3349 
  3321     dVal := nativeContext argAt:1.
  3350     dVal := nativeContext argAt:1.
  3322     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3351 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3323         dVal isReal ifTrue:[
  3352 "/        dVal isReal ifTrue:[
  3324             'JAVAVM [info]: missing double flag in Math>>floor' infoPrintCR.
  3353 "/            'JAVAVM [info]: missing double flag in Math>>floor' infoPrintCR.
  3325         ] ifFalse:[
  3354 "/        ] ifFalse:[
  3326             self halt:'expected double arg'
  3355 "/            self halt:'expected double arg'
  3327         ]
  3356 "/        ]
  3328     ].
  3357 "/    ].
  3329     ^ dVal floorAsFloat
  3358     ^ dVal floorAsFloat
  3330 
  3359 
  3331     "Created: / 7.1.1998 / 19:09:21 / cg"
  3360     "Created: / 7.1.1998 / 19:09:21 / cg"
  3332     "Modified: / 4.11.1998 / 22:09:10 / cg"
  3361     "Modified: / 11.11.1998 / 15:07:45 / cg"
  3333 !
  3362 !
  3334 
  3363 
  3335 _Math_log:nativeContext
  3364 _Math_log:nativeContext
  3336     "logarithm"
  3365     "logarithm"
  3337 
  3366 
  3338     |dVal|
  3367     |dVal|
  3339 
  3368 
  3340     dVal := nativeContext argAt:1.
  3369     dVal := nativeContext argAt:1.
  3341     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3370 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3342         dVal isReal ifTrue:[
  3371 "/        dVal isReal ifTrue:[
  3343             'JAVAVM [info]: missing double flag in Math>>log' infoPrintCR.
  3372 "/            'JAVAVM [info]: missing double flag in Math>>log' infoPrintCR.
  3344         ] ifFalse:[
  3373 "/        ] ifFalse:[
  3345             self halt:'expected double arg'
  3374 "/            self halt:'expected double arg'
  3346         ]
  3375 "/        ]
  3347     ].
  3376 "/    ].
  3348     ^ dVal log
  3377     ^ dVal log
  3349 
  3378 
  3350     "Created: / 7.1.1998 / 15:42:19 / cg"
  3379     "Created: / 7.1.1998 / 15:42:19 / cg"
  3351     "Modified: / 4.11.1998 / 22:09:16 / cg"
  3380     "Modified: / 11.11.1998 / 15:07:38 / cg"
  3352 !
  3381 !
  3353 
  3382 
  3354 _Math_pow:nativeContext
  3383 _Math_pow:nativeContext
  3355     "power"
  3384     "power"
  3356 
  3385 
  3357     |dVal1 dVal2|
  3386     |dVal1 dVal2|
  3358 
  3387 
  3359     dVal1 := nativeContext argAt:1.
  3388     dVal1 := nativeContext argAt:1.
  3360     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3389 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3361         dVal1 isReal ifTrue:[
  3390 "/        dVal1 isReal ifTrue:[
  3362             'JAVAVM [info]: missing double flag in Math>>pow' infoPrintCR.
  3391 "/            'JAVAVM [info]: missing double flag in Math>>pow' infoPrintCR.
  3363         ] ifFalse:[
  3392 "/        ] ifFalse:[
  3364             self halt:'expected double arg'
  3393 "/            self halt:'expected double arg'
  3365         ]
  3394 "/        ]
  3366     ].
  3395 "/    ].
  3367     dVal2 := nativeContext argAt:3.
  3396     dVal2 := nativeContext argAt:3.
  3368     (nativeContext argAt:4) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3397 "/    (nativeContext argAt:4) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3369         dVal2 isReal ifTrue:[
  3398 "/        dVal2 isReal ifTrue:[
  3370             'JAVAVM [info]: missing double flag in Math>>pow' infoPrintCR.
  3399 "/            'JAVAVM [info]: missing double flag in Math>>pow' infoPrintCR.
  3371         ] ifFalse:[
  3400 "/        ] ifFalse:[
  3372             self halt:'expected double arg'
  3401 "/            self halt:'expected double arg'
  3373         ]
  3402 "/        ]
  3374     ].
  3403 "/    ].
  3375     ^ dVal1 raisedTo:dVal2
  3404     ^ dVal1 raisedTo:dVal2
  3376 
  3405 
  3377     "Created: / 7.1.1998 / 15:44:13 / cg"
  3406     "Created: / 7.1.1998 / 15:44:13 / cg"
  3378     "Modified: / 4.11.1998 / 22:09:26 / cg"
  3407     "Modified: / 11.11.1998 / 15:07:33 / cg"
  3379 !
  3408 !
  3380 
  3409 
  3381 _Math_sin:nativeContext
  3410 _Math_sin:nativeContext
  3382     "sine"
  3411     "sine"
  3383 
  3412 
  3384     |dVal|
  3413     |dVal|
  3385 
  3414 
  3386     dVal := nativeContext argAt:1.
  3415     dVal := nativeContext argAt:1.
  3387     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3416 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3388         dVal isReal ifTrue:[
  3417 "/        dVal isReal ifTrue:[
  3389             'JAVAVM [info]: missing double flag in Math>>sin' infoPrintCR.
  3418 "/            'JAVAVM [info]: missing double flag in Math>>sin' infoPrintCR.
  3390         ] ifFalse:[
  3419 "/        ] ifFalse:[
  3391             self halt:'expected double arg'
  3420 "/            self halt:'expected double arg'
  3392         ]
  3421 "/        ]
  3393     ].
  3422 "/    ].
  3394     ^ dVal sin
  3423     ^ dVal sin
  3395 
  3424 
  3396     "Created: / 7.1.1998 / 15:41:40 / cg"
  3425     "Created: / 7.1.1998 / 15:41:40 / cg"
  3397     "Modified: / 4.11.1998 / 22:09:30 / cg"
  3426     "Modified: / 11.11.1998 / 15:07:09 / cg"
  3398 !
  3427 !
  3399 
  3428 
  3400 _Math_sqrt:nativeContext
  3429 _Math_sqrt:nativeContext
  3401     "square root"
  3430     "square root"
  3402 
  3431 
  3403     |dVal|
  3432     |dVal|
  3404 
  3433 
  3405     dVal := nativeContext argAt:1.
  3434     dVal := nativeContext argAt:1.
  3406     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3435 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3407         dVal isReal ifTrue:[
  3436 "/        dVal isReal ifTrue:[
  3408             'JAVAVM [info]: missing double flag in Math>>sqrt' infoPrintCR.
  3437 "/            'JAVAVM [info]: missing double flag in Math>>sqrt' infoPrintCR.
  3409         ] ifFalse:[
  3438 "/        ] ifFalse:[
  3410             self halt:'expected double arg'
  3439 "/            self halt:'expected double arg'
  3411         ]
  3440 "/        ]
       
  3441 "/    ].
       
  3442 
       
  3443     "/ how about domain errors ?
       
  3444     dVal < 0 ifTrue:[
       
  3445 "/        ^ 0.0
  3412     ].
  3446     ].
  3413     ^ dVal sqrt
  3447     ^ dVal sqrt
  3414 
  3448 
  3415     "Created: / 7.1.1998 / 15:42:40 / cg"
  3449     "Created: / 7.1.1998 / 15:42:40 / cg"
  3416     "Modified: / 4.11.1998 / 22:09:35 / cg"
  3450     "Modified: / 11.11.1998 / 15:06:55 / cg"
  3417 !
  3451 !
  3418 
  3452 
  3419 _Math_tan:nativeContext
  3453 _Math_tan:nativeContext
  3420     "tangent"
  3454     "tangent"
  3421 
  3455 
  3422     |dVal|
  3456     |dVal|
  3423 
  3457 
  3424     dVal := nativeContext argAt:1.
  3458     dVal := nativeContext argAt:1.
  3425     (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3459 "/    (nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[
  3426         dVal isReal ifTrue:[
  3460 "/        dVal isReal ifTrue:[
  3427             'JAVAVM [info]: missing double flag in Math>>tan' infoPrintCR.
  3461 "/            'JAVAVM [info]: missing double flag in Math>>tan' infoPrintCR.
  3428         ] ifFalse:[
  3462 "/        ] ifFalse:[
  3429             self halt:'expected double arg'
  3463 "/            self halt:'expected double arg'
  3430         ]
  3464 "/        ]
  3431     ].
  3465 "/    ].
  3432     ^ dVal tan
  3466     ^ dVal tan
  3433 
  3467 
  3434     "Created: / 7.5.1998 / 00:34:03 / cg"
  3468     "Created: / 7.5.1998 / 00:34:03 / cg"
  3435     "Modified: / 4.11.1998 / 22:09:40 / cg"
  3469     "Modified: / 11.11.1998 / 15:07:14 / cg"
  3436 !
  3470 !
  3437 
  3471 
  3438 _Method_getModifiers:nativeContext
  3472 _Method_getModifiers:nativeContext
  3439     |jMethod mthd retVal|
  3473     |jMethod mthd retVal|
  3440 
  3474 
  3641 _Runtime_execInternal:nativeContext
  3675 _Runtime_execInternal:nativeContext
  3642     "Run a unix-command; return a process object."
  3676     "Run a unix-command; return a process object."
  3643 
  3677 
  3644     |cmdAndArgArray envArray cmd jProcessClass jProcess|
  3678     |cmdAndArgArray envArray cmd jProcessClass jProcess|
  3645 
  3679 
  3646 "/    cmdAndArgArray := nativeContext argAt:1.
  3680     cmdAndArgArray := nativeContext argAt:1.
  3647 "/    envArray := nativeContext argAt:2.
  3681     envArray := nativeContext argAt:2.
       
  3682 
       
  3683     cmd := cmdAndArgArray at:1.
       
  3684 
       
  3685     OperatingSystem isUNIXlike ifTrue:[
       
  3686         jProcessClass := Java classForName:'java.lang.UNIXProcess'.
       
  3687     ] ifFalse:[
       
  3688         jProcessClass := Java classForName:'java.lang.Win32Process'.
       
  3689     ].
  3648 "/
  3690 "/
  3649 "/    cmd := cmdAndArgArray at:1.
  3691     jProcessClass notNil ifTrue:[
  3650 "/
  3692         jProcess := jProcessClass newCleared.
  3651 "/    jProcessClass := Java classForName:'java.lang.UNIXProcess'.
  3693         jProcess
  3652 "/    jProcessClass notNil ifTrue:[
  3694             perform:#'<init>([Ljava/lang/String;[Ljava/lang/String;)V'
  3653 "/        jProcess := jProcessClass newCleared.
  3695             with:cmdAndArgArray
  3654 "/        jProcess
  3696             with:envArray.
  3655 "/            perform:#'<init>([Ljava/lang/String;[Ljava/lang/String;)V'
  3697         ^ jProcess
  3656 "/            with:cmdAndArgArray
  3698     ].
  3657 "/            with:envArray.
  3699 self halt.
  3658 "/        ^ jProcess
       
  3659 "/    ].
       
  3660     self throwIOExceptionWithMessage:'Process execution disabled/unimplemented'.
  3700     self throwIOExceptionWithMessage:'Process execution disabled/unimplemented'.
  3661     ^ nil
  3701     ^ nil
  3662 
  3702 
  3663     "Created: / 15.1.1998 / 01:50:31 / cg"
  3703     "Created: / 15.1.1998 / 01:50:31 / cg"
  3664     "Modified: / 15.1.1998 / 02:09:29 / cg"
  3704     "Modified: / 10.11.1998 / 19:54:29 / cg"
  3665 !
  3705 !
  3666 
  3706 
  3667 _Runtime_exitInternal:nativeContext
  3707 _Runtime_exitInternal:nativeContext
  3668     "exit - here, we only shut down java threads"
  3708     "exit - here, we only shut down java threads"
  3669 
  3709 
  4072 _Thread_sleep:nativeContext
  4112 _Thread_sleep:nativeContext
  4073     "sleep for some milliseconds "
  4113     "sleep for some milliseconds "
  4074 
  4114 
  4075     |millis|
  4115     |millis|
  4076 
  4116 
  4077     (nativeContext argAt:2) ~~ DUMMY_LONG_HIGHWORD ifTrue:[
  4117     millis := nativeContext argAt:1.
  4078 	self internalError:'expected long arg'.
  4118     Delay waitForMilliseconds:(millis max:50)
  4079     ] ifFalse:[
       
  4080 	millis := nativeContext argAt:1.
       
  4081 	Delay waitForMilliseconds:(millis max:50)
       
  4082     ].
       
  4083 
  4119 
  4084     "Created: / 7.1.1998 / 15:34:23 / cg"
  4120     "Created: / 7.1.1998 / 15:34:23 / cg"
  4085     "Modified: / 13.1.1998 / 13:48:25 / cg"
  4121     "Modified: / 10.11.1998 / 22:28:04 / cg"
  4086 !
  4122 !
  4087 
  4123 
  4088 _Thread_start:nativeContext
  4124 _Thread_start:nativeContext
  4089     "start the thread"
  4125     "start the thread"
  4090 
  4126 
  4321     ].
  4357     ].
  4322     out nextPutLine:'----------------------------------------------------'
  4358     out nextPutLine:'----------------------------------------------------'
  4323 
  4359 
  4324     "Created: / 4.1.1998 / 14:27:40 / cg"
  4360     "Created: / 4.1.1998 / 14:27:40 / cg"
  4325     "Modified: / 10.11.1998 / 14:19:32 / cg"
  4361     "Modified: / 10.11.1998 / 14:19:32 / cg"
       
  4362 !
       
  4363 
       
  4364 _Win32Process_create:nativeContext
       
  4365     "really create a win32 process"
       
  4366 
       
  4367     |env cmd jProcess p inPipe outPipe errorPipe|
       
  4368 
       
  4369     jProcess := nativeContext receiver.
       
  4370     cmd := nativeContext argAt:1.
       
  4371     cmd := Java as_ST_String:cmd.
       
  4372 
       
  4373     env := nativeContext argAt:2.
       
  4374     env notNil ifTrue:[
       
  4375         self halt
       
  4376     ].
       
  4377 self halt.
       
  4378 
       
  4379     p := Win32Process new.
       
  4380     p command:cmd.
       
  4381     p environment:env.
       
  4382     p inStream:inPipe.
       
  4383     p outStream:outPipe.
       
  4384     p errorStream:errorPipe.
       
  4385     p directory:nil.
       
  4386     p startProcess.
       
  4387 self halt.
       
  4388 
       
  4389     jProcess instVarNamed:'handle' put:p.
       
  4390 
       
  4391     "Created: / 10.11.1998 / 19:50:31 / cg"
       
  4392     "Modified: / 10.11.1998 / 21:34:18 / cg"
  4326 ! !
  4393 ! !
  4327 
  4394 
  4328 !JavaVM class methodsFor:'native - java.lang - jdk1.2'!
  4395 !JavaVM class methodsFor:'native - java.lang - jdk1.2'!
  4329 
  4396 
  4330 _AccessController_beginPrivileged:nativeContext
  4397 _AccessController_beginPrivileged:nativeContext
  8297 ! !
  8364 ! !
  8298 
  8365 
  8299 !JavaVM class methodsFor:'documentation'!
  8366 !JavaVM class methodsFor:'documentation'!
  8300 
  8367 
  8301 version
  8368 version
  8302     ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaVM.st,v 1.58 1998/11/10 17:14:28 cg Exp $'
  8369     ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaVM.st,v 1.59 1998/11/11 14:49:16 cg Exp $'
  8303 ! !
  8370 ! !
  8304 JavaVM initialize!
  8371 JavaVM initialize!