+2004-08-09 Per Bothner <per@bothner.com>
+
+ * 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.
+
2004-08-10 Andrew Haley <aph@redhat.com>
* testsuite/libjava.lang/err14.java: New file.
// tell everyone we're done.
def->state = JV_STATE_LOADED;
if (gcj::verbose_class_flag)
- fprintf (stderr, "[Loaded (bytecode) %s]\n", (const char*)(def->name->data));
+ fprintf (stderr, "[Loaded (bytecode) %s]\n", def->name->chars());
def->notifyAll ();
}
jstring msg = JvNewStringUTF ("loaded class ");
msg = msg->concat (def->getName ());
msg = msg->concat (_Jv_NewStringUTF (" was in fact named "));
- jstring klass_name = _Jv_NewStringUTF (loadedName->data);
+ jstring klass_name = loadedName->toString();
msg = msg->concat (klass_name);
throw_no_class_def_found_error (msg);
if (def->name != NULL)
{
jsize mlen = strlen (msg);
- unsigned char* data = (unsigned char*) def->name->data;
- int ulen = def->name->length;
+ unsigned char* data = (unsigned char*) def->name->chars();
+ int ulen = def->name->len();
unsigned char* limit = data + ulen;
jsize nlen = _Jv_strLengthUtf8 ((char *) data, ulen);
jsize len = nlen + mlen + 3;
bool
_Jv_VerifyFieldSignature (_Jv_Utf8Const*sig)
{
- unsigned char* ptr = (unsigned char*) sig->data;
- unsigned char* limit = ptr + sig->length;
+ unsigned char* ptr = (unsigned char*) sig->chars();
+ unsigned char* limit = ptr + sig->len();
ptr = _Jv_VerifyOne (ptr, limit, false);
bool
_Jv_VerifyMethodSignature (_Jv_Utf8Const*sig)
{
- unsigned char* ptr = (unsigned char*) sig->data;
- unsigned char* limit = ptr + sig->length;
+ unsigned char* ptr = (unsigned char*) sig->chars();
+ unsigned char* limit = ptr + sig->len();
if (ptr == limit || UTF8_GET(ptr,limit) != '(')
return false;
bool
_Jv_VerifyIdentifier (_Jv_Utf8Const* name)
{
- unsigned char *ptr = (unsigned char*) name->data;
- unsigned char *limit = ptr + name->length;
+ unsigned char *ptr = (unsigned char*) name->chars();
+ unsigned char *limit = (unsigned char*) name->limit();
int ch;
if ((ch = UTF8_GET (ptr, limit))==-1
bool
_Jv_VerifyClassName (_Jv_Utf8Const *name)
{
- return _Jv_VerifyClassName ((unsigned char*)&name->data[0],
- (_Jv_ushort) name->length);
+ return _Jv_VerifyClassName ((unsigned char*)name->chars(), name->len());
}
/* Returns true, if NAME1 and NAME2 represent classes in the same
bool
_Jv_ClassNameSamePackage (_Jv_Utf8Const *name1, _Jv_Utf8Const *name2)
{
- unsigned char* ptr1 = (unsigned char*) name1->data;
- unsigned char* limit1 = ptr1 + name1->length;
+ unsigned char* ptr1 = (unsigned char*) name1->chars();
+ unsigned char* limit1 = (unsigned char*) name1->limit();
unsigned char* last1 = ptr1;
}
// Now the length of NAME1's package name is LEN.
- int len = last1 - (unsigned char*) name1->data;
+ int len = last1 - (unsigned char*) name1->chars();
// If this is longer than NAME2, then we're off.
- if (len > name2->length)
+ if (len > name2->len())
return false;
// Then compare the first len bytes for equality.
- if (memcmp ((void*) name1->data, (void*) name2->data, len) == 0)
+ if (memcmp ((void*) name1->chars(), (void*) name2->chars(), len) == 0)
{
// Check that there are no .'s after position LEN in NAME2.
- unsigned char* ptr2 = (unsigned char*) name2->data + len;
- unsigned char* limit2 =
- (unsigned char*) name2->data + name2->length;
+ unsigned char* ptr2 = (unsigned char*) name2->chars() + len;
+ unsigned char* limit2 = (unsigned char*) name2->limit();
while (ptr2 < limit2)
{
#include <string.h>
-extern "C" jstring _Jv_NewStringUTF (const char *bytes);
extern "C" void _Jv_InitClass (jclass);
extern "C" void *_Jv_AllocBytes (jsize size) __attribute__((__malloc__));
{
if (!isResolved ())
{
- char first = ((_Jv_Utf8Const*)type)->data[0];
+ char first = ((_Jv_Utf8Const*)type)->first();
return first == '[' || first == 'L';
}
else
extern "C" jchar* _Jv_GetStringChars (jstring str);
extern "C" void _Jv_MonitorEnter (jobject);
extern "C" void _Jv_MonitorExit (jobject);
+extern "C" jstring _Jv_NewStringUTF (const char *bytes)
+ __attribute__((__malloc__));
extern "C" jstring _Jv_NewStringLatin1(const char*, jsize)
__attribute__((__malloc__));
extern "C" jsize _Jv_GetStringUTFLength (jstring);
extern "C" jsize _Jv_GetStringUTFRegion (jstring, jsize, jsize, char *);
+extern "C" jint _Jv_hashUtf8String (char*, int);
extern jint _Jv_CreateJavaVM (void* /*vm_args*/);
typedef unsigned int _Jv_uint __attribute__((__mode__(__SI__)));
typedef unsigned int _Jv_ulong __attribute__((__mode__(__DI__)));
-struct _Jv_Utf8Const
+class _Jv_Utf8Const
{
_Jv_ushort hash;
_Jv_ushort length; /* In bytes, of data portion, without final '\0'. */
char data[1]; /* In Utf8 format, with final '\0'. */
+ public:
+ /** Return same value of java.lang.String's hashCode. */
+ jint hash32() { return _Jv_hashUtf8String(data, length); }
+ /** Return a hash code that has at least 16 bits of information. */
+ _Jv_ushort hash16 () { return hash; }
+ /** Return a hash code that has at least 8 bits of information. */
+ _Jv_ushort hash8 () { return hash; }
+ /** Length in bytes of the UTF8-encoding. */
+ _Jv_ushort len () const { return length; }
+ /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
+ char* chars() { return data; }
+ /** Pointer to the NUL byte that terminated the UTF8-encoding. */
+ char* limit() { return data+length; }
+ /** Return the first byte in the UTF8-encoding. */
+ char first() const { return data[0]; }
+ /** Create a (non-interned) java.lang.String from this UTF8Const. */
+ jstring toString() { return _Jv_NewStringUTF(data); }
+ /** Given an UTF8 string, how many bytes needed for a UTF8Const,
+ including struct header, and final NUL. I.e. what to pas to malloc. */
+ static int space_needed (char *, int len)
+ { return sizeof (_Jv_Utf8Const) + len + 1; }
+ /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
+ void init (char *s, int len);
+ friend jboolean _Jv_equalUtf8Consts (const _Jv_Utf8Const*, const _Jv_Utf8Const *);
+ friend jboolean _Jv_equal (_Jv_Utf8Const*, jstring, jint);
+ friend jboolean _Jv_equaln (_Jv_Utf8Const*, jstring, jint);
+ friend _Jv_Utf8Const *_Jv_makeUtf8Const (char*, int);
+ friend _Jv_Utf8Const *_Jv_makeUtf8Const (jstring);
+ friend jstring _Jv_NewStringUtf8Const (_Jv_Utf8Const*);
};
{
using namespace java::lang::reflect;
return (((meth->accflags & (Modifier::STATIC | Modifier::PRIVATE)) == 0)
- && meth->name->data[0] != '<');
+ && meth->name->first() != '<');
}
// This function is used to determine the hash code of an object.
inline jboolean isArray (void)
{
- return name->data[0] == '[';
+ return name->first() == '[';
}
inline jclass getComponentType (void)
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)
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> *
_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;
{
_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;
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;
}
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;
// 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
// 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
_Jv_LayoutVTableMethods (target_class);
}
- meth = _Jv_LookupDeclaredMethod(target_class, sym.name,
+ meth = _Jv_LookupDeclaredMethod(target_class, sym.name,
sym.signature);
if (meth != NULL)
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
{
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)
{
_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);
}
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 ();
#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
{
// 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)
if (! klass)
{
- jstring sname = _Jv_NewStringUTF (name->data);
+ jstring sname = name->toString();
java::lang::ClassLoader *sys
= java::lang::ClassLoader::getSystemClassLoader ();
len = 3;
}
else
- len = element->name->length + 5;
+ len = element->name->len() + 5;
{
char signature[len];
}
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);
_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++)
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;
{
_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))
// 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);
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)
_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;
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;
if (function == NULL)
#endif /* WIN32 */
{
- jstring str = JvNewStringUTF (name->data);
+ jstring str = JvNewStringUTF (name->chars ());
throw new java::lang::UnsatisfiedLinkError (str);
}
}
/* Calculate a hash value for a string encoded in Utf8 format.
* This returns the same hash value as specified or java.lang.String.hashCode.
*/
-static jint
-hashUtf8String (char* str, int len)
+jint
+_Jv_hashUtf8String (char* str, int len)
{
unsigned char* ptr = (unsigned char*) str;
unsigned char* limit = ptr + len;
return hash;
}
+void
+_Jv_Utf8Const::init(char *s, int len)
+{
+ ::memcpy (data, s, len);
+ data[len] = 0;
+ length = len;
+ hash = _Jv_hashUtf8String (s, len) & 0xFFFF;
+}
+
_Jv_Utf8Const *
_Jv_makeUtf8Const (char* s, int len)
{
if (len < 0)
len = strlen (s);
- Utf8Const* m = (Utf8Const*) _Jv_AllocBytes (sizeof(Utf8Const) + len + 1);
- memcpy (m->data, s, len);
- m->data[len] = 0;
- m->length = len;
- m->hash = hashUtf8String (s, len) & 0xFFFF;
- return (m);
+ Utf8Const* m
+ = (Utf8Const*) _Jv_AllocBytes (_Jv_Utf8Const::space_needed(s, len));
+ m->init(s, len);
+ return m;
}
_Jv_Utf8Const *
if (! field->isResolved ())
{
_Jv_Utf8Const *sig = (_Jv_Utf8Const*)field->type;
- field->type = _Jv_FindClassFromSignature (sig->data, loader);
+ field->type = _Jv_FindClassFromSignature (sig->chars(), loader);
field->flags &= ~_Jv_FIELD_UNRESOLVED_FLAG;
}
}
_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();
// This exception is specified in JLS 2nd Ed, section 5.1.
throw new java::lang::NoClassDefFoundError (str);
}
jclass field_type = 0;
if (owner->loader != klass->loader)
- field_type = _Jv_FindClassFromSignature (field_type_name->data,
+ field_type = _Jv_FindClassFromSignature (field_type_name->chars(),
klass->loader);
_Jv_Field* the_field = 0;
sb->append(JvNewStringLatin1("field "));
sb->append(owner->getName());
sb->append(JvNewStringLatin1("."));
- sb->append(_Jv_NewStringUTF(field_name->data));
+ sb->append(field_name->toString());
sb->append(JvNewStringLatin1(" was not found."));
throw_incompatible_class_change_error(sb->toString());
}
sb->append(JvNewStringLatin1("method "));
sb->append(owner->getName());
sb->append(JvNewStringLatin1("."));
- sb->append(_Jv_NewStringUTF(method_name->data));
+ sb->append(method_name->toString());
sb->append(JvNewStringLatin1(" was not found."));
throw new java::lang::NoSuchMethodError (sb->toString());
}
sb->append(JvNewStringLatin1(": "));
sb->append(cls->getName());
sb->append(JvNewStringLatin1("."));
- sb->append(_Jv_NewStringUTF(method_name->data));
- sb->append(_Jv_NewStringUTF(method_signature->data));
+ sb->append(method_name->toString());
+ sb->append(method_signature->toString());
throw new java::lang::IllegalAccessError (sb->toString());
}
}
{
_Jv_Method *meth = &iface_class->interfaces[i]->methods[j];
// Don't bother with <clinit>.
- if (meth->name->data[0] == '<')
+ if (meth->name->first() == '<')
continue;
_Jv_Method *new_meth = _Jv_LookupDeclaredMethod (base, meth->name,
meth->signature);
_Jv_count_arguments (_Jv_Utf8Const *signature,
jboolean staticp)
{
- unsigned char *ptr = (unsigned char*) signature->data;
+ unsigned char *ptr = (unsigned char*) signature->chars();
int arg_count = staticp ? 0 : 1;
/* first, count number of arguments */
ffi_type **arg_types,
ffi_type **rtype_p)
{
- unsigned char *ptr = (unsigned char*) signature->data;
+ unsigned char *ptr = (unsigned char*) signature->chars();
int arg_index = 0; // arg number
int item_count = 0; // stack-item count
ffi_type *rtype = get_ffi_type_from_signature (ptr);
ptr = skip_one_type (ptr);
- if (ptr != (unsigned char*)signature->data + signature->length)
+ if (ptr != (unsigned char*)signature->chars() + signature->len())
throw_internal_error ("did not find end of signature");
if (ffi_prep_cif (cif, FFI_DEFAULT_ABI,
// This method.
_Jv_InterpMethod *current_method;
- // A linked list of utf8 objects we allocate. This is really ugly,
- // but without this our utf8 objects would be collected.
+ // A linked list of utf8 objects we allocate.
linked<_Jv_Utf8Const> *utf8_list;
// A linked list of all ref_intersection objects we allocate.
ref_intersection *isect_list;
// Create a new Utf-8 constant and return it. We do this to avoid
- // having our Utf-8 constants prematurely collected. FIXME this is
- // ugly.
+ // having our Utf-8 constants prematurely collected.
_Jv_Utf8Const *make_utf8_const (char *s, int len)
{
- _Jv_Utf8Const *val = _Jv_makeUtf8Const (s, len);
- _Jv_Utf8Const *r = (_Jv_Utf8Const *) _Jv_Malloc (sizeof (_Jv_Utf8Const)
- + val->length
- + 1);
- r->length = val->length;
- r->hash = val->hash;
- memcpy (r->data, val->data, val->length + 1);
-
- linked<_Jv_Utf8Const> *lu
- = (linked<_Jv_Utf8Const> *) _Jv_Malloc (sizeof (linked<_Jv_Utf8Const>));
+ linked<_Jv_Utf8Const> *lu = (linked<_Jv_Utf8Const> *)
+ _Jv_Malloc (sizeof (linked<_Jv_Utf8Const>)
+ + _Jv_Utf8Const::space_needed(s, len));
+ _Jv_Utf8Const *r = (_Jv_Utf8Const *) (lu + 1);
+ r->init(s, len);
lu->val = r;
lu->next = utf8_list;
utf8_list = lu;
buf->append (JvNewStringLatin1 (" in "));
buf->append (current_class->getName());
buf->append ((jchar) ':');
- buf->append (JvNewStringUTF (method->get_method()->name->data));
+ buf->append (method->get_method()->name->toString());
buf->append ((jchar) '(');
- buf->append (JvNewStringUTF (method->get_method()->signature->data));
+ buf->append (method->get_method()->signature->toString());
buf->append ((jchar) ')');
buf->append (JvNewStringLatin1 (": "));
java::lang::ClassLoader *loader
= verifier->current_class->getClassLoaderInternal();
// We might see either kind of name. Sigh.
- if (data.name->data[0] == 'L'
- && data.name->data[data.name->length - 1] == ';')
- data.klass = _Jv_FindClassFromSignature (data.name->data, loader);
+ if (data.name->first() == 'L' && data.name->limit()[-1] == ';')
+ data.klass = _Jv_FindClassFromSignature (data.name->chars(), loader);
else
data.klass = Class::forName (_Jv_NewStringUtf8Const (data.name),
false, loader);
if (is_resolved)
return data.klass->isArray ();
else
- return data.name->data[0] == '[';
+ return data.name->first() == '[';
}
bool isinterface (_Jv_BytecodeVerifier *verifier)
}
else
{
- char *p = data.name->data;
+ char *p = data.name->chars();
while (*p++ == '[')
++ndims;
}
&name, &field_type);
if (class_type)
*class_type = ct;
- if (field_type->data[0] == '[' || field_type->data[0] == 'L')
+ if (field_type->first() == '[' || field_type->first() == 'L')
return type (field_type, this);
- return get_type_val_for_signature (field_type->data[0]);
+ return get_type_val_for_signature (field_type->first());
}
type check_method_constant (int index, bool is_interface,
void compute_argument_types (_Jv_Utf8Const *signature,
type *types)
{
- char *p = signature->data;
+ char *p = signature->chars();
+
// Skip `('.
++p;
type compute_return_type (_Jv_Utf8Const *signature)
{
- char *p = signature->data;
+ char *p = signature->chars();
while (*p != ')')
++p;
++p;
if (opcode != op_invokespecial)
verify_fail ("can't invoke <init>");
}
- else if (method_name->data[0] == '<')
+ else if (method_name->first() == '<')
verify_fail ("can't invoke method starting with `<'");
// Pop arguments and check types.
// We just print the text as utf-8. This is just for debugging
// anyway.
debug_print ("--------------------------------\n");
- debug_print ("-- Verifying method `%s'\n", m->self->name->data);
+ debug_print ("-- Verifying method `%s'\n", m->self->name->chars());
current_method = m;
bytecode = m->bytecode ();
while (utf8_list != NULL)
{
linked<_Jv_Utf8Const> *n = utf8_list->next;
- _Jv_Free (utf8_list->val);
_Jv_Free (utf8_list);
utf8_list = n;
}