Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=ibR9wjYX5eit89HGzZv0YYEuXQ5ACaG7148lwrcGkXedLFLBRv9DXEpnLsN1kItNhhdN7SeKRZiYsBkhorSfTpXcZqLooXMusgD5wS/fbnx9HsY/9Y6VVX+wMuXX1y/C+yVhJw/IHEl6KDjBY1xjcRmE+V83vNl+5CCU6B8rvRE= ; Message-ID: <20041107045937.39823.qmail@web90003.mail.scd.yahoo.com> Date: Sat, 6 Nov 2004 20:59:37 -0800 (PST) From: Solly Ezekiel Subject: JNI call crashes the JVM To: cygwin AT cygwin DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii I've searched the archives for an answer to this question without success, so maybe this is a new problem after all... What I'm trying to do: Call gettimeofday() from Java via JNI. Why I'm doing this: System.currentTimeMillis() isn't accurate enough. It appears to have an accuracy of only about 10 ms under XP. I want 1 ms accuracy or better, and unfortunately, the various "real-time" extensions to Java (like javax.realtime) rely on System.currentTimeMills(). What I've tried: I wrote a native Java method, wrote a C++ body that calls gettimeofday(), compiled and linked as described at http://www.inonit.com/cygwin/jni/helloWorld/, loaded the DLL using System.loadLibrary(), and made the call from Java. I'm using Cygwin v1.5.11-1, g++ v3.3.3-3 and Mingw32 v20040810-1. What happened: The call to System.loadLibrary() never returns. What I tried next: Using the 'ar' command, I extracted only the .o files I needed from libc.a (I also tried doing the same with libcygwin.a) and linked them into the DLL. What happened: System.loadLibrary returned fine, but when I called gettimeofday() the JVM crashed with an access violation. What I tried next: I figured the DLL wasn't getting initialized when it was being loaded, so I added a call to cygwin_dll_init(). (I had to add a few more .o files for that to link.) What happened: Again, System.loadLibrary() returned fine, but when I called cygwin_dll_init() the JVM once again crashed with an access violation. So, that's where I am. I could delve into the innards of Cygwin to figure out what is (or isn't) happening, but I don't really have the time to do that. Has anyone tried to do what I'm doing, and do you have any wisdom you can share? I can't be the first person to have tried making calls to the Cygwin DLLs from JNI... can I? Thanks, Sol Ezekiel __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/