[OWASP-Washington] RE: Java Trivia

Jeff Williams jeff.williams at owasp.org
Tue Jan 24 15:54:08 EST 2006


No. Boolean operations in Java have short-circuit evaluation. See the JLS.

 

--Jeff

 

  _____  

From: Ed Tracy [mailto:edtracy at gmail.com] 
Sent: Tuesday, January 24, 2006 3:14 PM
To: owasp-washington at lists.sourceforge.net
Subject: Java Trivia

 

 

 

Can this cause a null pointer exception?

 

  if ( obj != null && obj.someMethod() != null ) { ...

 

I believe there is no guarantee that the compiler/optimizer will check that
obj is not null before trying to perform obj.someMethod(). If this is true,
then a null pointer may result. Thoughts?

 

-ed

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.owasp.org/pipermail/owasp-washington/attachments/20060124/5f4a0edd/attachment.html 


More information about the Owasp-washington mailing list