javaprims.h (_Jv_Utf8Const): Change struct to a class, with private fields and access methods.
* 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. From-SVN: r85854
This commit is contained in:
parent
fbac6f3cf5
commit
b4d49f49bf
14 changed files with 163 additions and 117 deletions
|
@ -83,7 +83,7 @@ java::lang::Class::forName (jstring className, jboolean initialize,
|
|||
throw new java::lang::ClassNotFoundException (className);
|
||||
|
||||
jclass klass = (buffer[0] == '['
|
||||
? _Jv_FindClassFromSignature (name->data, loader)
|
||||
? _Jv_FindClassFromSignature (name->chars(), loader)
|
||||
: _Jv_FindClass (name, loader));
|
||||
|
||||
if (klass == NULL)
|
||||
|
@ -443,10 +443,7 @@ java::lang::Class::getDeclaredMethods (void)
|
|||
jstring
|
||||
java::lang::Class::getName (void)
|
||||
{
|
||||
char buffer[name->length + 1];
|
||||
memcpy (buffer, name->data, name->length);
|
||||
buffer[name->length] = '\0';
|
||||
return _Jv_NewStringUTF (buffer);
|
||||
return name->toString();
|
||||
}
|
||||
|
||||
JArray<jclass> *
|
||||
|
@ -889,7 +886,7 @@ _Jv_FindMethodInCache (jclass klass,
|
|||
_Jv_Utf8Const *name,
|
||||
_Jv_Utf8Const *signature)
|
||||
{
|
||||
int index = name->hash & MCACHE_SIZE;
|
||||
int index = name->hash16() & MCACHE_SIZE;
|
||||
_Jv_mcache *mc = method_cache + index;
|
||||
_Jv_Method *m = mc->method;
|
||||
|
||||
|
@ -907,7 +904,7 @@ _Jv_AddMethodToCache (jclass klass,
|
|||
{
|
||||
_Jv_MonitorEnter (&java::lang::Class::class$);
|
||||
|
||||
int index = method->name->hash & MCACHE_SIZE;
|
||||
int index = method->name->hash16() & MCACHE_SIZE;
|
||||
|
||||
method_cache[index].method = method;
|
||||
method_cache[index].klass = klass;
|
||||
|
@ -1285,9 +1282,9 @@ _Jv_GenerateITable (jclass klass, _Jv_ifaces *ifaces, jshort *itable_offsets)
|
|||
jstring
|
||||
_Jv_GetMethodString (jclass klass, _Jv_Utf8Const *name)
|
||||
{
|
||||
jstring r = JvNewStringUTF (klass->name->data);
|
||||
jstring r = klass->name->toString();
|
||||
r = r->concat (JvNewStringUTF ("."));
|
||||
r = r->concat (JvNewStringUTF (name->data));
|
||||
r = r->concat (name->toString());
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -1329,7 +1326,7 @@ _Jv_AppendPartialITable (jclass klass, jclass iface, void **itable,
|
|||
break;
|
||||
}
|
||||
|
||||
if (meth && (meth->name->data[0] == '<'))
|
||||
if (meth && (meth->name->first() == '<'))
|
||||
{
|
||||
// leave a placeholder in the itable for hidden init methods.
|
||||
itable[pos] = NULL;
|
||||
|
@ -1588,8 +1585,7 @@ _Jv_LinkSymbolTable(jclass klass)
|
|||
|
||||
// We're looking for a field or a method, and we can tell
|
||||
// which is needed by looking at the signature.
|
||||
if (signature->length >= 2
|
||||
&& signature->data[0] == '(')
|
||||
if (signature->first() == '(' && signature->len() >= 2)
|
||||
{
|
||||
// If the target class does not have a vtable_method_count yet,
|
||||
// then we can't tell the offsets for its methods, so we must lay
|
||||
|
@ -1683,8 +1679,7 @@ _Jv_LinkSymbolTable(jclass klass)
|
|||
|
||||
// We're looking for a static field or a static method, and we
|
||||
// can tell which is needed by looking at the signature.
|
||||
if (signature->length >= 2
|
||||
&& signature->data[0] == '(')
|
||||
if (signature->first() == '(' && signature->len() >= 2)
|
||||
{
|
||||
// If the target class does not have a vtable_method_count yet,
|
||||
// then we can't tell the offsets for its methods, so we must lay
|
||||
|
@ -1695,7 +1690,7 @@ _Jv_LinkSymbolTable(jclass klass)
|
|||
_Jv_LayoutVTableMethods (target_class);
|
||||
}
|
||||
|
||||
meth = _Jv_LookupDeclaredMethod(target_class, sym.name,
|
||||
meth = _Jv_LookupDeclaredMethod(target_class, sym.name,
|
||||
sym.signature);
|
||||
|
||||
if (meth != NULL)
|
||||
|
@ -1829,8 +1824,7 @@ _Jv_LayoutVTableMethods (jclass klass)
|
|||
superclass = _Jv_FindClass (name, klass->loader);
|
||||
if (! superclass)
|
||||
{
|
||||
jstring str = _Jv_NewStringUTF (name->data);
|
||||
throw new java::lang::NoClassDefFoundError (str);
|
||||
throw new java::lang::NoClassDefFoundError (name->toString());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue