[loc-en-dev] Locale.clone()

Naoto Sato naoto.sato at oracle.com
Tue Aug 31 07:37:04 PDT 2010


I agree that Locale object is immutable and implementing Cloneable 
sounds wrong in the first place, I am not so sure we could change it 
this time. Here is the javadoc description from Object.clone():

---
The general intent is that, for any object x, the expression:

      x.clone() != x

will be true, and that the expression:

      x.clone().getClass() == x.getClass()

will be true, but these are not absolute requirements.
---

Although it says that x.clone() != x is not an absolute requirement, 
Locale has been adopting this since beginning (I believe) so some apps 
could rely on it. So unless there is a strong reason to change this 
behavior, I would just leave as it is.

Naoto


On 8/30/10 7:28 PM, Yoshito Umaoka wrote:
> Hi all,
>
> An instance of Locale is immutable. Therefore, you do not need clone().
> For now, Locale.clone() calls super.clone() - but I do not think this is
> actually necessary.
> I think Locale.clone() should be just { return this; }.
>
> What do you think? Any objections?
>
> -Yoshito



More information about the locale-enhancement-dev mailing list