JDK-6953275 : Many Swing tests are failing because of a GTK lib
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P1
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris
  • CPU: generic,sparc
  • Submitted: 2010-05-18
  • Updated: 2013-12-10
  • Resolved: 2010-05-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b94Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
Many of the functional Swing tests are failing in Solaris when GTK look and feel is used.  Few regression tests also failed for the same reason. 

Also could be reproduced using SwingSet2

To Reproduce:

1. Run SwingSet2 using the PIT build (7 b94)
2. Switch to the GTK look and Feel
3. Notice the following messages on the console / terminal

dtftest@sfsparc001:...laris_sparc/demo/jfc/SwingSet2$ ../../../bin/java -jar SwingSet2.jar
Exception in thread "AWT-EventQueue-0" java.lang.InternalError: Unable to load native GTK libraries
	at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initialize(GTKLookAndFeel.java:1447)
	at javax.swing.UIManager.setLookAndFeel(UIManager.java:531)
	at javax.swing.UIManager.setLookAndFeel(UIManager.java:576)
	at SwingSet2.updateLookAndFeel(SwingSet2.java:1017)
	at SwingSet2.setLookAndFeel(SwingSet2.java:982)
	at SwingSet2$ChangeLookAndFeelAction.actionPerformed(SwingSet2.java:1169)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2015)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2338)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
	at javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:308)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
	at java.awt.Component.processMouseEvent(Component.java:6434)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
	at java.awt.Component.processEvent(Component.java:6199)
	at java.awt.Container.processEvent(Container.java:2203)
	at java.awt.Component.dispatchEventImpl(Component.java:4790)
	at java.awt.Container.dispatchEventImpl(Container.java:2261)
	at java.awt.Component.dispatchEvent(Component.java:4616)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4803)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4463)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4393)
	at java.awt.Container.dispatchEventImpl(Container.java:2247)
	at java.awt.Window.dispatchEventImpl(Window.java:2671)
	at java.awt.Component.dispatchEvent(Component.java:4616)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:651)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:255)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:170)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:160)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:155)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:136)

Comments
SUGGESTED FIX --- old/src/solaris/native/sun/awt/gtk2_interface.c 2010-05-18 18:27:26.000000000 +0400 +++ new/src/solaris/native/sun/awt/gtk2_interface.c 2010-05-18 18:27:26.000000000 +0400 @@ -77,6 +77,7 @@ static void *gtk2_libhandle = NULL; static void *gthread_libhandle = NULL; +static gboolean flag_g_thread_get_initialized = FALSE; static jmp_buf j; /* Widgets */ @@ -436,8 +437,10 @@ fp_gtk_file_chooser_set_filter = dl_symbol("gtk_file_chooser_set_filter"); fp_gtk_file_chooser_get_type = dl_symbol("gtk_file_chooser_get_type"); fp_gtk_file_filter_new = dl_symbol("gtk_file_filter_new"); - fp_gtk_file_chooser_set_do_overwrite_confirmation = dl_symbol( - "gtk_file_chooser_set_do_overwrite_confirmation"); + if (fp_gtk_check_version(2, 8, 0) == NULL) { + fp_gtk_file_chooser_set_do_overwrite_confirmation = dl_symbol( + "gtk_file_chooser_set_do_overwrite_confirmation"); + } fp_gtk_file_chooser_set_select_multiple = dl_symbol( "gtk_file_chooser_set_select_multiple"); fp_gtk_file_chooser_get_current_folder = dl_symbol( @@ -641,8 +644,6 @@ /** * GLib thread system */ - fp_g_thread_get_initialized = dl_symbol_gthread( - "g_thread_get_initialized"); fp_g_thread_init = dl_symbol_gthread("g_thread_init"); fp_gdk_threads_init = dl_symbol("gdk_threads_init"); fp_gdk_threads_enter = dl_symbol("gdk_threads_enter"); @@ -744,7 +745,9 @@ if (fp_gtk_check_version(2, 2, 0) == NULL) { // Init the thread system to use GLib in a thread-safe mode - if (!fp_g_thread_get_initialized()) { + if (!flag_g_thread_get_initialized) { + flag_g_thread_get_initialized = TRUE; + fp_g_thread_init(NULL); //According the GTK documentation, gdk_threads_init() should be --- old/src/solaris/native/sun/awt/gtk2_interface.h 2010-05-18 18:27:28.000000000 +0400 +++ new/src/solaris/native/sun/awt/gtk2_interface.h 2010-05-18 18:27:27.000000000 +0400 @@ -786,7 +786,6 @@ guint (*fp_gtk_main_level)(void); -gboolean (*fp_g_thread_get_initialized)(void); void (*fp_g_thread_init)(GThreadFunctions *vtable); void (*fp_gdk_threads_init)(void); void (*fp_gdk_threads_enter)(void);
18-05-2010

EVALUATION Also, the gtk_file_chooser_set_do_overwrite_confirmation() is available since GTK 2.8 only.
18-05-2010

EVALUATION The fix for 6913179 introduced support for native GTK FileDialog. However, it also requires some functions from the libgthreads library that actually exist in newer versions of GTK only. For instance, the g_thread_get_initialized symbol is requested while it's only available since gtk 2.20. Since this function gets invoked when the GTK is initialized by JDK, the initialization fails, and any Swing application requesting the GTK L&F fails. Probably we should create a boolean flag indicating whether the GTK has already been initialized, rather than relying on a function that is only available in latest GTK versions.
18-05-2010

EVALUATION seems to be a regression of 6913179
18-05-2010