RFR: 8181084: JavaFX show big icons in system menu on macOS with Retina display [v5]

Jose Pereda jpereda at openjdk.org
Mon Jul 25 12:41:14 UTC 2022


On Mon, 25 Jul 2022 12:22:50 GMT, Paul <duke at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/native-glass/mac/GlassMenu.m line 267:
>> 
>>> 265:             jclass pixelsClass = (*env)->FindClass(env, "com/sun/glass/ui/mac/MacPixels");
>>> 266: 
>>> 267:             jfieldID jPixelsWidthField = (*env)->GetFieldID(env, pixelsClass, "width", "I");
>> 
>> After each JNI call you need to check for exceptions like:
>> 
>> jfieldID jPixelsWidthField = (*env)->GetFieldID...
>> if ((*env)->ExceptionCheck(env)) return;
>
> Thanks @jperedadnr.
> The last line inside that if block is `[image release]`. I am assuming that this is a memory cleanup from `(*env)->CallVoidMethod(env, pixels, jPixelsAttachData, ptr_to_jlong(&image));`. 
> 
> If I am adding the `ExceptionCheck` after each JNI call, should I make my block:-
> 
> jfloat scaley = (*env)->GetFloatField(env, pixels, jPixelsScaleYField);
> if ((*env)->ExceptionCheck(env)) {
>     [image release];
>     return;
> }

You can apply the checks only when you get the jclass and jfields in `initIDs`. 
Then you can simply add an if that verifies that jPixelsXXXField > 0 before getting the jint/jfloat values.

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

PR: https://git.openjdk.org/jfx/pull/743


More information about the openjfx-dev mailing list