<AWT Dev> [9] Review request: new macro for conversion to jboolean

Phil Race philip.race at oracle.com
Wed Mar 19 20:08:26 UTC 2014


PS .. so maybe whilst you are touching this file you could do
#define JNU_CHECK_NULL CHECK_NULL
#define JNU_CHECK_NULL_RETURN CHECK_NULL_RETURN

so we could migrate to these (clearer) ones

-phil.

On 3/19/2014 1:05 PM, Phil Race wrote:
> I think having it start with "JNU_" is a good suggestion.
> I've been wondering over the last week or so if it would not have been
> better to have CHECK_NULL called JNU_CHECK_NULL to reduce collision 
> chances
> and to make it clearer where it comes from ..
>
> -phil.
>
> On 3/19/2014 12:49 PM, Mike Duigou wrote:
>> Definitely a useful macro.
>>
>> I too would prefer a name like TO_JBOOLEAN since it reveals the 
>> result type. Also all uppercase to identify it as a macro. If we are 
>> paranoid and want to reduce the chance of a name collision then 
>> JNU_TO_JBOOLEAN perhaps.
>>
>> I would also define the macro as:
>>
>> #define JNU_TO_JBOOLEAN(obj) (jboolean) ((obj) ? JNI_TRUE : JNI_FALSE)
>>
>> so that the type of the result is explicit. Unfortunately jni.h 
>> doesn't define JNI_TRUE or false with a cast to jboolean as they 
>> probably should.
>>
>> Mike
>>
>> On Mar 19 2014, at 11:36 , Sergey Bylokhov 
>> <sergey.bylokhov at oracle.com> wrote:
>>
>>> Thanks Anthony!
>>>
>>> Can somebody from the core-libs team take a look?
>>>
>>> On 3/17/14 10:31 PM, Anthony Petrov wrote:
>>>> Personally, I'd call it to_jboolean(obj), but IS_TRUE(obj) sounds 
>>>> good to me too. Either way, I'm fine with the fix.
>>>>
>>>> -- 
>>>> best regards,
>>>> Anthony
>>>>
>>>> On 3/17/2014 7:01 PM, Sergey Bylokhov wrote:
>>>>> Hello.
>>>>> This review request is for the new macro, which simplify 
>>>>> conversion to
>>>>> jboolean. It will be useful for fixing parfait warnings.
>>>>>
>>>>> We have a lot of places, where we cast some type to jboolean:
>>>>>
>>>>> BOOL = retVal;
>>>>> return (jboolean) retVal;
>>>>>
>>>>> WARNING: Expecting value of JNI primitive type jboolean: mismatched
>>>>> value retVal with size 32 bits, retVal used for conversion to int8 
>>>>> in return
>>>>>
>>>>>
>>>>> +++ b/src/share/native/common/jni_util.h    Mon Mar 17 18:28:48 
>>>>> 2014 +0400
>>>>> @@ -277,6 +277,7 @@
>>>>>
>>>>>   #define IS_NULL(obj) ((obj) == NULL)
>>>>>   #define JNU_IsNull(env,obj) ((obj) == NULL)
>>>>> +#define IS_TRUE(obj) ((obj) ? JNI_TRUE : JNI_FALSE)
>>>>>
>>>>> I am not sure about the name, probably someone have a better 
>>>>> suggestion?
>>>>>
>>>>> The fix is for jdk9/dev.
>>>>>
>>>>> -- 
>>>>> Best regards, Sergey.
>>>>>
>>>
>>> -- 
>>> Best regards, Sergey.
>>>
>




More information about the core-libs-dev mailing list