Re: Can an object be finalized while still weakly reachable?

2016-05-19 Thread Martin Buchholz
Martin's law of object pools in the presence of finalizers: Resurrecting a pooled object with a finalizer can be disastrous as it can be finalized later while in active use. Returning an object to the pool is a common thing to do in close() methods, and close() methods are reasonable thin

Re: Can an object be finalized while still weakly reachable?

2016-05-18 Thread Martin Buchholz
g discussion when we touched that part of the code last time. > just > for your reference:-) > > http://mail.openjdk.java.net/pipermail/core-libs-dev/2011-April/thread.html#6545 > > -sherman > >> My static reference was finalized because it used to be unreachable, >

Re: Can an object be finalized while still weakly reachable?

2016-05-17 Thread Xueming Shen
part of the code last time. just for your reference:-) http://mail.openjdk.java.net/pipermail/core-libs-dev/2011-April/thread.html#6545 -sherman My static reference was finalized because it used to be unreachable, not because it is now weakly reachable! On Mon, May 16, 2016 at 11:49 PM, Peter

Re: Can an object be finalized while still weakly reachable?

2016-05-17 Thread Martin Buchholz
Thanks, Peter. My current theory is indeed that I made a mistake, and have encountered my first real finalization resurrection bug. ZipFile + Inflater have 4 finalize methods and a WeakHashMap in play! My static reference was finalized because it used to be unreachable, not because it is now

Re: Can an object be finalized while still weakly reachable?

2016-05-16 Thread Peter Levart
Hi Martin, On 05/17/2016 05:19 AM, Martin Buchholz wrote: I have some evidence that an object's finalize method can run while a weak reference pointing to it is not yet cleared, which surprised me. E.g. class F { protected void finalize() { assert wref.get() != this; } } static WeakReference w

Can an object be finalized while still weakly reachable?

2016-05-16 Thread Martin Buchholz
I have some evidence that an object's finalize method can run while a weak reference pointing to it is not yet cleared, which surprised me. E.g. class F { protected void finalize() { assert wref.get() != this; } } static WeakReference wref = new WeakReference(new F()); If this is a bug, I can try

Re: @Finalized

2015-08-26 Thread Andrew Dinn
On 26/08/15 20:01, Aleksey Shipilev wrote: > On 08/26/2015 06:07 PM, Doug Lea wrote: >> On 08/26/2015 10:12 AM, Andrew Haley wrote: >>> On 08/26/2015 03:01 PM, Doug Lea wrote: This is an issue of large importance to a small audience, and is at the moment an orphan. To work out, I think it

Re: @Finalized

2015-08-26 Thread Aleksey Shipilev
On 08/26/2015 06:07 PM, Doug Lea wrote: > On 08/26/2015 10:12 AM, Andrew Haley wrote: >> On 08/26/2015 03:01 PM, Doug Lea wrote: >>> This is an issue of large importance to a small audience, >>> and is at the moment an orphan. To work out, I think it >>> requires at least some involvement from comp

Re: @Finalized

2015-08-26 Thread Doug Lea
On 08/26/2015 10:12 AM, Andrew Haley wrote: On 08/26/2015 03:01 PM, Doug Lea wrote: This is an issue of large importance to a small audience, and is at the moment an orphan. To work out, I think it requires at least some involvement from compiler and/or IDE developers. If you are or know of some

Re: @Finalized

2015-08-26 Thread Andrew Haley
On 08/26/2015 03:01 PM, Doug Lea wrote: > This is an issue of large importance to a small audience, > and is at the moment an orphan. To work out, I think it > requires at least some involvement from compiler and/or IDE > developers. If you are or know of someone who might be interested > in pursui

@Finalized

2015-08-26 Thread Doug Lea
. The second part seems to escape scope of these JEPs: Supporting an annotation (most likely named @Finalized) that would enable tools and/or compilers to convert methods of classes in danger of premature finalization from { body } to try { body } finally { Reference.reachabilityFence(this); } And