OK, I've solved it. JNI wasn't really a skill I wanted in my toolbelt, but
anyway...

There were two types of problems in bindings.c, both of which gcj was
forgiving of but Sun was not. I'm surprised that gcj managed to access
fields when given a class instead of an object! See patch below. The code
now works with both gcj and Sun.

$ diff bindings.c bindings.orig
69c69
<     if (!(jcexcep = (*jenv)->FindClass(jenv, "org/a11y/BrlAPI/Error"))) {
---
>     if (!(jcexcep = (*jenv)->FindClass(jenv, "org.a11y.BrlAPI.Error"))) {
100c100
<   if (!(jcexcep = (*env)->FindClass(env, "org/a11y/BrlAPI/Exception"))) {
---
>   if (!(jcexcep = (*env)->FindClass(env, "org.a11y.BrlAPI.Exception"))) {
133c133
<   handle = (void*) (intptr_t) (*jenv)->GetLongField(jenv, jobj, handleID);
\
---
>   handle = (void*) (intptr_t) (*jenv)->GetLongField(jenv, jcls, handleID);
\
158,159c158
<
<   (*jenv)->SetLongField(jenv, jobj, handleID, (jlong) (intptr_t) handle);
---
>   (*jenv)->SetLongField(jenv, jcls, handleID, (jlong) (intptr_t) handle);
235c234
<   (*jenv)->SetLongField(jenv, jobj, handleID, (jlong) (intptr_t) NULL);
---
>   (*jenv)->SetLongField(jenv, jcls, handleID, (jlong) (intptr_t) NULL);
267c266
<   if (!(jcsize = (*jenv)->FindClass(jenv, "org/a11y/BrlAPI/DisplaySize")))
{
---
>   if (!(jcsize = (*jenv)->FindClass(jenv, "org.a11y.BrlAPI.DisplaySize")))
{

Cheers,
Simon


2009/5/27 Samuel Thibault <[email protected]>

> Mario Lang, le Tue 26 May 2009 15:10:41 +0200, a écrit :
> > Samuel Thibault <[email protected]> writes:
> > Yet another data point for you:  If I execute the test code with
> > /usr/lib/jvm/java-gcj/bin/java it works.
> > If I use openjdk or sun variants, it breaks.
> >
> > Looks like a hotspot thing, or some incompatibility in the JNI support
> > between gcj and the sun derives JVMs.
>
> I'm a bit clueless.  My jni code definitively is correct.  It is not a
> 32bit/64bit issue as Simon tests with a 32bit machine.  Simon, are you
> using gcj's jni.h or sun's jni.h?
>
> Samuel
> _______________________________________________
> This message was sent via the BRLTTY mailing list.
> To post a message, send an e-mail to: [email protected]
> For general information, go to: http://mielke.cc/mailman/listinfo/brltty
>
_______________________________________________
This message was sent via the BRLTTY mailing list.
To post a message, send an e-mail to: [email protected]
For general information, go to: http://mielke.cc/mailman/listinfo/brltty

Reply via email to