By requiring the client to provide a buffer of a known type. It is generally not advisable to provide methods that take a Buffer as a parameter because it could some crazy subclass of Buffer which you haven’t anticipated such as CharBuffer or LongBuffer.
At the very least, require a ByteBuffer as your parameters, and then you can turn it directly into a FloatBuffer or IntBuffer or whatever as required. But Buffer as an argument is a very poor choice.
Cas