Commit da98b11a by Tom Tromey Committed by Tom Tromey

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
parent 93745862
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> 2002-11-19 Ranjit Mathew <rmathew@hotmail.com>
* include/jni.h: Add missing JNICALL and JNIEXPORT attributes * include/jni.h: Add missing JNICALL and JNIEXPORT attributes
......
/* java.lang.ref.Reference /* 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. This file is part of GNU Classpath.
...@@ -185,7 +185,7 @@ public abstract class Reference ...@@ -185,7 +185,7 @@ public abstract class Reference
*/ */
public boolean enqueue() public boolean enqueue()
{ {
if (queue != null) if (queue != null && nextOnQueue == null)
{ {
queue.enqueue(this); queue.enqueue(this);
queue = null; queue = null;
......
// natReference.cc - Native code for References // 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. This file is part of libgcj.
...@@ -165,7 +165,8 @@ add_to_hash (java::lang::ref::Reference *the_reference) ...@@ -165,7 +165,8 @@ add_to_hash (java::lang::ref::Reference *the_reference)
if (3 * hash_count >= 2 * hash_size) if (3 * hash_count >= 2 * hash_size)
rehash (); 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); object_list *item = find_slot (referent);
if (item->reference == NULL) if (item->reference == NULL)
{ {
...@@ -197,7 +198,7 @@ add_to_hash (java::lang::ref::Reference *the_reference) ...@@ -197,7 +198,7 @@ add_to_hash (java::lang::ref::Reference *the_reference)
link = &iter->next; link = &iter->next;
iter = *link; iter = *link;
} }
n->next = (*link) ? (*link)->next : NULL; n->next = *link;
*link = n; *link = n;
} }
...@@ -249,13 +250,7 @@ finalize_referred_to_object (jobject obj) ...@@ -249,13 +250,7 @@ finalize_referred_to_object (jobject obj)
// If the copy is already NULL then the user must have // If the copy is already NULL then the user must have
// called Reference.clear(). // called Reference.clear().
if (ref->copy != NULL) if (ref->copy != NULL)
{ ref->enqueue ();
if (w == PHANTOM)
ref->referent = ref->copy;
else
ref->copy = NULL;
ref->enqueue ();
}
object_list *next = head->next; object_list *next = head->next;
_Jv_Free (head); _Jv_Free (head);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment