On Wed, 23 Jun 2021 09:19:16 GMT, Maxim Kartashev 
<github.com+28651297+mkartas...@openjdk.org> wrote:

> Added an `ExceptionCheck()` followed by `ExceptionDescribe()` and 
> `ExceptionClear()` immediately after the Java calls made from the callback 
> function `ReadTTFontFileFunc()` in `freetypeScaler.c`. 
> 
> The exception(s) need to be cleared because we're not returning immediately 
> to Java that would've been able to handle them gracefully. And in order not 
> to loose the exception entirely (even though the return value would also 
> indicate an error condition), print out the exception with 
> `ExceptionDescribe()` to aid in debugging.

src/java.desktop/share/native/libfontmanager/freetypeScaler.c line 146:

> 144:     freeNativeResources(env, scalerInfo);
> 145:     (*env)->CallVoidMethod(env, scaler, invalidateScalerMID);
> 146:     // NB: Exceptions must not be cleared (and therefore no JNI calls 
> performed) after calling this method

Please split long lines to 80 chars per line

src/java.desktop/share/native/libfontmanager/freetypeScaler.c line 199:

> 197:                                           bBuffer, offset, numBytes);
> 198:             // This is a callback, we are not returning immediately to 
> Java and better report exceptions now
> 199:             CHECK_EXCEPTION(env);

Probably we should report it only if "debugFonts" was set?

test/jdk/java/awt/font/JNICheck/FreeTypeScalerJNICheck.java line 28:

> 26:  * @bug 8269223
> 27:  * @summary Verifies that -Xcheck:jni issues no warnings from 
> freetypeScaler.c
> 28:  * @requires os.family == "linux"

Can we run this test on all platforms? Since this bug was not found, means we 
did not cover this code by the tests, and it will be useful to test it even if 
the code path will be different on other platforms.

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

PR: https://git.openjdk.java.net/jdk/pull/4572

Reply via email to