Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How keep state in C++ across JNI calls?  RSS feed

 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some C++ code (it's actually all global functions right now) which is called from Java like:

myObj.callNativeMethod1( someObj );
myObj.callNativeMethodThatWorksWithSomeObj( );

How can I make sure that "someObj" which was passed into the first method is still valid/usable in method 2?

EDIT: The C++ app is multithreaded. So it also needs access to that object in other threads as well as across calls.
[ October 18, 2006: Message edited by: Dan Bizman ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Didn't I just answer this for you here?
 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LOL, yes. My brqain was overloaded!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!