Hi Phil, 

The change looks fine for me.

Thanks,
Krishna

-----Original Message-----
From: Phil Race 
Sent: Friday, March 16, 2018 11:05 PM
To: awt-...@openjdk.java.net; swing-dev@openjdk.java.net
Subject: <AWT Dev> RFR: 8198649 : Switch AWT/Swing's default GTK version to 3

Bug: https://bugs.openjdk.java.net/browse/JDK-8198649
Webrev: http://cr.openjdk.java.net/~prr/8198649/

This is a very small change to switch the default GTK library loaded from GTK 
2.2 to GTK 3.

Both are supported as of JDK 9 but it still defaults to 2.2 and you use
jdk.gtk.version=3 to switch.

Since only one of these can be loaded a switch is necessary in case auto-detect 
fails or JDK get to load its version first, but making GTK3 load by default 
will help with SWT interop as shown here  where we load Swing's GTK L+F 
followed by SWT

---
import javax.swing.UIManager;
import org.eclipse.swt.widgets.Display;

public class SWT_Swing {
  public static void main(String[] args) throws Exception { 
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
         Display display = new Display();
  }
}

--

/jdk9/bin/java -Djdk.gtk.verbose=true  -cp swt.jar:. SWT_Swing Looking for GTK2 
library...
GTK2 library loaded.

(java:21435): GLib-GObject-WARNING **: cannot register existing type 
'GdkDisplayManager'

(java:21435): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' 
failed

(java:21435): GLib-GObject-CRITICAL **: g_object_new: assertion 
'G_TYPE_IS_OBJECT (object_type)' failed

---

As you can see SWT now cannot work since JDK loaded GTK 2.2 by default and 
unlike JDK SWT has no detection code or automatic fall back

But with the proposed change we get no error :
~/jdk-11/build/linux-x86_64-normal-server-release/jdk/bin/java
-Djdk.gtk.verbose=true  -cp swt.jar:. SWT_Swing Looking for GTK3 library...
GTK3 library loaded.

Granted, the reverse problem would happen for apps that depend on GTK 2.2 but 
that is looking backwards ..

I have also run the SwingSet2 demo in the various cases and it is fine.

We expect to make the same switch for JavaFX.

-phil.



Reply via email to