implement JVM_ResolveClass

This just reuses code in avian.Classes which was formerly only used in
the Avian classpath build.
This commit is contained in:
Joel Dice 2011-03-26 23:24:48 -06:00
parent ba028b86bf
commit 686cbc3637
5 changed files with 51 additions and 30 deletions

View File

@ -53,7 +53,7 @@ public class Classes {
return c;
} catch (ClassNotFoundException e) {
NoClassDefFoundError error = new NoClassDefFoundError
(new String(nameBytes, offset, length, false));
(new String(nameBytes, offset, length));
error.initCause(e);
throw error;
}
@ -96,7 +96,7 @@ public class Classes {
case 's': {
byte[] data = (byte[]) Singleton.getObject(pool, read2(in) - 1);
return new String(data, 0, data.length - 1, false);
return new String(data, 0, data.length - 1);
}
case 'e': {
@ -106,7 +106,7 @@ public class Classes {
return Enum.valueOf
(SystemClassLoader.getClass
(loadVMClass(loader, typeName, 1, typeName.length - 3)),
new String(name, 0, name.length - 1, false));
new String(name, 0, name.length - 1));
}
case 'c':{
@ -143,7 +143,7 @@ public class Classes {
for (int i = 2; i < annotation.length; i += 2) {
byte[] name = (byte[]) Singleton.getObject(pool, read2(in) - 1);
annotation[i] = new String(name, 0, name.length - 1, false);
annotation[i] = new String(name, 0, name.length - 1);
annotation[i + 1] = parseAnnotationValue(loader, pool, in);
}

View File

@ -552,12 +552,14 @@ ifneq ($(classpath),avian)
$(classpath-src)/avian/Callback.java \
$(classpath-src)/avian/CallbackReceiver.java \
$(classpath-src)/avian/ClassAddendum.java \
$(classpath-src)/avian/Classes.java \
$(classpath-src)/avian/ConstantPool.java \
$(classpath-src)/avian/Continuations.java \
$(classpath-src)/avian/FieldAddendum.java \
$(classpath-src)/avian/IncompatibleContinuationException.java \
$(classpath-src)/avian/Machine.java \
$(classpath-src)/avian/MethodAddendum.java \
$(classpath-src)/avian/Singleton.java \
$(classpath-src)/avian/Stream.java \
$(classpath-src)/avian/SystemClassLoader.java \
$(classpath-src)/avian/VMClass.java \

View File

@ -48,6 +48,31 @@ resolveSystemClassThrow(Thread* t, object loader, object spec)
} // namespace
extern "C" JNIEXPORT void JNICALL
Avian_avian_Classes_acquireClassLock
(Thread* t, object, uintptr_t*)
{
acquire(t, t->m->classLock);
}
extern "C" JNIEXPORT void JNICALL
Avian_avian_Classes_releaseClassLock
(Thread* t, object, uintptr_t*)
{
release(t, t->m->classLock);
}
extern "C" JNIEXPORT int64_t JNICALL
Avian_avian_Classes_resolveVMClass
(Thread* t, object, uintptr_t* arguments)
{
object loader = reinterpret_cast<object>(arguments[0]);
object spec = reinterpret_cast<object>(arguments[1]);
return reinterpret_cast<int64_t>
(resolveClass(t, loader, spec, true, Machine::ClassNotFoundExceptionType));
}
extern "C" JNIEXPORT int64_t JNICALL
Avian_avian_SystemClassLoader_findLoadedVMClass
(Thread* t, object, uintptr_t* arguments)

View File

@ -589,31 +589,6 @@ Avian_java_lang_Thread_yield
t->m->system->yield();
}
extern "C" JNIEXPORT void JNICALL
Avian_avian_Classes_acquireClassLock
(Thread* t, object, uintptr_t*)
{
acquire(t, t->m->classLock);
}
extern "C" JNIEXPORT void JNICALL
Avian_avian_Classes_releaseClassLock
(Thread* t, object, uintptr_t*)
{
release(t, t->m->classLock);
}
extern "C" JNIEXPORT int64_t JNICALL
Avian_avian_Classes_resolveVMClass
(Thread* t, object, uintptr_t* arguments)
{
object loader = reinterpret_cast<object>(arguments[0]);
object spec = reinterpret_cast<object>(arguments[1]);
return reinterpret_cast<int64_t>
(resolveClass(t, loader, spec, true, Machine::ClassNotFoundExceptionType));
}
extern "C" JNIEXPORT int64_t JNICALL
Avian_avian_Classes_primitiveClass
(Thread* t, object, uintptr_t* arguments)

View File

@ -3312,8 +3312,27 @@ EXPORT(JVM_FindPrimitiveClass)(Thread* t, const char* name)
}
}
uint64_t
jvmResolveClass(Thread* t, uintptr_t* arguments)
{
jclass c = reinterpret_cast<jclass>(arguments[0]);
object method = resolveMethod
(t, root(t, Machine::BootLoader), "avian/Classes", "link",
"(Lavian/VMClass;)V");
t->m->processor->invoke(t, method, 0, jclassVmClass(t, *c));
return 1;
}
extern "C" JNIEXPORT void JNICALL
EXPORT(JVM_ResolveClass)(Thread*, jclass) { abort(); }
EXPORT(JVM_ResolveClass)(Thread* t, jclass c)
{
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(c) };
run(t, jvmResolveClass, arguments);
}
uint64_t
jvmFindClassFromClassLoader(Thread* t, uintptr_t* arguments)