summaryrefslogtreecommitdiff
path: root/libjava/jni.cc
diff options
context:
space:
mode:
authorbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-12 06:53:42 +0000
committerbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-12 06:53:42 +0000
commit307719b97143646f73530f046493efc507351385 (patch)
treeddcf219c5b73f37a94e4a0d174408bc041874a8e /libjava/jni.cc
parent3b50f8cbc13e04294332211ea899d8cf19a3e1be (diff)
downloadgcc-307719b97143646f73530f046493efc507351385.tar.gz
* gcj/javaprims.h (_Jv_Utf8Const): Change struct to a class,
with private fields and access methods. (_Jv_NewStringUTF, _Jv_hashUtf8String): New function declarations. * gcj/cni.h (_Jv_NewStringUTF): Move to javaprims.h. * prims.cc (_Jv_Utf8COnst::init): New method implementation. ( _Jv_makeUtf8Const): Rewrite using new constructors. (hashUtf8String): Rename to +_Jv_hashUtf8String and make non-static. * defineclass.cc: Use new _Utf8Const access/convenience methods. * jni.cc: Likewise. * resolve.cc: Likewise. * gcj/field.h: Likewise. * include/jvm.h: Likewise. * java/lang/Class.h: Likewise. * java/lang/natClass.cc: Likwise. * java/lang/natClassLoader.cc: Likewise * java/lang/reflect/natMethod.cc: Likewise * verify.cc: Likewise. (_Jv_BytecodeVerifier::make_utf8_const): Optimize. (~_Jv_BytecodeVerifier): Don't need second _Jv_Free call. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85854 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/jni.cc')
-rw-r--r--libjava/jni.cc28
1 files changed, 15 insertions, 13 deletions
diff --git a/libjava/jni.cc b/libjava/jni.cc
index f5a66d0948d..7943fe0ef04 100644
--- a/libjava/jni.cc
+++ b/libjava/jni.cc
@@ -1880,8 +1880,8 @@ _Jv_JNI_RegisterNatives (JNIEnv *env, jclass klass,
{
_Jv_Method *self = &imeths[i];
- if (! strcmp (self->name->data, methods[j].name)
- && ! strcmp (self->signature->data, methods[j].signature))
+ if (! strcmp (self->name->chars (), methods[j].name)
+ && ! strcmp (self->signature->chars (), methods[j].signature))
{
if (! (self->accflags
& java::lang::reflect::Modifier::NATIVE))
@@ -1985,8 +1985,8 @@ mangled_name (jclass klass, _Jv_Utf8Const *func_name,
// Don't use add_char because we need a literal `_'.
buf[here++] = '_';
- const unsigned char *fn = (const unsigned char *) func_name->data;
- const unsigned char *limit = fn + func_name->length;
+ const unsigned char *fn = (const unsigned char *) func_name->chars ();
+ const unsigned char *limit = fn + func_name->len ();
for (int i = 0; ; ++i)
{
int ch = UTF8_GET (fn, limit);
@@ -2000,8 +2000,8 @@ mangled_name (jclass klass, _Jv_Utf8Const *func_name,
buf[here++] = '_';
buf[here++] = '_';
- const unsigned char *sig = (const unsigned char *) signature->data;
- limit = sig + signature->length;
+ const unsigned char *sig = (const unsigned char *) signature->chars ();
+ limit = sig + signature->len ();
JvAssert (sig[0] == '(');
++sig;
while (1)
@@ -2058,7 +2058,9 @@ extern "C" void *
_Jv_LookupJNIMethod (jclass klass, _Jv_Utf8Const *name,
_Jv_Utf8Const *signature, MAYBE_UNUSED int args_size)
{
- char buf[10 + 6 * (name->length + signature->length) + 12];
+ int name_length = name->len();
+ int sig_length = signature->len();
+ char buf[10 + 6 * (name_length + sig_length) + 12];
int long_start;
void *function;
@@ -2066,13 +2068,13 @@ _Jv_LookupJNIMethod (jclass klass, _Jv_Utf8Const *name,
JvSynchronize sync (global_ref_table);
// First see if we have an override in the hash table.
- strncpy (buf, name->data, name->length);
- buf[name->length] = '\0';
- strncpy (buf + name->length + 1, signature->data, signature->length);
- buf[name->length + signature->length + 1] = '\0';
+ strncpy (buf, name->chars (), name_length);
+ buf[name_length] = '\0';
+ strncpy (buf + name_length + 1, signature->chars (), sig_length);
+ buf[name_length + sig_length + 1] = '\0';
JNINativeMethod meth;
meth.name = buf;
- meth.signature = buf + name->length + 1;
+ meth.signature = buf + name_length + 1;
function = nathash_find (&meth);
if (function != NULL)
return function;
@@ -2139,7 +2141,7 @@ _Jv_LookupJNIMethod (jclass klass, _Jv_Utf8Const *name,
if (function == NULL)
#endif /* WIN32 */
{
- jstring str = JvNewStringUTF (name->data);
+ jstring str = JvNewStringUTF (name->chars ());
throw new java::lang::UnsatisfiedLinkError (str);
}
}