diff options
| author | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-04-01 21:54:10 +0000 |
|---|---|---|
| committer | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-04-01 21:54:10 +0000 |
| commit | 037f67b82a447369b9deadca619e059b0a3f50d8 (patch) | |
| tree | 9e1f195b291f3f9fb34b91a18a554d4b28f775e8 /libjava | |
| parent | 1e3cd04be9565704fb97be6d733636dea0442cf2 (diff) | |
| download | ppe42-gcc-037f67b82a447369b9deadca619e059b0a3f50d8.tar.gz ppe42-gcc-037f67b82a447369b9deadca619e059b0a3f50d8.zip | |
* java/lang/natString.cc (intern): If string's data does not point to
this String, make a fresh String that does.
* java/lang/natString.cc (unintern): Replace by static function.
* java/lang/String.java (unintern): Remove method.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@40990 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
| -rw-r--r-- | libjava/ChangeLog | 8 | ||||
| -rw-r--r-- | libjava/java/lang/String.java | 1 | ||||
| -rw-r--r-- | libjava/java/lang/natString.cc | 15 |
3 files changed, 17 insertions, 7 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 3c1ef115410..177052ffc73 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,13 @@ 2001-04-01 Per Bothner <per@bothner.com> + * java/lang/natString.cc (intern): If string's data does not point to + this String, make a fresh String that does. + + * java/lang/natString.cc (unintern): Replace by static function. + * java/lang/String.java (unintern): Remove method. + +2001-04-01 Per Bothner <per@bothner.com> + * DeflaterOutputStream.java (deflate): Loop while def.needsInput. (finish): def.deflate needs to be called in a loop. (inbuf, inbufLength): New private fields. diff --git a/libjava/java/lang/String.java b/libjava/java/lang/String.java index 22e11530f77..b985cf4186c 100644 --- a/libjava/java/lang/String.java +++ b/libjava/java/lang/String.java @@ -347,6 +347,5 @@ public final class String implements Serializable, Comparable 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 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 c052905dc48..1c71bfd97e2 100644 --- a/libjava/java/lang/natString.cc +++ b/libjava/java/lang/natString.cc @@ -29,6 +29,7 @@ details. */ #include <gnu/gcj/convert/BytesToUnicode.h> #include <jvm.h> +static void unintern (jobject); static jstring* strhash = NULL; static int strhash_count = 0; /* Number of slots used in strhash. */ static int strhash_size = 0; /* Number of slots available in strhash. @@ -174,17 +175,19 @@ java::lang::String::intern() *ptr = (jstring) MASK_PTR (*ptr); return (jstring) UNMASK_PTR (*ptr); } - SET_STRING_IS_INTERNED(this); + jstring str = this->data == this ? this + : _Jv_NewString(JvGetStringChars(this), this->length()); + SET_STRING_IS_INTERNED(str); strhash_count++; - *ptr = this; + *ptr = str; // When string is GC'd, clear the slot in the hash table. - _Jv_RegisterFinalizer ((void *) this, unintern); - return this; + _Jv_RegisterFinalizer ((void *) str, unintern); + return str; } /* Called by String fake finalizer. */ -void -java::lang::String::unintern (jobject obj) +static void +unintern (jobject obj) { JvSynchronize sync (&StringClass); jstring str = reinterpret_cast<jstring> (obj); |

