Originally posted by Ilja Preuss:
I am not sure that this is true. At the byte code level, all local variables have method scope, so I think that it isn't guaranteed that a reference to an object from a local variable gets lost before the containing method is finished.
It isn't guaranteed, and in older JVMs it doesn't happen. The Sun 1.4 JVM can garbage collect a variable as soon as it goes out of scope, though, even before the method terminates and the stack frame gets cleaned up.
- Peter