diff options
author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-10-21 13:25:46 +0000 |
---|---|---|
committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-10-21 13:25:46 +0000 |
commit | 1c662558a1113238a624245a45382d3df90ccf13 (patch) | |
tree | a5cbe718127a2194f3229dcdf80e56a45134e51a | |
parent | e0cf0d1d2825988033848a8cd74344de2027338b (diff) | |
download | gcc-1c662558a1113238a624245a45382d3df90ccf13.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72750 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | libjava/ChangeLog | 6 | ||||
-rw-r--r-- | libjava/java/util/logging/ErrorManager.java | 21 |
2 files changed, 24 insertions, 3 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 67dc182232e..aa3f79ec8c3 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -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 diff --git a/libjava/java/util/logging/ErrorManager.java b/libjava/java/util/logging/ErrorManager.java index cc36bf6301c..7381a5227ac 100644 --- a/libjava/java/util/logging/ErrorManager.java +++ b/libjava/java/util/logging/ErrorManager.java @@ -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 class ErrorManager 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 @@ public class ErrorManager 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; |