Merging the MacOS X Port into HotSpot Express 23 (7098194)

David Holmes david.holmes at oracle.com
Thu Oct 13 17:43:23 PDT 2011


On 14/10/2011 9:50 AM, John Rose wrote:
> On Oct 13, 2011, at 2:53 PM, David Holmes wrote:
>
>> Paul mis-spoke when he said "There should be no direct uses of
>> printf format specifiers in Hotspot code," as the code is absolutely
>> full of them, as you would expect. We should always use %d for int and
>> jint types, %ld for longs, and should only need macros for typedef'd
>> types (pointers, jlongs, potentially unsigned values) that might be
>> different on different platforms/compilers..
>
> I agree about %d, %s, etc.
>
> But let's make a distinction about %ld. Naked use of the C type "long"
> is a portability trap, and should not be in our code unless there is
> strong requirement. (The old style pages say something about this, FWIW.)

Yes you are absolutely right. We shouldn't be using "long" types in the 
first place.

David

> In Hotspot code there are approximately 30 uses of print format strings
> of the form %ld. That qualifies as a rarity, compared with the
> corresponding 2000 uses of the string %d. (See below.) Let's continue to
> make "long" and "%ld" be rare in our source base.
>
> -- John
>
> --------
> grep -n 'print.*%ld' $(hg loc -I src) | wc
> 34 255 4004
> --------
> grep -n 'print.*%d' $(hg loc -I src) | wc
> 2086 15753 236821
> --------
>
>


More information about the hotspot-dev mailing list