accept foo.bar.Baz as well as foo/bar/Baz in FindClass

This commit is contained in:
Joel Dice 2008-01-19 13:30:11 -07:00
parent ee60d48cfe
commit e9826b2d7f

View File

@ -143,13 +143,24 @@ NewStringUTF(Thread* t, const char* chars)
return makeLocalReference(t, s);
}
void
replace(int a, int b, const char* in, int8_t* out)
{
while (*in) {
*out = (*in == a ? b : *in);
++ in;
++ out;
}
*out = 0;
}
jclass JNICALL
FindClass(Thread* t, const char* name)
{
ENTER(t, Thread::ActiveState);
object n = makeByteArray(t, strlen(name) + 1, false);
memcpy(&byteArrayBody(t, n, 0), name, byteArrayLength(t, n));
replace('.', '/', name, &byteArrayBody(t, n, 0));
return makeLocalReference(t, resolveClass(t, n));
}