While exposing functionalities from a C++ library to Java i recently faced a problem regarding C++ shared_ptr
pointers. The case is that the Object itself as well as the jlong
handle related to that Object lives whithin the Java portion but subsequent structures access that Object using smart pointers.
The problem what i got is: When a smart pointer gets destroyed or reset the underlying object gets deleted as well. However the Java reference points still to that Object.
I tried a lot but i did not manage to keep ownership on the Java-Side. Are there any best practices or solutions to that problem ?