Danny Smith <danny_r_smith_2001@...> writes:
> I plead complete ignorance with Java, so I'll ask naively:
> Can Java bind to C++ objects?
Yes; GCC supports two specifications for the bindings: JNI (Sun) and
CNI (Cygnus). Both require that threads created by C/C++ code be
'registered' with the Java side of the universe by invoking a special
function, and must be unregistered when they terminate.
Now technically you have to register all the threads you create, but
in practice, if you never try to execute any Java code in a thread,
and you don't need to lock on any Java mutexes, you can get away with
not registering. So code that does this would break, but I figure
these people are asking for trouble anyways, sort of like people who
omit '-mthreads' =)
> What is problem with having to link in the helper thread dll?
I'd rather not have it lying around if I don't have to. DLL versioning
issues, more stuff to distribute (multiple files == zip/cab archive),
DLL search path issues, etc. Nothing major, of course; it'd just be
nice not to have to have it around.
To my understanding, mingwthr.dll is necessary in C/C++ since the only
way to get notified when a thread dies is to have a DLL attached to
the process. In Java, the only way to create a thread is through
java.lang.Thread.run(), so we can just tack on the dtor code at the
end of that function (since it's part of libgcj, not the OS).
Curious: is there any way in win32 to 'trap' a system call -- ie
replace CreateThread with some other implementation that spawns the
thread and performs cleanup when it returns? This would let you use a
similar approach with C/C++ code.
> Many people would like that helper dll to be incorporated into a
> shared libgcc/libsupc++.a to enable throwing C++ exceptions across
> dll boundaries. Would that not be useful thing for Java as well.
Yes, although further off in the future -- we don't have Java DLL's
working yet =)
"If I put copyrighted material into the 'chewy nougat center', I can
claim the crunchy chocolate coating is an 'Access Control
Why Windows NT/2k/XP is unreliable: http://www.zappadoodle.com