This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: JNI multiple String problem


On Thu, 13 Mar 2003, Nicholas Burton wrote:
> Yes I am lucky that you are working on JNI at the moment :^)
> Thanks very much for your prompt and very helpful reply.
You're quite welcome :)

> I tried the gcc -mrtd flag and it did cure the problem.
Good :)

> I am not sure if I am running in rxvt. Does that happen automatically
> when you execute cygwin.bat (ie bash --login -i) by double clicking the
> cygwin icon?
No. rxvt is one of the packages in the Cygwin net distribution, but if you 
want to use it, you'll have to install it (and edit the cygwin.bat a bit 
if you want it to launch rxvt for you :)

> 'java StringEx' works for me in the cygwin terminal and under cmd.exe
Good :)

> I tried the same program under linux and it ran OK without using the
> -mrtd flag,
> using gcc 3.2 20020903 (Red Hat Linux 8.0 3.2-7).
The -mrtd flag sets the calling convention to stdcall. In any case, you 
need to use the same calling convention as the Java VM uses (or rather: 
the one it expects you to use). It also has to find your functions in the 
DLL, so you need to use (roughly) the same naming convention. Using 
stdcall with gcc by adding the attribute does make the stack-manipulation 
OK, but mangles the name in a slightly different way than MSVC does (MSVC 
adds an underscore to the name, gcc doesn't). Using -mrtd changes the 
calling convention but not the name mangling, which allows the VM to both 
find the function (because there is no @... behind it and no underscore 
before it) and use it (because the return value is popped by the callee in 
stead of the caller).

> Thanks for the info about releasing memory, --- (very strange).
Actually, I should take that back - it does work. The memory is allocated 
and freed on/from the proper heap. (I just tried it out)

I had some trouble with that earlier under MSVC, though.. (I'll figure 
that out when I get to it).

ciao!

rlc



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]