Java and Cygwin: a difficult relation
Lapo Luchini
l.luchini@andxor.it
Thu Jan 26 14:40:00 GMT 2006
In the company I and Alessandro (in cc) work for there is a Java
application that uses gamin in order to receive file alteration events.
Main development platform is FreeBSD and, as gamin has no pure-Java
client available, we used a smallish JNI wrapper around the libgamin
client; it works flawlessly.
The problem is now, of course, to do it all on Windows.
gamin seems to compile and work, on cygwin, with a few patches; this
seemed to be the hard part, but in fact reveals to be the easier one.
The other problem is that from JNI you can't simply call a cygwin DLL,
as it wouldn't load his cygwin1.dll dependency correctly and surely dump.
I had a similar problem, a few months ago: calling a .NET managed code
from Java.
In that case, I reversed the approach: instead of importing an external
DLL using JNI, I instantiated the Java Virtual Machine itself inside the
.NET program, and "register" the local function as a static method of
the Java class.
This is the approach we pursued since this very morning, "almost"
succeeding in it.
"almost", unfortunately.
Calling the C function is not a problem, it even does a couple debug
printf with no problem.
But as soon as the C function calls a libgamin method (FAMOpen, the very
first one), it all fails miserably.
Anyone has an idea why? Is it a random bug or a fundamental problem of
the way cygwin1.dll works (like in the case of direct JNI)?
Follows the error itself:
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x610ad945, pid=1280,
tid=1084
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode, sharing)
# Problematic frame:
# C [cygwin1.dll+0xad945]
#
# An error report file with more information is saved as hs_err_pid1280.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
And an excerpt of hs_err_pid1280.log (the relevant stack frame):
Stack: [0x00030000,0x00230000), sp=0x0022e9ec, free space=2042k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,
C=native code)
C [cygwin1.dll+0xad945]
C [cygwin1.dll+0x8dd7f]
C [launcherS.exe+0x3048]
C [launcherS.exe+0x11e4]
j com.andxor.gamin.FAMConnection.FAMOpen()J+0
j com.andxor.gamin.FAMConnection.<init>()V+25
j FAMTest.main([Ljava/lang/String;)V+27
v ~StubRoutines::call_stub
V [jvm.dll+0x845a9]
V [jvm.dll+0xd9317]
V [jvm.dll+0x8447a]
V [jvm.dll+0x8b44a]
C [launcherS.exe+0x1b35]
C [launcherS.exe+0x1c72]
C [cygwin1.dll+0x5bc8]
C [cygwin1.dll+0x5eb3]
Thanks in advance for any suggestion,
Lapo and Alessandro
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3224 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20060126/c8a41287/attachment.bin>
More information about the Cygwin
mailing list