* Native finalizer.
@ 2009-07-13 16:50 abhishek desai
2009-07-13 16:54 ` Ben Gardiner
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: abhishek desai @ 2009-07-13 16:50 UTC (permalink / raw)
To: java
Hi,
Is there any way to assign a native finalizer method per object to be
called when the object gets garbage collected ? I want to assign this
in the native layer.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Native finalizer.
2009-07-13 16:50 Native finalizer abhishek desai
@ 2009-07-13 16:54 ` Ben Gardiner
2009-07-13 17:37 ` Andrew Haley
2009-07-13 19:09 ` Chris Gray
2 siblings, 0 replies; 4+ messages in thread
From: Ben Gardiner @ 2009-07-13 16:54 UTC (permalink / raw)
To: abhishek desai; +Cc: java
abhishek desai wrote:
> Hi,
>
> Is there any way to assign a native finalizer method per object to be
> called when the object gets garbage collected ? I want to assign this
> in the native layer.
>
I think you'll find an example of this in natReference.cc:
void
::java::lang::ref::Reference::create (jobject ref)
{
// Nothing says you can't make a Reference with a NULL referent.
// But there's nothing to do in such a case.
referent = reinterpret_cast<gnu::gcj::RawData *> (ref);
copy = referent;
if (referent != NULL)
{
JvSynchronize sync (java::lang::ref::Reference::lock);
// `this' is a new Reference object. We register a new
// finalizer for pointed-to object and we arrange a special
// finalizer for ourselves as well.
_Jv_RegisterFinalizer (this, finalize_reference);
_Jv_RegisterFinalizer (referent, finalize_referred_to_object);
gnu::gcj::RawData **p = &referent;
_Jv_GCRegisterDisappearingLink ((jobject *) p);
add_to_hash (this);
}
}
,Ben
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Native finalizer.
2009-07-13 16:50 Native finalizer abhishek desai
2009-07-13 16:54 ` Ben Gardiner
@ 2009-07-13 17:37 ` Andrew Haley
2009-07-13 19:09 ` Chris Gray
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Haley @ 2009-07-13 17:37 UTC (permalink / raw)
To: abhishek desai; +Cc: java
abhishek desai wrote:
> Is there any way to assign a native finalizer method per object to be
> called when the object gets garbage collected ? I want to assign this
> in the native layer.
Sure, just define a method Myclass::finalize() in C++. I think that'll
work.
Andrew.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Native finalizer.
2009-07-13 16:50 Native finalizer abhishek desai
2009-07-13 16:54 ` Ben Gardiner
2009-07-13 17:37 ` Andrew Haley
@ 2009-07-13 19:09 ` Chris Gray
2 siblings, 0 replies; 4+ messages in thread
From: Chris Gray @ 2009-07-13 19:09 UTC (permalink / raw)
To: java
On Monday 13 July 2009 18:50:29 abhishek desai wrote:
> Hi,
>
> Is there any way to assign a native finalizer method per object to be
> called when the object gets garbage collected ? I want to assign this
> in the native layer.
protected native void finalize();
Or am I missing something?
--
Chris Gray /k/ Embedded Java Solutions BE0809.435.306
Embedded & Mobile Java, OSGi http://www.k-embedded-java.com/
chris.gray@kiffer.be +32 3 216 0369
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-07-13 19:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-13 16:50 Native finalizer abhishek desai
2009-07-13 16:54 ` Ben Gardiner
2009-07-13 17:37 ` Andrew Haley
2009-07-13 19:09 ` Chris Gray
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).