Monday, December 15, 2003, 12:40:58 AM, Stephen McConnell wrote: > Daniel Dekany wrote: [snip] >>So what? If ref.get() == null, you only know that it is "at least queued >>for finalization". But, again, it does not means that the finalization >>will actually happen. Because, even if the object is queued for >>finalization, the VM can terminate before actually doing that. Or is it >>the VM required to finalize all queued objects before terminating? >>(Point that sentence in the specs.) >> > > So the question is - "is a JVM required to invoke finalize (where > finalize is overriden) on all objects objects on the stack for existing > (or the more specific case of invoking finalize on all objects in the > finalizable queue). My understanding is that "best efforts" can be > assumed relative to the JLS, but that implementions take this to extreme > imposed by the application. > > In particular we have the following (implementation) reference: > > System.runFinalization(): [snip]
"Deprecated. This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock." > However, we also have the following (implementation) statement in > > Runtime.addShutdownHook(): By which we don't win if the soft ref returns null... [snip] > My interpritation here is that the notion of "best effort" can be > assumed (but that its not gauranteed due to constrains implied by the > underlying operating system) - which means that you have a situation > where active release is desirable. [snip] My conclusion was/is that anything based on GC, and especially on "finally" is inherently chaotic... so I would not build on that. (Note: I didn't checked that JLS based proof regarding the proxy finalization and hard ref problem yet... but I will.) -- Best regards, Daniel Dekany --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
