Tim Ellison wrote:
Oleg Khaschansky wrote:
Do you suggest to introduce the error handling for all the wrappers or
only for this one? If for all, do you think if it will affect the
performance?

I was thinking of something like this.  In the non-error case it would
add an additional NULL check as the function address is being cached,
and no additional overhead after the cache has been populated.

The actual exception thrown is open to debate.\

:)

I don't understand the context - in the event of this fault, is it time to simply shut down? Or is this survivable? My understanding is that you just don't want to see a GPF.

Either way, how about a hint - like "missing libxmu" or similar?

geir


Index:
src/main/native/x11wrapper/linux/org_apache_harmony_awt_nativebridge_linux_X11.cpp
===================================================================
---
src/main/native/x11wrapper/linux/org_apache_harmony_awt_nativebridge_linux_X11.cpp
(revision 478891)
+++
src/main/native/x11wrapper/linux/org_apache_harmony_awt_nativebridge_linux_X11.cpp
(working copy)
@@ -23,6 +23,7 @@

 #include "org_apache_harmony_awt_nativebridge_linux_X11.h"
 #include "org_apache_harmony_awt_nativebridge_linux_ErrorHandler.h"
+#include "exceptions.h"

 static libHandler libX11;
 static libHandler libXmu;
@@ -575,6 +576,10 @@
 JNIEXPORT jint  JNICALL
Java_org_apache_harmony_awt_nativebridge_linux_X11_XmuLookupStandardColormap(
JNIEnv *env, jobject self, jlong dpy, jint screen, jlong visualid, jint
depth, jlong property, jint replace, jint retain) {
     if (p_nbridge_XmuLookupStandardColormap == NULL) {
         p_nbridge_XmuLookupStandardColormap = (int (*) (void *, int,
long, int, long, int, int)) FindFunction(libXmu,
"XmuLookupStandardColormap");
+        if (p_nbridge_XmuLookupStandardColormap == NULL) {
+            throwNewExceptionByName(env,
"java/lang/UnsupportedOperationException", "Function not found");
+            return 0;
+               }
     }
     return (jint) (* p_nbridge_XmuLookupStandardColormap)((void *) dpy,
(int) screen, (long) visualid, (int) depth, (long) property, (int)
replace, (int) retain);
 }


What do you think?

Regards,
Tim

Reply via email to