JNI/Win32 Patch #1: Use "stdcall" Convention in the Interpreter to Invoke Native Methods

Ranjit Mathew rmathew@hotmail.com
Wed Dec 4 22:49:00 GMT 2002


Hi,

     The following patch proposes to make the interpreter
use the "stdcall" calling convention on Win32 while invoking
native (JNI) methods.

NOTE: This patch will not work until the following patch
to libffi to enable stdcall support is applied:

http://gcc.gnu.org/ml/java-patches/2002-q4/msg00204.html

This patch will not immediately make JNI work on Win32, but
it is an incremental step towards that direction. I will
follow up with more patches for JNI/Win32 as soon as possible.

ChangeLog:

2002-12-05  Ranjit Mathew <rmathew@hotmail.com>

     * resolve.cc (_Jv_JNIMethod::ncode): Use stdcall calling
     convention on Win32 to invoke native JNI methods.

------------------------------ 8< -----------------------------------
--- resolve.cc  Thu Dec  5 12:02:23 2002
+++ resolve.cc  Thu Dec  5 12:06:51 2002
@@ -945,5 +945,12 @@
           arg_count * sizeof (ffi_type *));

-  if (ffi_prep_cif (&jni_cif, FFI_DEFAULT_ABI,
+  // NOTE: This must agree with the JNICALL definition in jni.h
+  #ifdef WIN32
+  #define FFI_JNI_ABI FFI_STDCALL
+  #else
+  #define FFI_JNI_ABI FFI_DEFAULT_ABI
+  #endif
+
+  if (ffi_prep_cif (&jni_cif, FFI_JNI_ABI,
                     extra_args + arg_count, rtype,
                     jni_arg_types) != FFI_OK)
------------------------------ 8< -----------------------------------

Sincerely Yours,
Ranjit.

-- 
Ranjit Mathew          Email: rmathew AT hotmail DOT com

Bangalore, INDIA.      Web: http://ranjitmathew.tripod.com/





More information about the Java-patches mailing list