On Sat, 5 Sep 2026 03:42:54 GMT, Michael Strauß <[email protected]> wrote:
>> John Hendrikx has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Remove whitespace > > modules/javafx.graphics/src/main/native-prism-sw/JJavaSurface.c line 163: > >> 161: >> 162: surface->super.data = (void *)((jint *)surface->super.data + >> 163: (*env)->GetIntField(env, surfaceHandle, >> fieldIds[SURFACE_DATA_OFFSET])); > > This might violate the contract of > [GetPrimitiveArrayCritical](https://docs.oracle.com/en/java/javase/26/docs/specs/jni/functions.html#getprimitivearraycritical-releaseprimitivearraycritical) > in two ways: > 1. "Inside a critical region, native code must not call other JNI functions", > but you're calling `GetIntField`. > 2. The pointer passed to `ReleasePrimitiveArrayCritical` must be the exact > pointer as returned by `GetPrimitiveArrayCritical`, you can't do pointer > arithmetic with it. > > A solution could be to read the data offset before entering the critical > region, retain the original base pointer separately, use base + offset only > as the renderer pointer, and then pass the base pointer to > `ReleasePrimitiveArrayCritical`. Thanks, I've fixed this, my JNI/C is a bit rusty. I did some investigation, and it seems at least Hot Spot doesn't care what pointer you pass it -- I was a bit surprised it worked at all (I do have a Java based test that covers this). I also fixed the potential div by zero there now (for some reason surfaces allow width/height of 0) and cleaned it up a bit since there is an almost exact copy in JDirectBufferSurface.c ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1969#discussion_r3939993782
