What's causing "Unable to retrieve native address from ByteBuffer object"?

Posted by r0u1i on Stack Overflow See other posts from Stack Overflow or by r0u1i
Published on 2010-12-26T16:38:49Z Indexed on 2010/12/26 16:53 UTC
Read the original article Hit count: 170

Filed under:
|
|

As a very novice Java programmer, I probably should not mess with that kind of things. Unfortunately, I'm using a library which have a method that accepts a ByteBuffer object and throws when I try to use it:

Exception in thread "main" java.lang.NullPointerException: Unable to retrieve native address from ByteBuffer object

Is it because I'm not using a non-direct buffer?

edit: There's not a lot of my code there. The library I'm using is jNetPcap, and I'm trying to dump a packet to file. My code takes an existing packet, and extract a ByteBuffer out of it:

        byte[] bytes = m_packet.getByteArray(0, m_packet.size());
    ByteBuffer buffer = ByteBuffer.wrap(bytes);

Then it calls on of the dump methods of jNetPcap that takes a ByteBuffer.

© Stack Overflow or respective owner

Related posts about java

Related posts about jni