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

JavaFX native libraries are written with JNI misuses.


    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.0
    • Component/s: javafx
    • Environment:

      i'm running on windows but i don't think it is relevant


      related to this thread: https://forums.oracle.com/forums/thread.jspa?threadID=2265086&messageID=9810375


      I've tried to simplify the problem, if i want to load a resource into the AudioClip method from a jar file and run it i get this error below
      i only see the error when running it with -Xcheck:jni enabled, otherwise you just get a "file not found" error



      package hh;

      import javafx.scene.Group;
      import javafx.scene.control.Label;
      import javafx.scene.media.AudioClip;

      import java.io.File;
      import java.net.URL;

      public class TestDialog extends Group {

          public TestDialog() {
              Label x = new Label("test");
              x.setPrefSize(50, 50);

          private void play(String resourcePath) {

              try {
                  URL url = null;
                  if (resourcePath.startsWith("http:") || resourcePath.startsWith("file:")) {
                      url = new URL(resourcePath);
                  } else {
                      ClassLoader loader = Main.class.getClassLoader();
                      url = loader.getResource(resourcePath);
                  if (url == null) {
                      File file = new File(resourcePath);
                      url = file.toURI().toURL();

                  AudioClip audioClip = new AudioClip(url.toExternalForm());

              } catch (Throwable t) {


      We have found a root cause of the problem. JavaFX native libraries are
      written with JNI misuses. If you are enable -Xcheck:jni for running your
      example on Oracle HotSpot JVM, you will get multiple warnings like:

      WARNING in native method: JNI call made with exception pending

      So formally, there is no bug in Excelsior JET but in JavaFX library.
      Nevertheless, we have fixed this problem emulating HotSpot behavior in
      this case to make this sample working on our JVM as well.


      so when i add this xcheck argument i get this

      WARNING in native method: JNI call made with exception pending
      at com.sun.media.jfxmediaimpl.NativeMedia.nativeInitNativeMedia(Native Method)
      at com.sun.media.jfxmediaimpl.NativeMedia.<init>(NativeMedia.java:137)
      at com.sun.media.jfxmediaimpl.NativeMediaPlayer.<init>(NativeMediaPlayer.java:243)
      at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:197)
      at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:131)
      at com.sun.media.jfxmediaimpl.NativeMediaAudioClipPlayer.play(NativeMediaAudioClipPlayer.java:274)
      - locked <0x24581018> (a com.sun.media.jfxmediaimpl.NativeMediaAudioClipPlayer)
      at com.sun.media.jfxmediaimpl.NativeMediaAudioClipPlayer.clipScheduler(NativeMediaAudioClipPlayer.java:68)
      at com.sun.media.jfxmediaimpl.NativeMediaAudioClipPlayer.access$000(NativeMediaAudioClipPlayer.java:25)
      at com.sun.media.jfxmediaimpl.NativeMediaAudioClipPlayer$1.run(NativeMediaAudioClipPlayer.java:86)
      at java.lang.Thread.run(Thread.java:662)


        1. test.part1.rar
          9.54 MB
        2. test.part2.rar
          9.54 MB
        3. test.part3.rar
          9.54 MB
        4. test.part4.rar
          1.27 MB



            • Assignee:
              almatvee Alexander Matveev
              mortiasjfx mortias (Inactive)
            • Votes:
              1 Vote for this issue
              2 Start watching this issue


              • Created: