This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: previous java.lang.ref.Reference patch not properly applied.
- From: David Daney <ddaney at avtrex dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Fri, 19 Sep 2003 13:37:04 -0700
- Subject: Patch: previous java.lang.ref.Reference patch not properly applied.
The patch I submitted as:
http://gcc.gnu.org/ml/java/2003-08/msg00272.html
Was misapplied when committed to cvs.
There were two problems.
The referent was not being cleared, which results in get() returning the
referent even after clear() is called.
My reading of section 17 of the JLS requires that clear be synchronized.
David Daney.
2003-09-19 David Daney <ddaney@avtrex.com>
* libjava/java/lang/ref/Reference.java (clear): Set referent
to null and synchronize.
Index: Reference.java
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/lang/ref/Reference.java,v
retrieving revision 1.6
diff -u -3 -p -r1.6 Reference.java
--- Reference.java 26 Aug 2003 16:31:12 -0000 1.6
+++ Reference.java 19 Sep 2003 20:21:54 -0000
@@ -176,7 +176,12 @@ public abstract class Reference
*/
public void clear()
{
- cleared = true;
+ // Must synchronize so changes are visible in finalizer thread.
+ synchronized(lock)
+ {
+ referent = null;
+ cleared = true;
+ }
}
/**