[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Locale initialization error
From: |
Patrik Reali |
Subject: |
Re: Locale initialization error |
Date: |
Fri, 22 Mar 2002 19:12:35 +0100 |
From: "Eric Blake" <address@hidden>
> Patrik Reali wrote:
> >
> > Hi!
> >
> > I've run into a initialization problem when class java/util/Locale is
> > initialized.
> >
> For these constructors, I tried adding a trusted constructor which does
> no capitalization. I'm still running into a problem here:
Your solution with the trusted constructor works properly.
On my side, I tried a different approach:
public Locale(String language, String country, String variant)
{
if (defaulLocale == null) {
this.language = language;
this.country = country;
this.variant = variant;
} else {
this.language = convertLanguage(language);
this.country = country.toUpperCase();
this.variant = variant.toUpperCase();
}
this.hashcode = (this.language.hashCode() ^ this.country.hashCode()
^ this.variant.hashCode());
}
This works too. It's up to you to choose the solution you prefer.
> According to the Javadoc of java.lang.System, there is no guarantee that
> the properties user.language, user.region, or user.variant exist. Does
> Sun document anywhere that these must exist, or who must supply them?
> Or is it just a VM integration requirement of Classpath? If the latter,
> then is it documented in the Classpath/VM integration guide?
>
VMSystem.java doesn't list those properties.
Locale should maybe install some defaults, if no properties are available:
private static Locale defaultLocale =
new Locale(System.getProperty("user.language", "en"),
System.getProperty("user.region", ""),
System.getProperty("user.variant", ""));
The language is important, because it is used for the convertions.
> I just committed my hack shown above - did it do the trick for you?
It works, thanks.
> (How I wish that I could compile a working VM on cygwin, to answer that
> question for myself).
>
I first had the opposite problem: testing the VM without API. And as I'm
still
testing my JVM, I never now if the error is on my side or not. I would offer
you my
Jaos, but it runs only on the Aos system: nice but different!
Ciao,
Patrik