RFR 8074067: Cleanup in java.base/share/native/libjava/Bits.c

Martin Buchholz martinrb at google.com
Tue Mar 3 09:23:04 UTC 2015


On Tue, Mar 3, 2015 at 12:15 AM, Ivan Gerasimov <ivan.gerasimov at oracle.com>
wrote:

>  Thanks Martin for the suggestion!
>
> On 03.03.2015 0:08, Martin Buchholz wrote:
>
> slightly safer (more likely to compile everywhere) might be to convert
> input length into a size_t immediately and to
>
>  I'm not quite sure it would be correct.
> If size_t happens to be 32-bit int, then the length could overflow, since
> it represents the size of the array in bytes, while we're operating on the
> the array of shorts, ints and longs.
> I would feel more comfortable if length gets cast to size_t only when it
> is guaranteed to be in the range (0, 1048576).
>
>
Sounds good to me!
It's still good practice to have both branches of a ternary expression have
the same signedness.

BTW, it seems those static native methods like copyFromShortArray should
have a jclass clazz second arg, not a jobject this.



More information about the core-libs-dev mailing list