Call C function when Java object terminates/finalizes

lille stor <[email protected]> Tue, 29 Dec 2020 10:40:29 +0100
Newsgroups gmane.comp.programming.swig
Message-ID <trinity-48d2c1bf-7827-46c5-b273-4ef463cda731-1609234829597@3c-app-mailcom-bs02>
Hi,

I have a Java object (created from a Java class generated by SWIG) that when it is about to terminate/finalize, I would like to call a C function to release some resources from the C side of my program. Basically, I would like to know how to extent the following Java method (generated by SWIG) with a call to a C function to release resources (in bold):

public synchronized void delete() {

if (swigCPtr != 0) {

if (swigCMemOwn) {

swigCMemOwn = false;

TestJNI.delete_Pool(swigCPtr);

TestJNI.releaseResource(swigCPtr);

}

swigCPtr = 0;

}

}

Could you please tell how can this be achieved?

Thank you,

L.

_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user