load native lib (SWT) with JNI on windows

Ranjit Mathew rmathew@hotmail.com
Sun Nov 24 12:43:00 GMT 2002


Tom Tromey wrote:
>>>>>>"Ranjit" == Ranjit Mathew <rmathew@vsnl.net> writes:
>>>>>>> Ranjit> To complement the situation perfectly, the MinGW ld omits the
> Ranjit> underscore in both the cases and adds the @nn for stdcall
> Ranjit> functions.
>> Is it really ld that does this? I thought the compiler made all the
> name mangling decisions.

Sorry, it is indeed the compiler that does it.
> Ranjit> Therefore, for a given JNI method fooBar( ) implemented in a DLL,
> Ranjit> the LookupJNIMethod( ) function must search for all of
> Ranjit> "fooBar@nn" (GCC), "_fooBar@nn" (MSVC) and "fooBar" (BCC).
> Ranjit> (Assuming these are the only compilers we care to support.)
>> Was this decision made consciously by gcc? Maybe it is just a bug and
> we should also prefix `_' to stdcall methods. Can you find out?

I have raised the issue in the mingw-dvlpr list.
> In any case it looks like we'll need more Windows-specific code in the
> JNI lookup.

Yes. This kind of jugglery should ideally be masked for the rest
of libgcj by libltdl. But then, FindSymbolInExecutable( ) would
need to be modified to also take the ABI being used and the
number of bytes used for passing the arguments.
BTW, as a quick hack I added something like:
 args_size += ( this_arg_size < 4) ? 4 : this_arg_size;
for each "this_arg_size" representing a JNI method parameter
in "gcc/java/expr.c" (ref. my earlier patch) - this says
that at least a word (4 bytes on x86-32) will be passed
onto the stack for each parameter.
This lets me build and successfully run the simple
HelloWorld program given in this IBM developerWorks
article:
http://www-106.ibm.com/developerworks/java/library/j-nativegui/?Open&t=grl,l=805,p=cgui
(I must tell him about the new state of affairs vis-a-vis GCJ on
 Windows. ;-))
I will try out the more complicated examples given in the
"SWT Examples" packages that come with the Eclipse SDK and
let you know.
Unfortunately, for some reason, the interpreter still fails
in executing the HelloSWT program. :-(
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

AltStyle によって変換されたページ (->オリジナル) /