JNI in GCJ 3.2 for Win32
Ranjit Mathew
rmathew@hotmail.com
Thu Nov 7 22:30:00 GMT 2002
Tom Tromey wrote:
> Ranjit> 3. In particular, if we use the "stdcall" calling convention
> Ranjit> for calling native methods, then the JNI stub generation
> Ranjit> function build_jni_stub( ) in "gcc/java/expr.c" *must* be able
> Ranjit> to generate the correct call. Otherwise the Java program dies
> Ranjit> with an "UnsatisfiedLinkError" for the native method in
> Ranjit> question.
>> build_jni_stub isn't the real problem. This will always generate an
> ordinary call to _Jv_JNIMethod::call. This is the function that has a
> problem. It seems to me that we'll need to teach libffi about
> stdcall.
Well I taught libffi to stdcall and modified libjava/resolve.cc
thusly:
----------------------------- 8< ------------------------------
--- resolve.cc.orig Fri Nov 8 11:19:31 2002
+++ resolve.cc Fri Nov 8 11:21:49 2002
@@ -945,5 +945,12 @@
arg_count * sizeof (ffi_type *));
- if (ffi_prep_cif (&jni_cif, FFI_DEFAULT_ABI,
+/* NOTE: This *must* be consistent with the JNICALL define in jni.h */
+#ifdef WIN32
+#define JNI_ABI FFI_STDCALL
+#else
+#define JNI_ABI FFI_DEFAULT_ABI
+#endif
+
+ if (ffi_prep_cif (&jni_cif, JNI_ABI,
extra_args + arg_count, rtype,
jni_arg_types) != FFI_OK)
----------------------------- 8< ------------------------------
However, I'm stuck at this point: __stdcall functions get
translated to _fooBar@8 instead of _fooBar if the function
fooBar takes arguments that take 8 bytes, for example.
(See:
http://msdn.microsoft.com/library/en-us/vclang/html/_core___stdcall.asp
for details.)
The _Jv_LookupJNIMethod( ) function in jni.cc needs to be
able to construct this to look up the symbol properly, but
it does not know how many bytes would be taken up by the
arguments. :-(
Any ideas?
Sincerely Yours,
Ranjit.
--
Ranjit Mathew Email: rmathew AT hotmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.tripod.com/
More information about the Java
mailing list