Linux JNI bug found

Started by igorky, March 10, 2010, 11:01:35

Previous topic - Next topic

igorky

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)

Matzon

  

   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?

igorky

But my app is exit on this error. Any suggest?

princec

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 :)

Matzon

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???

princec

It only picks it up if you run with -Xcheck:jni

Cas :)