This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Patch: java.util.logging.ErrorManager


Hi list,


I commited the attached patch to merge a bugfix made by Sascha Brawer in 
classpath.


Michael
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2285
diff -u -b -B -r1.2285 ChangeLog
--- ChangeLog	21 Oct 2003 13:21:31 -0000	1.2285
+++ ChangeLog	21 Oct 2003 13:25:16 -0000
@@ -1,3 +1,9 @@
+2003-10-21  Sascha Brawer  <brawer@dandelis.ch>
+
+	Fix for bug #2944, reported by David Holmes <dholmes@dltech.com.au>
+        * java/util/logging/ErrorManager.java (everUsed): Made volatile.
+        (error): Synchronize on instance, not class.
+
 2003-10-21  Mark Wielaard  <mark@klomp.org>
 
 	Reported by M.Negovanovic
Index: java/util/logging/ErrorManager.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/logging/ErrorManager.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 ErrorManager.java
--- java/util/logging/ErrorManager.java	21 Jun 2003 10:31:55 -0000	1.1
+++ java/util/logging/ErrorManager.java	21 Oct 2003 13:25:16 -0000
@@ -2,7 +2,7 @@
    -- a class for dealing with errors that a Handler encounters
       during logging
 
-Copyright (C) 2002 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -100,7 +100,16 @@
   public static final int FORMAT_FAILURE = 5;
 
 
-  private boolean everUsed = false;
+  /**
+   * Indicates whether the {@link #error} method of this ErrorManager
+   * has ever been used.
+   *
+   * Declared volatile in order to correctly support the
+   * double-checked locking idiom (once the revised Java Memory Model
+   * gets adopted); see Classpath bug #2944.
+   */
+  private volatile boolean everUsed = false;
+
 
   public ErrorManager()
   {
@@ -125,13 +134,19 @@
     if (everUsed)
       return;
 
-    synchronized (ErrorManager.class)
+    synchronized (this)
     {
       /* The double check is intentional. If the first check was
        * omitted, the monitor would have to be entered every time
        * error() method was called. If the second check was
        * omitted, the code below could be executed by multiple
        * threads simultaneously.
+       *
+       * This is the 'double-checked locking' idiom, which is broken
+       * with the current version of the Java memory model.  However,
+       * we assume that JVMs will have adopted a revised version of
+       * the Java Memory Model by the time GNU Classpath gains
+       * widespread acceptance. See Classpath bug #2944.
        */
       if (everUsed)
 	return;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]