-
-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replacements needed for the last vestiges of JNA #1107
Comments
Also need A robust replacement to get a Windows registry key is also needed. |
In the short term, the JNA dependency is being factored to a separate module here: https://github.com/caprica/vlcj-legacy The goal is to replace those functions in the new FFI vlcj itself. |
For macos, here's some code I've tried and work for vlc well:
For jre8 and jre11, i'm using https://github.com/JetBrains/JetBrainsRuntime |
I had code similar to this a long time ago :-) But, aren't these still issues with such an approach?:
So I don't think a pure Java approach is really possible with modern JDK's is it? I was really hoping there could at least be an FFI approach, not using JNI, but from what I can see it simply is not possible to use libjawt without FFI. JNA uses JNI in its bespoke native library to get window handles, but I really don't want to do that. |
@acely Your macOS code on JDK 11, it can only work with AWT Window, right? Not Canvas? |
Yes, works on jdk11 ONLY with awt window, using this method Since this works with jdk11, I assume it will work for jdk 18 as well. But my os is too old to run jdk18, so cant test that(sad) |
I tried a reflection-based approach in JDK 18 and JDK 19ea and it did not work - it might work if you set all the right module command-line switches to open everything up, but that is not really a nice solution for developers using vlcj IMO. |
Agree, but just for fun I tried something, it works but not elegant at all.
The reason why I did not use I think maybe on macos we should use javafx instead. |
On macOS it will always be suboptimal no matter what you do simply because there is no AWT anymore. So on macOS, I agree, use JavaFX - or maybe the new OpenGL renderer, but I don't really want to use OpenGL to write vlcj applications. I'm all for alternate approaches, now (well, soon) that we have FFI I would be happy with any approach that used native code, as long it was callable via FFI. |
Maybe by asking in the jdk mailing lists or making an enhancement bugreport you can get it exposed if it's there anyway and it's useful. |
It's extremely unlikely this will ever be exposed by the JDK. This is viewed as a private internal implementation detail. I would have thought if it were possible/feasible, the JNA people would have already done this. |
May I ask why JNI is not an option? |
Well, it is, and that's what JNA uses. I do not want to use that because I don't want to build a native library and ship it with vlcj for all the various architectures. Ideally, you could use JNA itself or the new FFM API but the underlying API you need to grab the component id is accessed opaquely via a JVM pointer, you can't just execute native API calls against libjawt or whatever. Personally, I don't see the problem with the JVM/JDK exposing the native window handle - I mean I understand why they don't, it's an implementation detail, but I don't see the harm in exposing a read only handle with no guarantees. The JVM/JDK maintainers would disagree. |
For the FFI version of vlcj, one of the goals is to completely remove the JNA dependency.
One sticking point is going to be getting an adequate replacement for
Native.getComponentID()
. This is used to get a native window handle on at least Linux and Windows (macOS has many issues around this) that can be passed to the appropriate LibVLC native method to cause video to be rendered in the window referenced by that handle.That Java call has a native counterpart in JNA:
https://github.com/java-native-access/jna/blob/a0641dd928776a8e81478015a1f14a39326887f3/native/dispatch.c#L3061
An alternate solution that does not use JNA is needed.
JNI is not an option here, but of course we could now use FFI to get that handle... somehow...
The text was updated successfully, but these errors were encountered: