From 3febd7cea7163115a3be13937deb8d5306ab5749 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sun, 10 Apr 2011 11:26:44 -0600 Subject: [PATCH] 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. --- src/classpath-avian.cpp | 7 +++++++ src/classpath-openjdk.cpp | 26 +++++++++++++++++++++----- src/compile.cpp | 4 ++-- src/machine.h | 3 +++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/classpath-avian.cpp b/src/classpath-avian.cpp index af1e337fcc..89c6cdc13d 100644 --- a/src/classpath-avian.cpp +++ b/src/classpath-avian.cpp @@ -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*) { diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 83d85af556..e130e93a16 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -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("sun/font/FontManager"), + &byteArrayBody(t, className(t, methodClass(t, method)), 0)) == 0 + and strcmp(reinterpret_cast("initIDs"), + &byteArrayBody(t, methodName(t, method), 0)) == 0 + and strcmp(reinterpret_cast("()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 diff --git a/src/compile.cpp b/src/compile.cpp index 369515b5d6..de07ebd294 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -7334,7 +7334,7 @@ invokeNative(MyThread* t) static_cast(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); diff --git a/src/machine.h b/src/machine.h index c73a11d0b3..488ed45563 100644 --- a/src/machine.h +++ b/src/machine.h @@ -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;