What methods should go into a java.util.Objects class in JDK 7?
Joseph D. Darcy
Joe.Darcy at Sun.COM
Fri Oct 2 17:49:36 UTC 2009
Jason Mehrens wrote:
> 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
> <http://java.sun.com/javase/6/docs/api/java/lang/String.html#valueOf%28java.lang.Object>)
Indeed it does! I'll replace the implementation with a call to
String.valueOf and update the javadoc accordingly. Thanks for spotting
this.
>
> What about a toIdentityString(Object) instead? Some of the nice
> properties of an identity string is that it is safe to
By toIdentityString, do you mean the String that would be returned by
toString if toString is not overridden?
-Joe
> 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.
> Check it out.
> <http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009>
More information about the core-libs-dev
mailing list