Merging the MacOS X Port into HotSpot Express 23 (7098194)
john.r.rose at oracle.com
Thu Oct 13 16:50:43 PDT 2011
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.)
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.
grep -n 'print.*%ld' $(hg loc -I src) | wc
34 255 4004
grep -n 'print.*%d' $(hg loc -I src) | wc
2086 15753 236821
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the hotspot-dev