• Post Reply Bookmark Topic Watch Topic
  • New Topic

If JNIEnv is valid does a call do javaVM-GetEnv reload it?  RSS feed

 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know of a way to check that the JNIEnv passed to a function is valid. I want to be able to call javaVM->GetEnv(...) to make sure it's a valid env, but I don't want to be relaoding it if unecessary. So if it is valid, will the call to GetEnv just return or does it fully reload it?

Is there a way to check if it is valid?
 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone know if there's a way to check the JNIEnv is valid?
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know of a way to check if JNIEnv is valid (other than by using it and seeing if it crashes...). Regarding javaVM-GetEnv(), if the documentation does not answer your question, then you can only find out by experiment; that then ties you to a specific implementation of JNI/JVM.
 
Dennis Laffey
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually a call to GetEnv will tell you if the thread is attached or detached. The env pointer that you pass to the function should be the same as before, but the return value will indicate that it is already attached (JNI_OK). The call will return JNI_EDETACHED if the thread is not attached and thus needs to be (in order for env to be valid).
see below

[ July 30, 2008: Message edited by: Dennis Laffey ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!