-
Bug
-
Resolution: Fixed
-
P3
-
fx2.0
-
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
Hello,
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
regards,
-----------------------
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);
play("hh/music/test.mp3");
getChildren().add(x);
}
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();
}
System.out.println(url.toExternalForm());
AudioClip audioClip = new AudioClip(url.toExternalForm());
audioClip.play();
} catch (Throwable t) {
t.printStackTrace();
}
}
}
-----------------------
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
file:/C:/java/HeavenHell/out/production/HeavenHell/hh/resources/music/test.mp3
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)
Hello,
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
regards,
-----------------------
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);
play("hh/music/test.mp3");
getChildren().add(x);
}
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();
}
System.out.println(url.toExternalForm());
AudioClip audioClip = new AudioClip(url.toExternalForm());
audioClip.play();
} catch (Throwable t) {
t.printStackTrace();
}
}
}
-----------------------
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
file:/C:/java/HeavenHell/out/production/HeavenHell/hh/resources/music/test.mp3
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)