Bill,
>> To echo Joe, I think the finalizer guardian idiom, whatever its
>> other deficiencies, does not have the problem you suggest: it does
>> use the implicit reference to its enclosing instance.
>
>
> Yes, but the reference to the guardian is dead:
I don't buy this.
> At 8:55 AM -0800 4/5/03, Joshua Bloch wrote:
>
>> // Finalizer Guardian idiom
>> public class Foo {
>> // Sole purpose of this object is to finalize outer Foo object
>> private final Object finalizerGuardian = new Object() {
>> protected void finalize() throws Throwable {
>> // Finalize outer Foo object
>> ...
>> }
>> };
>> ... // Remainder omitted
>> }
>
>
> While the this$0 field of the FinalizerGuardian class will be read,
> the finalizerGuardian field of class Foo will never be read, the JVM
> should be free to run the finalizer immediately.
What about reflection? Why the hurry? This contradicts peoples
instincts, and will cause all manner of errors.
> Maybe this is too harsh. Maybe we need a rule that liveness
> optimizations can only apply to methods variables, and that any object
> reachable via a field of a reachable object is itself reachable.
Amen, brother.
Josh
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:43 EDT