natReference.cc (add_to_hash): Look at copy', not referent'.

* 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.

From-SVN: r59278
This commit is contained in:
Tom Tromey 2002-11-19 21:59:41 +00:00 committed by Tom Tromey
parent 93745862c4
commit da98b11a83
3 changed files with 17 additions and 12 deletions

View File

@ -1,3 +1,13 @@
2002-11-19 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.
2002-11-19 Ranjit Mathew <rmathew@hotmail.com>
* include/jni.h: Add missing JNICALL and JNIEXPORT attributes

View File

@ -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 abstract class Reference
*/
public boolean enqueue()
{
if (queue != null)
if (queue != null && nextOnQueue == null)
{
queue.enqueue(this);
queue = null;

View File

@ -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 @@ add_to_hash (java::lang::ref::Reference *the_reference)
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 @@ add_to_hash (java::lang::ref::Reference *the_reference)
link = &iter->next;
iter = *link;
}
n->next = (*link) ? (*link)->next : NULL;
n->next = *link;
*link = n;
}
@ -249,13 +250,7 @@ finalize_referred_to_object (jobject obj)
// 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 ();
}
object_list *next = head->next;
_Jv_Free (head);