Open gissuebot opened 10 years ago
Original comment posted by kevinb@google.com on 2011-07-28 at 08:35 PM
(Reported by estaub2).
I would consider Primitives.bytes() but leave the *8 to the caller for bits.
The question is who would use it and why?
Original comment posted by esta...@comcast.net on 2011-07-28 at 11:02 PM
who would use it and why?
It might be used by anyone who needs to rapidly hard-allocate space for primitives and needs to do it in a generic way - possibly driven by reflection, for instance. While nio makes this less frequently needed, with Byte/Char/...*Buffer, et al, it's still sometimes necessary - for instance, when byte-ordering is important. It's possible that this kind of low-level code is either too rare or outside the Guava "sweet spot" - it was just a thought!
If it does seem worth doing, I'd extend the original suggestion to handle the "dummy" classes returned by reflection for unwrapped primitives, as well as the wrappers - both "long.class" and "Long.class".
Original comment posted by fry@google.com on 2011-12-10 at 04:13 PM
(No comment entered for this change.)
Labels: Package-Primitives
Original comment posted by fry@google.com on 2012-02-16 at 07:17 PM
(No comment entered for this change.)
Status: Acknowledged
Original comment posted by kevinb@google.com on 2012-05-30 at 07:43 PM
(No comment entered for this change.)
Labels: -Type-Enhancement
, Type-Addition
Original comment posted by kevinb@google.com on 2012-06-22 at 06:16 PM
(No comment entered for this change.)
Status: Research
@kevinb9n does this meet the low bar that we set for primitives/math code that is mathematically defined?
Original issue created by fry@google.com on 2011-07-28 at 05:30 PM
The Primitives class itself could use static int bits(Class clazz) static int bytes(Class clazz) which would throw on a class that isn't a JDK primitive wrapper.
FWIW, see http://stackoverflow.com/questions/6766343/best-practice-for-getting-datatype-sizesizeof-in-java/6772163#6772163 for what motivated me to write.