6 messages in net.java.dev.jna.usersRe: [jna-users] Getting MappedByteBuf...
FromSent OnAttachments
Stas OskinJun 17, 2009 4:19 pm 
Timothy WallJun 17, 2009 5:00 pm 
Stas OskinJun 20, 2009 11:41 am 
Timothy WallJun 20, 2009 12:06 pm 
Stas OskinJun 20, 2009 4:39 pm 
Timothy WallJun 20, 2009 9:12 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Getting MappedByteBuffer from Pointer?Actions...
From:Timothy Wall (twal@dev.java.net)
Date:Jun 20, 2009 9:12:27 pm
List:net.java.dev.jna.users

The ByteBuffer returned by Pointer.getByteBuffer (as well as that returned by ByteBuffer.allocateDirect()) gives you a DirectByteBuffer, which derives from MappedByteBuffer, so casting should work, although you should probably check the type to be sure before casting, since all VMs may not have the same implementation.

Whether casting is actually the right thing to do is a different question...

On Jun 20, 2009, at 7:39 PM, Stas Oskin wrote:

Hi.

Because the library I use accepts only the MappedByteBuffer type.

Regards.

2009/6/20 Timothy Wall <twal@dev.java.net>

On Jun 20, 2009, at 2:41 PM, Stas Oskin wrote:

Hi.

I'm using shared memory, and I need to provide pointer to shared memory segment in form of MappedByteBuffer.

Would typecasting ByteBuffer object to MappedByteBuffer do the trick?

The ByteBuffer you get from Pointer.getByteBuffer() is not a MappedByteBuffer, it is a direct ByteBuffer.

Do you already have the shared memory pointer? Why do you need a MappedByteBuffer type?

Thanks in advance!

2009/6/18 Timothy Wall <twal@dev.java.net> You can get a ByteBuffer from the Pointer via getDirectByteBuffer. What are you trying to do?

On Jun 17, 2009, at 7:20 PM, Stas Oskin wrote:

Hi.

Is there any good way to get a MappedByteBuffer from Pointer?

Thanks in advance!