What methods should go into a java.util.Objects class in JDK 7?

Jason Mehrens jason_mehrens at hotmail.com
Fri Oct 2 14:41:28 UTC 2009


Joe,


 > * null safe toString(Object), returning "null" for a null argument

 

Doesn't String.valueOf do the same thing?
http://java.sun.com/javase/6/docs/api/java/lang/String.html#valueOf(java.lang.Object)

 

What about a toIdentityString(Object) instead?  Some of the nice properties of an identity string is that it is safe to call from multiple threads even on objects that are not thread safe (JComponent), won't deadlock if toString is synchronized (observed in logging), and won't build run away strings (nCopies(Integer.MAX_VALUE, "lookout").toString()).

 

Jason
 		 	   		  
_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits.
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20091002/0aee6a94/attachment.html>


More information about the core-libs-dev mailing list