[Kde-java] Re: Qt/KDE java bindings: jni or cni

Tom Tromey tromey at redhat.com
Sat Mar 13 01:57:49 CET 2004


>>>>> "Richard" == Richard Dale <Richard_Dale at tipitina.demon.co.uk> writes:

Richard> Another approach is to use dynamic proxies to avoid the need
Richard> for a native java method for each method in the api being
Richard> wrapped. Then the only method that needs to be native is
Richard> Proxy.invoke() - you can funnel every api call into a single
Richard> method invocation.

Interesting.

Richard> A proxy is instantiated for each instance, and all calls are
Richard> forwarded to it.  A second proxy is used for static methods,
Richard> one instance per class.  Instead of 22000 JNI methods as at
Richard> present there should be more like 22 at most. So it will be
Richard> much easier to offer both JNI and CNI bindings because nearly
Richard> all the code will be exactly the same.

Individually wrapping 22000 calls would tend to bloat the executable,
wouldn't it?  :-)

Another idea would be something like what .NET does, or the old
JDirect.  That is, modify the VM to know more directly about native
calls.

You could do this in a way where you write the definitions once, but
then have different implementations for VMs you have modified (for
efficiency) and ones that you have not or cannot, letting you preserve
VM-independence.

Tom


More information about the Kde-java mailing list