classpath
[Top][All Lists]
Advanced

[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

Hi!

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

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

  public Locale(String language, String country, String variant)
  {
    this.language = convertLanguage(language);
    this.country = country.toUpperCase();
    this.variant = variant.toUpperCase();
    this.hashcode = (this.language.hashCode() ^ this.country.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
patch
available. My approach would be to avoid calling toLowerCase during the
initialization
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
JVM.MainThread.run pc=1256
JVMThreads.RunBody pc=781


--------
Patrik Reali
http://www.inf.ethz.ch/personal/reali
http://www.oberon.ethz.ch/jaos




reply via email to

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