This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: YA Socket timeout patch


Nic Ferrier wrote:

>>I don't agree. In this case there is no superclass that is going to mess 
>>with the value, it is safe and more efficient to not explicitly 
>>initialize it. I'd prefer if you removed them.
>>
>
>Safer to not initialize? How can it be safe to not initialize? I don't
>understand your issue here really, if it does cause increased size
>it's only tiny... Surely it's better to have explicit initialization
>and pay for the very small increase?
>

It is safe to not initialize because Java guarantees that all fields 
will always be initialized to 0 or null. However as Eric pointed out, 
its not safe for the *compiler* to optimize away such initializations 
because the possibility exists that a superclass initializer could 
somehow set the value before your initializer is run. In this case we 
know that can never happen!

regards

Bryce.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]