-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta
-
x86
-
windows_nt
Name: nl37777 Date: 02/23/2001
When starting up steve.wilson@eng's SheetMetal application, a large
number of java.text, sun.text, and sun.util.calendar classes are loaded
even though the application does not use any functionality that relies
on these classes. The reason is the following chain of initializations
starting with java.util.prefs.WindowsPreferences and going into the
java.util.logging framework:
- WindowsPreferences gets a Logger in a static field initializer,
- Logger creates a LogManager in a field initializer,
- LogManager reads a configuration file in a static initializer,
- the default configuration file specifies to create a FileHandler,
- FileHandler is a subclass of StreamHandler
- StreamHandler creates a SimpleFormatter in its constructor (the
formatter then gets replaced with an XMLFormatter created in the
FileHandler's constructor, so this is totally useless)
- SimpleFormatter creates a MessageFormat with a DateFormat in a field initializer.
So there's a lot of work going on in initializers that probably could be
delayed until we actually need to format something (nothing was logged
while launching this app). Note that focusing on the needless creation
of the SimpleFormatter in StreamHandler wouldn't help, because the
default configuration also creates a ConsoleHandler, which does use a SimpleFormatter.
The classes loaded are about 158K on disk. The classes are not loaded
when running the application on 1.3. They are:
java.text.DateFormat
java.text.DateFormat$Field
java.text.DateFormatSymbols
java.text.DecimalFormat
java.text.DecimalFormatSymbols
java.text.DigitList
java.text.FieldPosition
java.text.Format
java.text.Format$Field
java.text.MessageFormat
java.text.NumberFormat
java.text.SimpleDateFormat
sun.text.resources.DateFormatZoneData
sun.text.resources.DateFormatZoneData$1
sun.text.resources.DateFormatZoneData_en
sun.text.resources.LocaleData
sun.text.resources.LocaleData$1
sun.text.resources.LocaleElements
sun.text.resources.LocaleElements_en
sun.text.resources.LocaleElements_en_US
sun.util.calendar.ZoneInfo
sun.util.calendar.ZoneInfoFile
sun.util.calendar.ZoneInfoFile$1
The problem should be reproducible with any Swing application. Note that
some of the classes are also loaded unnecessarily due to
ComponentOrientation initialization; there's a separate bug 4418738 on
this issue.
======================================================================