RFR: 8301302: Platform preferences API [v34]

Michael Strauß mstrauss at openjdk.org
Sat Dec 2 01:01:19 UTC 2023


On Thu, 30 Nov 2023 22:54:02 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> Michael Strauß has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   initialize field with NULL
>
> modules/javafx.graphics/src/main/native-glass/gtk/PlatformSupport.cpp line 68:
> 
>> 66: jobject PlatformSupport::collectPreferences() const {
>> 67:     jobject prefs = env->NewObject(jHashMapCls, jHashMapInit);
>> 68:     if (EXCEPTION_OCCURED(env)) return NULL;
> 
> You should also check for `prefs == NULL` (or `!prefs` as you prefer);

Is that necessary? The JNI documentation for `NewObject` states: "Returns a Java object, or NULL if the object cannot be constructed."
Is there a non-exceptional way to _not_ construct an instance of a class?

> modules/javafx.graphics/src/main/native-glass/gtk/PlatformSupport.cpp line 70:
> 
>> 68:     if (EXCEPTION_OCCURED(env)) return NULL;
>> 69: 
>> 70:     GtkStyle* style = gtk_style_new();
> 
> Can `gtk_style_new` return NULL?

It's not specified to do so. Internally, it will call `g_object_new`, which is also not specified to return null. I've found some evidence on some gnome.org blog that it will not ever return null, but I haven't looked further than that.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1014#discussion_r1412689129
PR Review Comment: https://git.openjdk.org/jfx/pull/1014#discussion_r1412688694


More information about the openjfx-dev mailing list