Svoboda | Graniru | BBC Russia | Golosameriki | Facebook

JEP 283: Enable GTK 3 on Linux

Authorddhill
OwnerDavid Hill
TypeFeature
ScopeJDK
StatusClosed / Delivered
Release9
Componentjavafx / window-toolkit
Discussionopenjfx dash dev at openjdk dot java dot net
EffortM
DurationM
Reviewed byDavid Hill, Jonathan Giles, Kevin Rushforth, Philip Race, Sergey Bylokhov, Victor Dyakov
Endorsed byKevin Rushforth
Created2015/12/16 16:42
Updated2018/10/12 21:18
Issue8145568

Summary

Enable Java graphical applications, whether based on JavaFX, Swing, or AWT, to use either GTK 2 or GTK 3 on Linux.

Goals

Non-Goals

Share the dynamic wrapper mechanisms between AWT/Swing and JavaFX.

Motivation

Java on Linux currently uses GTK 2. This raises several issues:

Description

Java graphics should be able to support both GTK 2 and GTK 3.

AWT and Swing currently use a dynamic lookup of the required GTK functions, instead of directly linking with the native libraries themselves.

JavaFX has employed a similar mechanism in other areas, and can employ a similar mechanism in the window management code when calling GTK.

This dynamic loading mechanism can be extended to select either GTK 2 or 3, hiding as much as possible, with wrapper functions, any significant programmatic differences. It is likely that there will be some programmatic issues that will need to be resolved; for example, differences in data structures, or different functions.

A system property will be used to influence the selection of GTK 2 or 3 at run time. By default, this property will indicate GTK 2 to reduce risk. If GTK 2 is not present on a system then the run time will automatically choose GTK 3. If the run time can detect the need to use GTK 3 in time, for example when FXCanvas is used with SWT, then the system property will automatically be set to GTK 3.

JavaFX interacts with AWT/Swing via JFXPanel, and uses AWT functionality for printing support. It is possible to implement just the GTK 2/3 support in JavaFX, but that will come with limitations on the types of applications that can be supported.

Major subtasks for AWT/Swing:

Subtasks for JavaFX:

Alternatives

Migrate Java graphics to support only GTK 3.

Pros:

Cons:

Testing

The existing system tests for Java on Linux should be used.

At a minimum, the non-default path (GTK 3) should be used (forced) on one or more test runs to verify that all passing tests continue to pass.

Risks and Assumptions

The primary risk for the proposed solution is that new bugs will be introduced that will not be caught by testing. AWT uses more features and so may be at a higher risk of adding new bugs due to GTK behavioral changes.

There is a risk that the AWT/Swing subtask or the JavaFX subtask will not be completed in time due to unforeseen technical difficulties.

If AWT/Swing cannot be completed, then this will pose run-time restrictions on JavaFX, but only for applications that mix the two. Primarily this will be applications that use JFXPanel or do printing.

If JavaFX cannot be completed then there will be run-time problems for applications that mix JavaFX and SWT (FXCanvas).