JavaNativeMethod.st
author Stefan Vogel <sv@exept.de>
Tue, 08 Nov 2005 17:49:17 +0100
changeset 2121 7b06266d8249
parent 2107 f4509f6767fa
child 2151 c0b6570c6f9b
permissions -rw-r--r--
/tmp/cvsyRpZ5v

"{ Package: 'stx:libjava' }"

JavaMethodWithHandler variableSubclass:#JavaNativeMethod
	instanceVariableNames:'nativeImplementation'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Java-Classes'
!


!JavaNativeMethod class methodsFor:'initialization'!

initialize
    self flags:(self flags bitOr:Behavior flagJavaMethod).
! !

!JavaNativeMethod class methodsFor:'cleanup'!

flushAllCachedNativeMethods
    self allInstancesDo:[:aNativeMethod |
        aNativeMethod nativeImplementation:nil
    ].

    "
     self flushAllCachedNativeMethods
    "

    "Created: / 24.12.1999 / 03:10:38 / cg"
    "Modified: / 24.12.1999 / 03:10:51 / cg"
! !

!JavaNativeMethod methodsFor:'accessing'!

nativeImplementation
    "return the value of the instance variable 'nativeImplementation' (automatically generated)"

    ^ nativeImplementation

    "Created: / 25.9.1999 / 23:08:00 / cg"
!

nativeImplementation:something
    "set the value of the instance variable 'nativeImplementation' (automatically generated)"

    nativeImplementation := something.

    "Created: / 25.9.1999 / 23:08:00 / cg"
! !

!JavaNativeMethod methodsFor:'vm support'!

nativeMethodInvokation
    |nm sel mthd sender|

    (mthd := nativeImplementation) isNil ifTrue:[
        nm := selector copyWithoutLast:signature size.
        sel := ('_' , javaClass lastName , '_' , nm , ':') asSymbol.

        mthd := (JavaVM class compiledMethodAt:sel).
        (mthd isNil or:[mthd isLazyMethod]) ifTrue:[
            sender := thisContext sender.
            sender sender selector == #noByteCode ifTrue:[
                sender := sender sender.
                sender := sender sender.
                sender := sender sender.
            ].
            ^ JavaVM 
                perform:sel
                with:sender.
        ].
        nativeImplementation := mthd.
    ].

    ^ mthd
        valueWithReceiver:JavaVM
        arguments:(Array with:thisContext sender)
        selector:selector
        search:JavaVM class
        sender:nil

"
JavaNativeMethod flushAllCachedNativeMethods
"

    "Modified: / 27.1.2000 / 13:34:53 / cg"
! !

!JavaNativeMethod class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libjava/JavaNativeMethod.st,v 1.8 2002-11-22 20:09:13 cg Exp $'
! !

JavaNativeMethod initialize!