[Top][All Lists]

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

Locale initialization error

From: Patrik Reali
Subject: Locale initialization error
Date: Thu, 21 Mar 2002 23:03:56 +0100


I've run into a initialization problem when class java/util/Locale is

The static initialization of Locale creates many instances of class Locale,
constructor calls String.toUpperCase.

  public Locale(String language, String country, String variant)
    this.language = convertLanguage(language); = country.toUpperCase();
    this.variant = variant.toUpperCase();
    this.hashcode = (this.language.hashCode() ^
                     ^ this.variant.hashCode());

String.toUpperCase uses the default locale

  public String toUpperCase()
    return toUpperCase(Locale.getDefault());

but since Locale is still initializing, it does not exist and causes a
NullPointerException in the String.toUpperCase(Locale loc)
fuction as soon as loc is used.

The problem happens also when String.toUpperCase and String.toLowerCase
are invoked directly, as they cause the initialization of Locale too.

I'm not sure if I should post this to the patch manager too, as I have no
available. My approach would be to avoid calling toLowerCase during the
of the class, by setting using a flag or by using a different (private)
constructor for
the initialization (but this would require a dummy parameter).

Here's the stack dump (as generated by the Aos system) of the problem.
I removed the local variable informations; the numbers after the procedure
are used to distinguish the overloaded methods.

_jlString.String.toLowerCase5543 pc=7751
_jlString.String.toLowerCase1539 pc=7717
_juLocale.Locale.convertLanguage pc=1588
_juLocale.Locale.init7470 pc=1321
_juLocale.Locale.init2121 pc=1260
_juLocale.clinit pc=54
JVMSystem.Execute pc=2352
JVM.CheckInitialized pc=7983
_jlString.String.toUpperCase1539 pc=8251
_StringTest.main pc=1053
JVMSystem.InvokeMethod pc=2388
JVMBase.Method.invokeNative pc=3744 pc=1256
JVMThreads.RunBody pc=781

Patrik Reali

reply via email to

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