On 02/17/2015 10:15 AM, Florian Weimer wrote: > On 02/17/2015 11:00 AM, Andrew Haley wrote: >> On 02/17/2015 09:39 AM, Florian Weimer wrote: >>> On 02/14/2015 01:09 AM, John Rose wrote: >>>> These queries need to go into Unsafe. >>>> We also need Unsafe.getIntMisaligned, etc., which wire through to whatever >>>> second-best mechanism the platform offers. >>> >>> The safe variants should go into the java.lang.Integer etc. classes >>> IMHO. Even the JDK has quite a few uses for them (particularly the >>> big endian variant). Putting that into Unsafe only encourages >>> further use of Unsafe from application code. >> >> They'll all be visible as ByteBuffer methods, which should be enough >> for application code, shouldn't it? I'm not sure how much sense it >> makes to put them into java.lang.Integer etc. > > You'll still have to allocate a wrapping ByteBuffer object to use them. > I expect that makes them unattractive in many cases.
Hmm. I'm having a hard time trying to understand why. If you need to do a lot of accesses the allocation of the ByteBuffer won't be significant; if you don't need to do a lot of accesses it won't matter either. Andrew.