RFR: 8301302: Platform preferences API [v30]

John Hendrikx jhendrikx at openjdk.org
Fri Nov 24 22:01:47 UTC 2023


On Fri, 24 Nov 2023 18:07:01 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/com/sun/glass/ui/Application.java line 793:
>> 
>>> 791:      * Returns a mapping of platform-specific keys to the types of their values.
>>> 792:      * Polymorphic types are supported by specifying the common base type; for example, a key can
>>> 793:      * be mapped to {@code Paint.class} to support any type of paint.
>> 
>> May want to search for mentions of `Paint` now that its removed, and use a different example here.
>
> I think the example is probably one of the most practically relevant use cases, even though right now there aren't any mappings with a declared type of `Paint`.

Alright, just checking if you didn't forget this one :)

>> modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkApplication.java line 476:
>> 
>>> 474:     @Override
>>> 475:     public Map<String, String> getPlatformKeyMappings() {
>>> 476:         return Map.of(
>> 
>> IMHO this should be returned from a `private static final`
>
> I don't understand. This is an overridden method, do you propose to introduce another `private static final` method, and `getPlatformKeyMappings` then calls out to this other method?

I meant that it is a constant, which I think would be good to extract.  I think you may have mentioned it isn't called a whole lot, but recreating an immutable sometimes (large) map just seems unnecessary.

    private static final Map<String, String> MAPPINGS = Map.of(
        "GTK.theme_fg_color", "foregroundColor",
        "GTK.theme_bg_color", "backgroundColor"
    );

    @Override
    public Map<String, String> getPlatformKeyMappings() {
        return MAPPINGS;
    }

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1014#discussion_r1404656745
PR Review Comment: https://git.openjdk.org/jfx/pull/1014#discussion_r1404656228


More information about the openjfx-dev mailing list