[concurrency-interest] Object finalization

Chris Vest mr.chrisvest at gmail.com
Mon May 14 02:14:58 EDT 2012


Thanks guys,

I did indeed only include the constructor to show that neither `a` nor `b`
would be null after construction.

On 14 May 2012 01:10, Vitaly Davidovich <vitalyd at gmail.com> wrote:

> Ok, thanks for the correction -- I must've remembered it being the same as
> CLR.  In the CLR, it doesn't guarantee that references to 'a' and 'b' would
> be null, but that they *may* be null due to undefined order of reclaimation
> -- no explicit clearing of them needs to happen.
>
> Cheers,
>
> Vitaly
>
>
>
> On Sun, May 13, 2012 at 6:28 PM, David Holmes <davidcholmes at aapt.net.au>wrote:
>
>> **
>> The objects referred to by 'a' and 'b' will remain finalizer-reachable
>> until after the finalizer runs and so can not be reclaimed. If they were to
>> be reclaimed it would require that all references to them in finalizable
>> objects be found and cleared, which is not practical.
>>
>> With regard to the OP, as long as the constructor completes normally, it
>> is guaranteed that neither 'a' nor 'b' will be null when the finalizer
>> runs.
>>
>> David
>>
>> -----Original Message-----
>> *From:* concurrency-interest-bounces at cs.oswego.edu [mailto:
>> concurrency-interest-bounces at cs.oswego.edu]*On Behalf Of *Vitaly
>> Davidovich
>> *Sent:* Monday, 14 May 2012 8:20 AM
>> *To:* Bob Lee
>> *Cc:* concurrency-interest at cs.oswego.edu
>> *Subject:* Re: [concurrency-interest] Object finalization
>>
>> perhaps I'm misremembering but there's no guarantee on the order in which
>> objects are reclaimed.  When SomeService finalizer runs and assuming a and
>> b were kept alive only by this instance of SomeService, I don't think
>> there's any guarantee that a and b have not been reclaimed at this point
>> already.  That's how the CLR finalization works, so perhaps I'm conflating
>> the two.
>>
>> Sent from my phone
>> On May 13, 2012 5:54 PM, "Bob Lee" <crazybob at crazybob.org> wrote:
>>
>>> On Sun, May 13, 2012 at 2:41 PM, Vitaly Davidovich <vitalyd at gmail.com>wrote:
>>>
>>>> I am unclear whether the original question is specifically about
>>>> reachability of a and b from the constructor or whether the constructor was
>>>> shown to us to indicate that a and b are never null after construction
>>>> (assuming asserts are enabled).  If it's the former, your answer is correct
>>>> (that's what I meant by saying not sure if your reply was answering the
>>>> question).  If it's the latter, then I'm pretty sure my response is correct
>>>>
>>> Again, according the JLS, you're incorrect. "a" and "b" will be non-null
>>> when SomeService.finalize() executes. Why would you think otherwise?
>>>
>>> Bob
>>> Square is hiring! <https://squareup.com/jobs>
>>>
>>>
>>>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120514/88c63c64/attachment.html>


More information about the Concurrency-interest mailing list