local stack variables may be destroyed while the local inner class is still referenced!) How ? If class LivingstonCarpetBagger goes out of scope, becuse method return quickly, how did anyone get a reference to method-local-class MailCheck ?
And if scoping of methods (and possibly inner-classes) requires in i or j to be final, then they are no longer variables and this whole notion of compiler semantics enforcing copy semantics never set really well with me. If you want a copy, get a copy. If you want a final, say so. But where in Captain Bluetooth do they make an innner classes copy of somevar final if the original var was never final and the coder did not ask for no-write-back to be applied silently ? Original poster's code is out of scope right now because the script is loaded but I notice the sample code steps the access through not-just-one curly braces level and is probably at issue in the
// compile-error comment.
Poster's title is:
final variable i:final int i=0;on stack or heap?
, then in provided snippet i is mutable, j constant - none of which has anything to do with
Because of Method-Local Inner Classes is on heap,so it's wifecycle is longer than normal variable in the method. {btw Fudong, it's lifecycle and more correctly that
word should be scope or scoping - scope is how far away something matters.}
(think about it...otherwise they could run off in separate directions with all sorts of differing values!), That's why they are called variables. If you want every section of codebase working on the same whatchamacallit you are going to get some global warming from the Shining Sun of Code Correctness in Objected Orientation.
But the final insures that it's value won't differ from the method local classes version. Well ask the original poster if this is what is concern of merit in momentary post, the post title is not of concern or at issue in OO.
I'm sure Bert or one of the ranch-hands knows exactly how this gets implements Yeah, I know, they are always watching and if one of them hammers us let them hammer me becuase I can take the heat. It looks like we are going to need some to get across to original poster that stack or heap not at issue in sample code provided. Any addressable space is addressable space, iow all program variable ram can 'see' all program variable ram.
[ December 03, 2007: Message edited by: Nicholas Jordan ]