This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Using CNI to call compiled java from C++
- From: Bryce McKinlay <bryce at mckinlay dot net dot nz>
- To: stef dot millet at wanadoo dot fr
- Cc: java at gcc dot gnu dot org
- Date: Wed, 22 Oct 2003 22:19:18 +1300
- Subject: Re: Using CNI to call compiled java from C++
- References: <25695327.1066806277987.JavaMail.www@wwinf0403>
On Oct 22, 2003, at 8:04 PM, Stéphane MILLET wrote:
I agree with your answer but don't understand how the collector
decides that the object isn't reachable anymore. The Java object is
allocated and used in the C++ side of the program, so... Is it
declared unreachable as soon as you exit the current function like a
local variable ? or is there a function that makes an object
reclaimable ?
The object is unreachable once it can no longer be accessed from the
stack or static roots of your program. So, given that a reference to
this object is stored in a local (stack) variable, and assuming another
reference to it isn't stored somewhere, it becomes unreachable once you
exit the current function or explicitly set that variable to NULL or to
another object.
In my program, at the moment the finalizers of those types of objects
are never called.
Then that would be a bug - do you have a test case? But, note that
unlike C++ destructors, finalizers in Java are asynchronous and do not
run at predictable times. Finalizers won't be run until after a GC
cycle has completed, and the GC won't run unless you allocate enough
objects to trigger it.
Regards
Bryce.