aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog7
-rw-r--r--libjava/java/lang/String.java4
-rw-r--r--libjava/java/lang/natString.cc9
3 files changed, 15 insertions, 5 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index ebb56ed..19d074a 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,10 @@
+2000-04-12 Tom Tromey <tromey@cygnus.com>
+
+ * java/lang/natString.cc (unintern): Added `obj' argument.
+ (intern): Register finalizer for string.
+ * java/lang/String.java (unintern): Now static; added obj
+ argument.
+
2000-04-11 Tom Tromey <tromey@cygnus.com>
* java/util/Vector.java (VectorEnumeration): Now `final'.
diff --git a/libjava/java/lang/String.java b/libjava/java/lang/String.java
index 86388a6..272f3e2 100644
--- a/libjava/java/lang/String.java
+++ b/libjava/java/lang/String.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
This file is part of libgcj.
@@ -302,6 +302,6 @@ public final class String
private native void init (byte[] chars, int hibyte, int offset, int count);
private native void init (byte[] chars, int offset, int count, String enc)
throws UnsupportedEncodingException;
- private native void unintern ();
+ private static native void unintern (Object obj);
private static native void rehash ();
}
diff --git a/libjava/java/lang/natString.cc b/libjava/java/lang/natString.cc
index 3a39f23..175d8eb 100644
--- a/libjava/java/lang/natString.cc
+++ b/libjava/java/lang/natString.cc
@@ -1,6 +1,6 @@
// natString.cc - Implementation of java.lang.String native methods.
-/* Copyright (C) 1998, 1999 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
This file is part of libgcj.
@@ -153,15 +153,18 @@ java::lang::String::intern()
SET_STRING_IS_INTERNED(this);
strhash_count++;
*ptr = this;
+ // When string is GC'd, clear the slot in the hash table.
+ _Jv_RegisterFinalizer ((void *) this, unintern);
return this;
}
/* Called by String fake finalizer. */
void
-java::lang::String::unintern()
+java::lang::String::unintern (jobject obj)
{
JvSynchronize sync (&StringClass);
- jstring* ptr = _Jv_StringGetSlot(this);
+ jstring str = reinterpret_cast<jstring> (obj);
+ jstring* ptr = _Jv_StringGetSlot(str);
if (*ptr == NULL || *ptr == DELETED_STRING)
return;
*ptr = DELETED_STRING;