On Tue, 30 Jan 2024 14:03:39 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

> Now that I re-read the problem statement and the exception handling JNI, the 
> fix doesn't look correct to me.
> 
> What does the warning say?
> 
> > WARNING in native method: JNI call made without checking exceptions when 
> > required to from `CallStaticVoidMethodV` at 
> > `sun.awt.Win32GraphicsEnvironment.initDisplay`
> 
> To me, it means that `Win32GraphicsEnvironment.initDisplay` is the problem. 
> You found that `DWMIsCompositionEnabled` calls a static method via 
> `JNU_CallStaticMethodByName`.
> 
> As far as I can see, it's the last statement of the `DWMIsCompositionEnabled` 
> function.
> 
> Then `Java_sun_awt_Win32GraphicsEnvironment_initDisplay` calls `initScreens` 
> which, seemingly, can call other JNI methods.
> 

Well, yes - however the initScreens only calls other JNI methods through the 
assert callback of debug builds, so not a general thing. The initial proposal 
for a fix was to add an exception check right to the call of 
[JNU_CallStaticMethodByName(...,"dwmCompositionChanged",...)](https://github.com/openjdk/jdk/pull/17404/commits/32128744252d75104e0d19f5eb701ffdc7b3d417)
 but was dismissed by @prrace 

I think the current proposal makes the assertion callback more resilient to JNI 
warnings in general, so I guess it's not bad.

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

PR Comment: https://git.openjdk.org/jdk/pull/17404#issuecomment-1918464139

Reply via email to