aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>2004-08-11 23:53:42 -0700
committerPer Bothner <bothner@gcc.gnu.org>2004-08-11 23:53:42 -0700
commitb4d49f49bf21837bef59aa30788e2e9bf2ce2e3b (patch)
treeddcf219c5b73f37a94e4a0d174408bc041874a8e /libjava/java
parentfbac6f3cf5a007c9888d1fecdd647338f9eb623f (diff)
downloadgcc-b4d49f49bf21837bef59aa30788e2e9bf2ce2e3b.zip
gcc-b4d49f49bf21837bef59aa30788e2e9bf2ce2e3b.tar.gz
gcc-b4d49f49bf21837bef59aa30788e2e9bf2ce2e3b.tar.bz2
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
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/lang/Class.h2
-rw-r--r--libjava/java/lang/natClass.cc28
-rw-r--r--libjava/java/lang/natClassLoader.cc22
-rw-r--r--libjava/java/lang/reflect/natMethod.cc4
4 files changed, 25 insertions, 31 deletions
diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h
index 8d2b4a0..f6c6eec 100644
--- a/libjava/java/lang/Class.h
+++ b/libjava/java/lang/Class.h
@@ -212,7 +212,7 @@ public:
inline jboolean isArray (void)
{
- return name->data[0] == '[';
+ return name->first() == '[';
}
inline jclass getComponentType (void)
diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc
index 1b1a32d..f68f2a9 100644
--- a/libjava/java/lang/natClass.cc
+++ b/libjava/java/lang/natClass.cc
@@ -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
diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc
index b38c2db..1ff47b4 100644
--- a/libjava/java/lang/natClassLoader.cc
+++ b/libjava/java/lang/natClassLoader.cc
@@ -52,7 +52,7 @@ _Jv_WaitForState (jclass klass, int state)
{
klass->state = JV_STATE_LOADED;
if (gcj::verbose_class_flag)
- fprintf (stderr, "[Loaded (pre-compiled) %s]\n", (const char*)(klass->name->data));
+ fprintf (stderr, "[Loaded (pre-compiled) %s]\n", klass->name->chars());
}
if (state == JV_STATE_LINKED)
{
@@ -110,15 +110,15 @@ _Jv_PrepareCompiledClass (jclass klass)
_Jv_Utf8Const *name = pool->data[index].utf8;
jclass found;
- if (name->data[0] == '[')
- found = _Jv_FindClassFromSignature (&name->data[0],
+ if (name->first() == '[')
+ found = _Jv_FindClassFromSignature (name->chars(),
klass->loader);
else
found = _Jv_FindClass (name, klass->loader);
if (! found)
{
- jstring str = _Jv_NewStringUTF (name->data);
+ jstring str = name->toString();
throw new java::lang::NoClassDefFoundError (str);
}
@@ -182,7 +182,7 @@ _Jv_PrepareCompiledClass (jclass klass)
if (state == JV_STATE_COMPILED && gcj::verbose_class_flag)
fprintf (stderr, "[Loaded (pre-compiled) %s]\n",
- (const char*)(klass->name->data));
+ klass->name->chars());
klass->notifyAll ();
@@ -207,7 +207,7 @@ _Jv_PrepareCompiledClass (jclass klass)
#define HASH_LEN 1013
// Hash function for Utf8Consts.
-#define HASH_UTF(Utf) (((Utf)->hash) % HASH_LEN)
+#define HASH_UTF(Utf) ((Utf)->hash16() % HASH_LEN)
struct _Jv_LoaderInfo
{
@@ -348,7 +348,7 @@ _Jv_RegisterClassHookDefault (jclass klass)
// We size-limit MESSAGE so that you can't trash the stack.
char message[200];
strcpy (message, TEXT);
- strncpy (message + sizeof (TEXT) - 1, klass->name->data,
+ strncpy (message + sizeof (TEXT) - 1, klass->name->chars(),
sizeof (message) - sizeof (TEXT));
message[sizeof (message) - 1] = '\0';
if (! gcj::runtimeInitialized)
@@ -390,7 +390,7 @@ _Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
if (! klass)
{
- jstring sname = _Jv_NewStringUTF (name->data);
+ jstring sname = name->toString();
java::lang::ClassLoader *sys
= java::lang::ClassLoader::getSystemClassLoader ();
@@ -470,7 +470,7 @@ _Jv_NewArrayClass (jclass element, java::lang::ClassLoader *loader,
len = 3;
}
else
- len = element->name->length + 5;
+ len = element->name->len() + 5;
{
char signature[len];
@@ -483,8 +483,8 @@ _Jv_NewArrayClass (jclass element, java::lang::ClassLoader *loader,
}
else
{
- size_t length = element->name->length;
- const char *const name = element->name->data;
+ size_t length = element->name->len();
+ const char *const name = element->name->chars();
if (name[0] != '[')
signature[index++] = 'L';
memcpy (&signature[index], name, length);
diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc
index 8f9efdb..58b1cf6 100644
--- a/libjava/java/lang/reflect/natMethod.cc
+++ b/libjava/java/lang/reflect/natMethod.cc
@@ -246,7 +246,7 @@ _Jv_GetTypesFromSignature (jmethodID method,
_Jv_Utf8Const* sig = method->signature;
java::lang::ClassLoader *loader = declaringClass->getClassLoaderInternal();
- char *ptr = sig->data;
+ char *ptr = sig->chars();
int numArgs = 0;
/* First just count the number of parameters. */
for (; ; ptr++)
@@ -283,7 +283,7 @@ _Jv_GetTypesFromSignature (jmethodID method,
JArray<jclass> *args = (JArray<jclass> *)
JvNewObjectArray (numArgs, &java::lang::Class::class$, NULL);
jclass* argPtr = elements (args);
- for (ptr = sig->data; *ptr != '\0'; ptr++)
+ for (ptr = sig->chars(); *ptr != '\0'; ptr++)
{
int num_arrays = 0;
jclass type;