On Tuesday 16 December 2003 02:54, Jonathan Hawkes wrote:
> ----- Original Message -----
> From: "Niclas Hedhman" <[EMAIL PROTECTED]>
> > I don't know what you expect me to experience, and since the JLS has no
> > answer to what will happen in detail, I had to "observe behaviour"
> > which is per-definition wrong.
> Please explain.
Looking at your code I was thinking, what is he trying to prove? So, I
compiled and ran it to see what actually happens, just in case you have a
point that I failed to understand. (The JLS basically says that the code is
undeterministic.)
> However, your test worked exactly as I predicted. You're right, it doesn't
> matter (and it's not defined) which comes first "I am a B" or "I am an A".
> What I was simply pointing out is that they will both happen. A.b is
> reachable from the A.finalize() method. B.a is reachable from the
> B.finalization() method. This MUST be this way.
I never said elsewise. Just before finalize() is called for A (let's say it is
called first), A goes from "finalizer-reachable/finalizable" to
"reachable/finalized" (!) state and B is then "reachable/finalizable" (!).
It is also allowed to assign the object back to a hard reference, in which
case it will stay in "reachable/finalized" state "forever", i.e. finalize()
will not be called again.
> Ok, forgive me; but I can't make heads or tails of what you are saying
> here.
<quote src="Jonathan Hawkes">
Before an object is discarded, any object that references that object will
have its finalize() method invoked.
</quote>
Can this mean anything else than
class A
{
protected void finalize()
{
System.out.println( "Jonathan's text says this method is called." );
}
public static void main( String[] args ) throws Exception
{
A a = new A();
B b = new B();
b = null;
synchronized( A.class )
{
System.gc();
wait();
}
}
}
public class B
{}
???
> There is no reason to be a prick. And since when are the API docs
> inadequate evidence?
Sorry - no intention, but I started with a fairly friendly pointer "I assume
it was an honest mistake", that the quoted text above was just typed
differently from what you meant. I still think it is so...
Niclas
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]