re GNATS libgcj/38 (Static initializer in DecimalFormat eventually depends on itself)

2000-02-25  Bryce McKinlay  <bryce@albatross.co.nz>

        * java/net/URLConnection.java (initializeDateFormats): New
        private method.
        (getHeaderFieldDate): Call initializeDateFormats if required.
        locale, dateFormat1, dateFormat2, dateFormat3: Don't initialize
        these.
        Fix for PR libgcj/38.

From-SVN: r32153
This commit is contained in:
Bryce McKinlay 2000-02-25 22:38:33 +00:00 committed by Bryce McKinlay
parent 0ad913af75
commit 4ae4a3c973
2 changed files with 30 additions and 7 deletions

View File

@ -1,3 +1,12 @@
2000-02-25 Bryce McKinlay <bryce@albatross.co.nz>
* java/net/URLConnection.java (initializeDateFormats): New
private method.
(getHeaderFieldDate): Call initializeDateFormats if required.
locale, dateFormat1, dateFormat2, dateFormat3: Don't initialize
these.
Fix for PR libgcj/38.
2000-02-24 Warren Levy <warrenl@cygnus.com>
* java/math/BigInteger.java(ival): Made private.

View File

@ -47,13 +47,9 @@ public abstract class URLConnection
private static ContentHandlerFactory factory;
private static ContentHandler contentHandler;
private static Hashtable handlers = new Hashtable();
private static Locale locale = new Locale("En", "Us", "Unix");
private static SimpleDateFormat dateFormat1 =
new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'", locale);
private static SimpleDateFormat dateFormat2 =
new SimpleDateFormat("EEEE, dd-MMM-yy hh:mm:ss 'GMT'", locale);
private static SimpleDateFormat dateFormat3 =
new SimpleDateFormat("EEE MMM d hh:mm:ss yyyy", locale);
private static Locale locale;
private static SimpleDateFormat dateFormat1, dateFormat2, dateFormat3;
private static boolean dateformats_initialized = false;
protected URLConnection(URL url)
{
@ -128,6 +124,8 @@ public abstract class URLConnection
public long getHeaderFieldDate(String name, long val)
{
if (! dateformats_initialized)
initializeDateFormats();
String str = getHeaderField(name);
if (str != null)
{
@ -437,4 +435,20 @@ public abstract class URLConnection
handlers.put(contentType, contentType);
return null;
}
// We don't put these in a static initializer, because it creates problems
// with initializer co-dependency: SimpleDateFormat's constructors eventually
// depend on URLConnection (via the java.text.*Symbols classes).
private synchronized void initializeDateFormats()
{
if (dateformats_initialized)
return;
locale = new Locale("En", "Us", "Unix");
dateFormat1 = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'",
locale);
dateFormat2 = new SimpleDateFormat("EEEE, dd-MMM-yy hh:mm:ss 'GMT'",
locale);
dateFormat3 = new SimpleDateFormat("EEE MMM d hh:mm:ss yyyy", locale);
dateformats_initialized = true;
}
}