aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorAnthony Green <green@redhat.com>2005-02-14 13:51:29 +0000
committerAnthony Green <green@redhat.com>2005-02-14 13:51:29 +0000
commit990d517a9eccbc90534544085bec1f69735b0d79 (patch)
tree66806536e5d93fc403025a09eace3e2bf5fc09ba /libjava
parent17418c339491de66282a1da36d3214edcf6d00b1 (diff)
2005-02-13 Anthony Green <green@redhat.com>
* jni.cc (nathash_add): Don't strdup the method signature. (_Jv_JNI_RegisterNatives): Convert the slashes to dots in the method signature. Update copyright. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@95010 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog7
-rw-r--r--libjava/jni.cc26
2 files changed, 28 insertions, 5 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 579ee763451..b47469f343d 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,10 @@
+2005-02-13 Anthony Green <green@redhat.com>
+
+ * jni.cc (nathash_add): Don't strdup the method signature.
+ (_Jv_JNI_RegisterNatives): Convert the slashes to dots in the
+ method signature.
+ Update copyright.
+
2005-02-12 Mark Wielaard <mark@klomp.org>
Fixes bug libgcj/8170
diff --git a/libjava/jni.cc b/libjava/jni.cc
index 6e0ab899c3e..b7c208417a5 100644
--- a/libjava/jni.cc
+++ b/libjava/jni.cc
@@ -1,6 +1,6 @@
// jni.cc - JNI implementation, including the jump table.
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation
This file is part of libgcj.
@@ -1880,7 +1880,8 @@ nathash_add (const JNINativeMethod *method)
return;
// FIXME
slot->name = strdup (method->name);
- slot->signature = strdup (method->signature);
+ // This was already strduped in _Jv_JNI_RegisterNatives.
+ slot->signature = method->signature;
slot->fnPtr = method->fnPtr;
}
@@ -1894,6 +1895,8 @@ _Jv_JNI_RegisterNatives (JNIEnv *env, jclass klass,
// the nathash table.
JvSynchronize sync (global_ref_table);
+ JNINativeMethod dottedMethod;
+
// Look at each descriptor given us, and find the corresponding
// method in the class.
for (int j = 0; j < nMethods; ++j)
@@ -1905,15 +1908,28 @@ _Jv_JNI_RegisterNatives (JNIEnv *env, jclass klass,
{
_Jv_Method *self = &imeths[i];
- if (! strcmp (self->name->chars (), methods[j].name)
- && ! strcmp (self->signature->chars (), methods[j].signature))
+ // Copy this JNINativeMethod and do a slash to dot
+ // conversion on the signature.
+ dottedMethod.name = methods[j].name;
+ dottedMethod.signature = strdup (methods[j].signature);
+ dottedMethod.fnPtr = methods[j].fnPtr;
+ char *c = dottedMethod.signature;
+ while (*c)
+ {
+ if (*c == '/')
+ *c = '.';
+ c++;
+ }
+
+ if (! strcmp (self->name->chars (), dottedMethod.name)
+ && ! strcmp (self->signature->chars (), dottedMethod.signature))
{
if (! (self->accflags & java::lang::reflect::Modifier::NATIVE))
break;
// Found a match that is native.
found = true;
- nathash_add (&methods[j]);
+ nathash_add (&dottedMethod);
break;
}