classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] Small java.util.Locale change


From: Andrew John Hughes
Subject: Re: [cp-patches] Small java.util.Locale change
Date: Mon, 20 Dec 2004 08:28:27 +0000

On Mon, 2004-12-20 at 02:18, Robert Schuster wrote:
> Andrew John Hughes wrote:
> 
> >I spotted a small bug in java.util.Locale while trying to debug a problem in
> >java.util.Currency.  The equals method compares String objects using ==
> >rather than equals().
> >  
> >
> >     Locale l = (Locale) obj;
> > 
> >-    return (language == l.language
> >-            && country == l.country
> >-            && variant == l.variant);
> >+    return ((language.equals(l.language))
> >+            && country.equals(l.country)
> >+            && variant.equals(l.variant));
> >   }
> > 
> >  
> >
> I am not sure whether this is needed. I have seen that the constructors 
> of Locale call intern() on the String instances given as arguments. The 
> Strings which exists at
> compile time are automatically intern()'ed. That means referential 
> equality should work in equals().
> 
> The docs of String.intern() describe this magic a little better. :-)
> 
> cu
> Robert
> 
> 
> 
> _______________________________________________
> Classpath-patches mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/classpath-patches

I thought this may be the case after posting (given that this must have
been in there a long time).  If so, it should probably be noted as such
in the code, as this is not the usual behaviour.
-- 
Andrew :-)

Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html

No software patents in Europe -- http://nosoftwarepatents.com

"Value your freedom, or you will lose it, teaches history.
`Don't bother us with politics' respond those who don't want to learn."
-- Richard Stallman

"We've all been part of the biggest beta test the world has ever known --
Windows"
-- Victor Wheatman, Gartner

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]