Reachability of an object when a thread is running one of its methods

Andrew Haley aph at redhat.com
Thu Dec 6 02:34:35 PST 2012


On 12/06/2012 08:51 AM, Carlo de Wolf wrote:
> On 12/05/2012 01:44 PM, Andrew Haley wrote:
>> On 12/05/2012 12:02 PM, Carlo de Wolf wrote:
>>
>>> If it is by omission then either way it should explicitly stated it or
>>> have an additional warning. (At least that's my opinion. :-) )
>>
>> I certainly agree that this should be discussed.  Is the JLS the right
>> place for such things, though?
> 
> Since the JLS defines reachability and when the finalize is run, I
> would say yes.  Although the counter-argument would be that good
> programming practices should not be in spec.  Then again the
> finalize guardian pattern did make it in. :-)
>>
>> The key phrase is this:
>>
>> "A reachable object is any object that can be accessed in any
>> potential continuing computation from any live thread."
>>
>> So, the question is what constitutes an access.  Is the execution of a
>> method (of an object) after that method has been started an access to
>> that object?  I don't think it is.
> 
> Understood, but can we assert this?

I would say that from a strictly formal point of view there is no need
to do so in the JLS itself.  One could argue, based on the
conversation we've just had here, that there are already too many
examples and illustrations for such a formal document.  It's easy to
mistake what is simply an example of a rule for normative text.

However, if you can come up with some wordage it might be worth
submitting it, but a change to the JLS is going to have to jump
through a lot of hoops.

Andrew.


More information about the java-se-8-spec-comments mailing list