LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: igorky on March 10, 2010, 11:01:35

Title: Linux JNI bug found
Post by: igorky on March 10, 2010, 11:01:35
Linux version 2.6.31-19-386 (buildd@palmer) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) ) #56-Ubuntu SMP Thu Jan 28 03:33:38 UTC 2010 (Ubuntu 2.6.31-19.56-386)

Run java with -Xcheck:jni

FATAL ERROR in native method: Static field ID passed to JNI
        at java.lang.ClassLoader$NativeLibrary.find(Native Method)
        at java.lang.ClassLoader.findNative(Unknown Source)
        - locked <0x806c14b0> (a java.util.Vector)
        at org.lwjgl.opengl.LinuxEvent.nGetButtonTime(Native Method)
        at org.lwjgl.opengl.LinuxEvent.getButtonTime(LinuxEvent.java:135)
        at org.lwjgl.opengl.LinuxMouse.filterEvent(LinuxMouse.java:285)
        at org.lwjgl.opengl.LinuxDisplay.processEvents(LinuxDisplay.java:740)
        at org.lwjgl.opengl.LinuxDisplay.update(LinuxDisplay.java:775)
        at org.lwjgl.opengl.Display.processMessages(Display.java:679)
        - locked <0x806b1328> (a java.lang.Object)
        at org.lwjgl.opengl.Display.update(Display.java:708)
        - locked <0x806b1328> (a java.lang.Object)
        at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:418)
        at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:318)
        at org.newdawn.slick.tests.ShapeTest.main(ShapeTest.java:286)
Title: Re: Linux JNI bug found
Post by: Matzon on March 10, 2010, 12:28:29
 

   56 private final ByteBuffer event_buffer;
   57
   58 LinuxEvent() {
   59 this.event_buffer = createEventBuffer();
   60 }
   61 private static native ByteBuffer createEventBuffer();


  134 public long getButtonTime() {
  135 return nGetButtonTime(event_buffer);
  136 }

  137 private static native long nGetButtonTime(ByteBuffer event_buffer);



   
   47 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxEvent_createEventBuffer(JNIEnv *env, jclass unused) {
   48 return newJavaManagedByteBuffer(env, sizeof(XEvent));
   49 }


  116 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonTime(JNIEnv *env, jclass unused, jobject event_buffer) {
  117 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
  118 return event->xbutton.time;
  119 }



looks like a bogus jni complaint to me?
Title: Re: Linux JNI bug found
Post by: igorky on March 10, 2010, 12:57:26
But my app is exit on this error. Any suggest?
Title: Re: Linux JNI bug found
Post by: princec on March 10, 2010, 14:11:26
I had this same bug on some other native code in Windows. It turns out that it was a long field, which was being obtained correctly in JNI but which triggered this error. Switching the Java field to an int mysteriously caused the  Java error to go away. I suspect now that it's actually a JNI bug.

Cas :)
Title: Re: Linux JNI bug found
Post by: Matzon on March 10, 2010, 16:36:29
Quote from: igorky on March 10, 2010, 12:57:26
But my app is exit on this error. Any suggest?
Wouldn't this then be an error for all linux users???
Title: Re: Linux JNI bug found
Post by: princec on March 10, 2010, 17:21:32
It only picks it up if you run with -Xcheck:jni

Cas :)