On Monday 15 December 2003 00:32, Daniel Dekany wrote: > Sunday, December 14, 2003, 2:28:14 PM, Stephen McConnell wrote: > > The soft reference is to the proxy so if the reference returns null we > > know that the proxy has been finalized which means that the > > corresponding component has been decommissioned. > > [snip] > > Why? Is it a soft reference cleared exactly when the referenced object > is finalized? Is this two act united to form an atomic operation? I > think they are not, so it is possible that the soft ref. cleared earlier > than finalization is called (but please point out if the JVM spec. > states something that prevents this to happen), so it is till not > ensured that finalize() will be called before the VM terminates.
Stephen, I agree with Daniel's sentiment, that it is dangerous to play around with these matters by "observation of behaviour". Everything needs to be strictly(!) checked with the JLS, otherwise we are in for extremely subtle and intermittent problems in the future. So looking at the state diagram, what is actually happening; Proxy goes; A - B - G - K - F Component goes; A - B - G then it may either go K or M - J or M - C - K and finally it may go F or D - N - F It can NEVER go (read the text) A - E Isn't that so? End of the Day, Stephen has a point, the component will never become unreachable before the finalize() method in the Proxy ! Why? Because, if the finalizer have proceeded to reachable/finalized before the Proxy does the G transition, the component will make a D transition, and when the Proxy is making the K transition , the component will N and the F. Q.E.D. Stephen is right!!! (Although using the wrong method to be right.) Cheers Niclas P.S. IMHE, this has been an area of plenty bugs in JVMs ;o) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
