Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8127739

Gtk: fails to start when run with -Xcheck:jni

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7u6
    • 7u6
    • javafx
    • Linux/x86/GTK

      java -Xcheck:jni -cp artifacts/sdk/rt/lib/jfxrt.jar:apps/ga-samples/Ensemble/dist/Ensemble.jar ensemble.Ensemble2

      FATAL ERROR in native method: Bad global or local ref passed to JNI
      at com.sun.glass.ui.gtk.GtkWindow._createWindow(Native Method)
      at com.sun.glass.ui.Window.<init>(Window.java:176)
      at com.sun.glass.ui.gtk.GtkWindow.<init>(GtkWindow.java:21)
      at com.sun.glass.ui.gtk.GtkApplication.createWindow(GtkApplication.java:139)
      at com.sun.javafx.tk.quantum.WindowStage.initPlatformWindow(WindowStage.java:139)
      at com.sun.javafx.tk.quantum.WindowStage.init(WindowStage.java:80)
      at com.sun.javafx.tk.quantum.QuantumToolkit.createTKStage(QuantumToolkit.java:495)
      at javafx.stage.Stage.impl_visibleChanging(Stage.java:840)
      at javafx.stage.Window$10.invalidated(Window.java:676)
      at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:129)
      at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:163)
      at javafx.stage.Window.setShowing(Window.java:767)
      at javafx.stage.Window.show(Window.java:782)
      at javafx.stage.Stage.show(Stage.java:227)
      at ensemble.Ensemble2.start(Ensemble2.java:406)
      at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:315)
      at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:174)
      at com.sun.javafx.application.PlatformImpl$3.run(PlatformImpl.java:141)
      at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
      at com.sun.glass.ui.gtk.GtkApplication$2$1.run(GtkApplication.java:79)
      at java.lang.Thread.run(Thread.java:722)
      Aborted (core dumped)

      It looks like the GTK port makes extensive use of a stored JNIEnv "mainEnv" that is used for many JNI operations. The JNI specification obviously does not allow using JNIEnv from another thread, but does appear to allow storing it and re-using it in future JNI calls in the same thread. In this case, either mainEnv is used from the wrong thread or -Xcheck:jni is too picky. Either way it would help to be able to run with -Xcheck:jni.

            msladecek Martin Sládeček
            dblaukop Daniel Blaukopf (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: