When I create a native implementation peer in c++ how can I ensure that native part is also deleted when java object is deleted by JVM? I can add some methods that user of java object has to call explicitly, but I'd like to know if there some hook that I could put to handle when java object is deleted (garbage collected) so that I can automatically delete c++ implementation object as well.
I reviewed JACE it seems that it does that, but I'd need to run PeerEnhancer to patch generated class file (probably that's how it hooks delete? or maybe it needs this patching for something else). However, I'd like to avoid messing with compiled java files, I don't want anything fancy