tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Caldarale, Charles R" <Chuck.Caldar...@unisys.com>
Subject RE: [OT] How do I ........?
Date Thu, 16 Nov 2006 00:22:31 GMT
> From: Martin Gainty [mailto:mgainty@hotmail.com] 
> Subject: Re: How do I ........?
> 
> This is one of those SS!=DS discussions which means that 
> variables placed/alloc'ed on the stack are NOT the same as 
> variables alloc'ed from heap
> so 
> when using a variable which is  alloced  on the stack AND 
> initialised to some known value (null) 
> feel free to test that pre-allocated stack variable as with 
> if(stack_variable == null)
> 
> If you dont know how this variable is alloc'ed or you know 
> that the variable is alloc'ed from heap use try / 
> catch(NullPointerException npe)
> 
> to do otherwise you're risking your webapp causing 'an 
> unhandled exception' when referencing a unalloc'ed variable..

A continuing display of your ignorance and irrelevance.

Sounds like you're confusing the issue with variable and field
initialization.  Variables in Java are always thread-local and within
the scope of a method; their allocation is up to the particular JVM
implementation and need not be materialized in memory at all.  They also
do not have any pre-defined initial values in lieu of an explicit
initialization expression.

Fields are associated with an object instance or class (if static); most
JVMs do allocate objects from a heap, but again there's no spec
requirement to do so.  Static fields are also usually allocated from a
heap, but not necessarily the same one as instances.  By definition,
fields have an initial value of zero, null, or false (depending on
type), if not specified by an initialization expression.

None of this has any bearing on whether or not it's valid to use a var
== null expression, which, of course, is always an acceptable thing to
do.  The fact that you can't seem to do it speaks only to your
programming skills, not anything in the Java language.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message