News for hackers. Stuff that matters.
Re:My favorite bug: segfaults in Java by adevine on Sunday March 29, 2015 @01:00AM (#9283938)
Not necessarily. Those "getChild()" and "something()" methods could, for example, return new objects. this is only the root of child and something if this retains references (i.e. member variables) to these objects, which I'm guessing was not the case in this example.
Re:My favorite bug: segfaults in Java by kdrakon on Sunday March 29, 2015 @08:38AM (#9284618)
Ah, yes, didn't consider that. But what about 'this'?; for what reason could the JVM choose to GC an object that the calling thread is currently running in? The example method exists in an instance of 'this' and isn't static.
Re:My favorite bug: segfaults in Java by Dylan16807 on Sunday March 29, 2015 @02:19PM (#9285839)
Execution in Java does not have a concept of "current object". 'this' is passed in a magic way, but it does not exist in a magic way. It's like any other variable, and can be collected as soon as it's not needed. Which can be extremely early, because optimizations can reduce the 'need' for a variable to only its side effects.

Go pick apart aggressively optimized and inlined code and I bet you can find situations where 'this' never even exists.