jboolean handling in native JDK code - was : RE: 8211163: UNIX version of Java_java_io_Console_echo does not return a clean boolean

Phil Race philip.race at oracle.com
Fri Sep 28 16:32:30 UTC 2018


_RequestWindowFocus is declared to return jboolean.

So I don't think there's a nasty bug, just a whole lot of casting which might
be better avoided by some additional overload of SyncCall() which accepts
the function's real signature.

-phil.


On 09/28/2018 07:04 AM, Andrew Haley wrote:
> On 09/28/2018 01:32 PM, Baesken, Matthias wrote:
>> Shouldn't we better compare  the  pointer to NULL   instead of just  casting ?
> Heavens, yes! You have found a nasty bug.
>
> Note that the cast to intptr_t used here suppresses the compiler
> warning which should have been a big clue that something was
> wrong. Good catch.
>
> 8198895: Compilation errors in java.desktop with VS 2017
>
> +++ b/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp     Mon Mar 19 14:16:23 2018 -0700
> @@ -3915,8 +3915,8 @@
>       rfs->component = selfGlobalRef;
>       rfs->isMouseEventCause = isMouseEventCause;
>
> -    return (jboolean)AwtToolkit::GetInstance().SyncCall(
> -        (void*(*)(void*))AwtWindow::_RequestWindowFocus, rfs);
> +    return (jboolean)((intptr_t)AwtToolkit::GetInstance().SyncCall(
> +        (void*(*)(void*))AwtWindow::_RequestWindowFocus, rfs));
>       // global refs and rfs are deleted in _RequestWindowFocus
>
>       CATCH_BAD_ALLOC_RET(JNI_FALSE);



More information about the jdk-dev mailing list