Hi all,
We updated the target platform to 2021-09 for our Eclipse RCP application that uses JOGL (via Jzy3d) and found an issue. When JOGL's SWTAccessor class is loaded (for a NewtCanvasSWT or GLCanvas), it initializes some field to point to methods in SWT's internal classes. The recent release of SWT 4.21 separated some gtk methods off to gtk3 and gtk4 specific bindings. This breaks the initialization code when looking for gtk_widget_get_window. The patch below fixes this. I can provide a PR on https://github.com/sgothel/jogl if that's more convenient. Best regards, Peter ---8<--- --- SWTAccessor.java.orig 2022-02-16 10:22:07.702204475 +0000 +++ SWTAccessor.java 2022-02-16 10:25:38.589674850 +0000 @@ -95,6 +95,7 @@ private static final String str_OS_gtk_class = "org.eclipse.swt.internal.gtk.OS"; // used by earlier versions of SWT private static final String str_GTK_gtk_class = "org.eclipse.swt.internal.gtk.GTK"; // used by later versions of SWT + private static final String str_GTK3_gtk_class = "org.eclipse.swt.internal.gtk3.GTK3"; // used by later versions of SWT (4.21+) private static final String str_GDK_gtk_class = "org.eclipse.swt.internal.gtk.GDK"; // used by later versions of SWT public static final Class<?> OS_gtk_class; private static final String str_OS_gtk_version = "GTK_VERSION"; @@ -124,6 +125,8 @@ private static final String str_gdk_window_set_back_pixmap = "gdk_window_set_back_pixmap"; private static final String str_gdk_window_set_background_pattern = "gdk_window_set_background_pattern"; + private static final int SWT_VERSION_4_21 = 4946; + private static final VersionNumber GTK_VERSION_2_14_0 = new VersionNumber(2, 14, 0); private static final VersionNumber GTK_VERSION_2_24_0 = new VersionNumber(2, 24, 0); private static final VersionNumber GTK_VERSION_2_90_0 = new VersionNumber(2, 90, 0); @@ -261,7 +264,12 @@ _gtk_version = GTK_VERSION(field_OS_gtk_version.getInt(null)); m1 = cGTK.getDeclaredMethod(str_gtk_widget_realize, handleType); if (_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0) { - m4 = cGTK.getDeclaredMethod(str_gtk_widget_get_window, handleType); + if (SWT.getVersion() < SWT_VERSION_4_21) { + m4 = cGTK.getDeclaredMethod(str_gtk_widget_get_window, handleType); + } else { + Class<?> cGTK3 = ReflectionUtil.getClass(str_GTK3_gtk_class, false, cl); + m4 = cGTK3.getDeclaredMethod(str_gtk_widget_get_window, handleType); + } } else { m3 = cGTK.getDeclaredMethod(str_GTK_WIDGET_WINDOW, handleType); } ---8<--- |
Thanks for sharing this.
When I added natives for M1 / ARM64, I also had to add this SWT jar. Were you able to build and run without updating any SWT jar? Without any promise, there is a chance I rebuild JOGL soon. Having your PR on https://github.com/jzy3d/jogl would be helpful to integrate it in this release, so do not hesitate to push your work there. |
This post was updated on .
It works in a simple JUnit test but not in a plugin test owing to the Equinox class loader not finding the gtk3 package. I think the SWT gtk jar needs to export org.eclipse.swt.internal.gtk3.
Edit: here's the upstream bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=577874 |
Hi Peter,
Now that the upstream bug in SWT allows you to test your patch, does it work in a "regular" Equinox plugins scenario ? And if so, have you been able to regenerate JOGL ? Or how do you plan to use your fix ? Any information appreciated as I am facing the exact same issue, and i have not decided yet what to do (wait for an "official" 2.4 release, use an "unofficial build" like the one produced by Martin, build our own versions... ?) Cheers Alexis |
Hi,
Just to report that I have been able to run JOGL on Eclipse 4.23 (2022-03) using the fix posted by Peter. Being in a regular Equinox/OSGI environment, I only had to duplicate SWTAcccessor.java, fix it, add it to the sources of the plugin where the JOGL libraries reside and voila ! this class is loaded by the ClassLoader instead of the one buried in JOGL jars. Obviously a temporary solution, but better than nothing for those who do not want to recompile JOGL or wait for a new version... Thanks guys ! Alexis |
In reply to this post by PeterC-DLS
I had the same error on Ubuntu, Eclipse 4.23 and successfully applied your patch after reading this post.
So a big thank you from my side! |
In reply to this post by Alexis Drogoul
Hi all,
Thanks for the feedback. I've add a PR sgothel/jogl#108.
Best regards,
Peter
|
Administrator
|
It's not the right place to fill bug reports, Github is only used as a mirror. You have to fill a bug report here:
https://jogamp.org/bugzilla/ If you don't have an account, contact me in private, I'll create one for you.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |