AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

JNI CallStaticVoidMethod fails after N calls

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> JVM, native methods and hardware
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue Nov 21, 2006 7:47 pm    Post subject: JNI CallStaticVoidMethod fails after N calls Reply with quote



I have written an application in Java and C on the Solaris 10 (x86)
platform using the JDK 1.5.0_09. The Java code calls a native method
"startButtonWatcher," which then forks, the parent process returning,
and the child process initiating an event loop that calls a static
method, "sendButtonEvent," on a Java class "ButtonWatcher."

The problem is that on the 65 invocation, the CallStaticVoidMethod will
hang. There is no core file or pid log file produced. (it will also
hang for CallVoidMethod as well if I remove the static declaration in
ButtonWatcher.)

I have also added a main() function to the C code so that it can be
compiled and run as an executable rather than a library file loaded
from Java, and the the same loop will be fine, the Call*Method call
being exected forever (or over a million times at least). The only
difference in the code is the JVM--in the sharable library, it uses the
JVM of the class that calls the native method, and the standalone has
to create its own. What could be the problem? Thanks!
Back to top
Chris Uppal
Guest





PostPosted: Wed Nov 22, 2006 8:59 pm    Post subject: Re: JNI CallStaticVoidMethod fails after N calls Reply with quote



santiago538 (AT) yahoo (DOT) com wrote:

Quote:
I have written an application in Java and C on the Solaris 10 (x86)
platform using the JDK 1.5.0_09. The Java code calls a native method
"startButtonWatcher," which then forks, the parent process returning,
and the child process initiating an event loop that calls a static
method, "sendButtonEvent," on a Java class "ButtonWatcher."

You mean you actually call fork() to create a new Unix process ??

If so then I'm extremely surprised that it works at all, let alone 64 times
before failing.

If not then I presume you mean that you start a new OS thread from your C code
(within the same Unix process). In that case I'd suspect that you are doing
something "wrong" with your threads (or, also a plausible hypothesis
unfortunately, that Sun are doing something wrong with /their/ threads), and
that the difference in behaviour has little to do with the way the JVM is
launched. Check that you are being completely clean about how you access
AWT/Swing objects, and that you don't do /anything/ to them except from code
runnng on the EDT. Of course, that's only a guess; another possibility is
that you have a good old-fashioned deadlock which is not related to AWT at
all...

-- chris
Back to top
Guest






PostPosted: Thu Nov 23, 2006 12:37 am    Post subject: Re: JNI CallStaticVoidMethod fails after N calls Reply with quote



Chris Uppal wrote:
Quote:
santiago538 (AT) yahoo (DOT) com wrote:

I have written an application in Java and C on the Solaris 10 (x86)
platform using the JDK 1.5.0_09. The Java code calls a native method
"startButtonWatcher," which then forks, the parent process returning,
and the child process initiating an event loop that calls a static
method, "sendButtonEvent," on a Java class "ButtonWatcher."

You mean you actually call fork() to create a new Unix process ??

If so then I'm extremely surprised that it works at all, let alone 64 times
before failing.

If not then I presume you mean that you start a new OS thread from your C code
(within the same Unix process). In that case I'd suspect that you are doing
something "wrong" with your threads (or, also a plausible hypothesis
unfortunately, that Sun are doing something wrong with /their/ threads), and
that the difference in behaviour has little to do with the way the JVM is
launched. Check that you are being completely clean about how you access
AWT/Swing objects, and that you don't do /anything/ to them except from code
runnng on the EDT. Of course, that's only a guess; another possibility is
that you have a good old-fashioned deadlock which is not related to AWT at
all...

-- chris

Hi Chris,

I'm new to Unix programming, and I did use a fork(). I changed my code
to use pthreads instead and it works fine now. Thanks
Back to top
Chris Uppal
Guest





PostPosted: Thu Nov 23, 2006 5:41 pm    Post subject: Re: JNI CallStaticVoidMethod fails after N calls Reply with quote

santiago538 (AT) yahoo (DOT) com wrote:

Quote:
I'm new to Unix programming,

No shame in that! ;-)


Quote:
and I did use a fork(). I changed my code
to use pthreads instead and it works fine now.

I'm glad it's working properly now. But I'm /really/ puzzled as to how the
earlier versions could have worked at all. There must be something Very
Strange Indeed about how Solaris handles dynamic link libraries.

Oh well...

-- chris
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> JVM, native methods and hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.