load libfontmanager.so before trying to resolve FontManager.initIDs

sun.font.FontManager.initIDs is a native method defined in
libfontmanager.so, yet there seems to be no mechanism in OpenJDK's
class library to actually load that library, so we lazily load it
before trying to resolve the method.
This commit is contained in:
Joel Dice 2011-04-10 11:26:44 -06:00
parent d5fb7f97b9
commit 3febd7cea7
4 changed files with 33 additions and 7 deletions

View File

@ -10,6 +10,7 @@
#include "machine.h"
#include "classpath-common.h"
#include "process.h"
using namespace vm;
@ -63,6 +64,12 @@ class MyClasspath : public Classpath {
t->m->processor->invoke(t, method, 0, t->javaThread);
}
virtual void
resolveNative(Thread* t, object method)
{
vm::resolveNative(t, method);
}
virtual void
boot(Thread*)
{

View File

@ -11,6 +11,7 @@
#include "machine.h"
#include "classpath-common.h"
#include "util.h"
#include "process.h"
#ifdef PLATFORM_WINDOWS
@ -517,6 +518,24 @@ class MyClasspath : public Classpath {
release(t, t->javaThread);
}
virtual void
resolveNative(Thread* t, object method)
{
if (strcmp(reinterpret_cast<const int8_t*>("sun/font/FontManager"),
&byteArrayBody(t, className(t, methodClass(t, method)), 0)) == 0
and strcmp(reinterpret_cast<const int8_t*>("initIDs"),
&byteArrayBody(t, methodName(t, method), 0)) == 0
and strcmp(reinterpret_cast<const int8_t*>("()V"),
&byteArrayBody(t, methodSpec(t, method), 0)) == 0)
{
PROTECT(t, method);
expect(t, loadLibrary(t, libraryPath, "fontmanager", true, true));
}
vm::resolveNative(t, method);
}
virtual void
boot(Thread* t)
{
@ -528,11 +547,8 @@ class MyClasspath : public Classpath {
#ifdef AVIAN_OPENJDK_SRC
interceptFileOperations(t);
#else // not AVIAN_OPENJDK_SRC
if (loadLibrary(t, libraryPath, "verify", true, true) == 0
or loadLibrary(t, libraryPath, "java", true, true) == 0)
{
abort(t);
}
expect(t, loadLibrary(t, libraryPath, "verify", true, true));
expect(t, loadLibrary(t, libraryPath, "java", true, true));
#endif // not AVIAN_OPENJDK_SRC
object constructor = resolveMethod

View File

@ -7334,7 +7334,7 @@ invokeNative(MyThread* t)
static_cast<MyThread*>(t)->trace->nativeMethod = 0;
});
resolveNative(t, t->trace->nativeMethod);
t->m->classpath->resolveNative(t, t->trace->nativeMethod);
result = invokeNative2(t, t->trace->nativeMethod);
@ -8143,7 +8143,7 @@ class SignalHandler: public System::SignalHandler {
t->exception = vm::root(t, root);
}
// printTrace(t, t->exception);
printTrace(t, t->exception);
object continuation;
findUnwindTarget(t, ip, frame, stack, &continuation);

View File

@ -1567,6 +1567,9 @@ class Classpath {
virtual void
runThread(Thread* t) = 0;
virtual void
resolveNative(Thread* t, object method) = 0;
virtual void
boot(Thread* t) = 0;