This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: Reference fixes
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 19 Nov 2002 14:30:15 -0700
- Subject: Patch: FYI: Reference fixes
- Reply-to: tromey at redhat dot com
I'm checking this in.
This fixes a few bugs in the implementation of Reference.
Tom
Index: libjava/ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/lang/ref/natReference.cc (add_to_hash): Look at `copy', not
`referent'.
(finalize_referred_to_object): Don't modify `referent' or `copy'
fields.
(add_to_hash): Correctly set `n->next' when updating list.
* java/lang/ref/Reference.java (enqueue): Return false if already
enqueued.
Index: libjava/java/lang/ref/Reference.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/ref/Reference.java,v
retrieving revision 1.3
diff -u -r1.3 Reference.java
--- libjava/java/lang/ref/Reference.java 22 Jan 2002 22:40:18 -0000 1.3
+++ libjava/java/lang/ref/Reference.java 19 Nov 2002 21:56:53 -0000
@@ -1,5 +1,5 @@
/* java.lang.ref.Reference
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -185,7 +185,7 @@
*/
public boolean enqueue()
{
- if (queue != null)
+ if (queue != null && nextOnQueue == null)
{
queue.enqueue(this);
queue = null;
Index: libjava/java/lang/ref/natReference.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/ref/natReference.cc,v
retrieving revision 1.2
diff -u -r1.2 natReference.cc
--- libjava/java/lang/ref/natReference.cc 3 Oct 2001 16:47:02 -0000 1.2
+++ libjava/java/lang/ref/natReference.cc 19 Nov 2002 21:56:53 -0000
@@ -1,6 +1,6 @@
// natReference.cc - Native code for References
-/* Copyright (C) 2001 Free Software Foundation
+/* Copyright (C) 2001, 2002 Free Software Foundation
This file is part of libgcj.
@@ -165,7 +165,8 @@
if (3 * hash_count >= 2 * hash_size)
rehash ();
- jobject referent = the_reference->referent;
+ // Use `copy' here because the `referent' field has been cleared.
+ jobject referent = the_reference->copy;
object_list *item = find_slot (referent);
if (item->reference == NULL)
{
@@ -197,7 +198,7 @@
link = &iter->next;
iter = *link;
}
- n->next = (*link) ? (*link)->next : NULL;
+ n->next = *link;
*link = n;
}
@@ -249,13 +250,7 @@
// If the copy is already NULL then the user must have
// called Reference.clear().
if (ref->copy != NULL)
- {
- if (w == PHANTOM)
- ref->referent = ref->copy;
- else
- ref->copy = NULL;
- ref->enqueue ();
- }
+ ref->enqueue ();
object_list *next = head->next;
_Jv_Free (head);