diff --git a/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/ByteBuffer.h b/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/ByteBuffer.h index 21d17a27a..1e31d76cf 100644 --- a/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/ByteBuffer.h +++ b/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/ByteBuffer.h @@ -15,6 +15,13 @@ namespace facebook { namespace jni { +class JBuffer : public JavaClass { +public: + static constexpr const char* kJavaDescriptor = "Ljava/nio/Buffer;"; + + void rewind() const; +}; + // JNI's NIO support has some awkward preconditions and error reporting. This // class provides much more user-friendly access. class FBEXPORT JByteBuffer : public JavaClass { diff --git a/ReactAndroid/src/main/jni/first-party/fb/jni/ByteBuffer.cpp b/ReactAndroid/src/main/jni/first-party/fb/jni/ByteBuffer.cpp index 5a5317f9f..806093027 100644 --- a/ReactAndroid/src/main/jni/first-party/fb/jni/ByteBuffer.cpp +++ b/ReactAndroid/src/main/jni/first-party/fb/jni/ByteBuffer.cpp @@ -22,6 +22,11 @@ local_ref createEmpty() { } } +void JBuffer::rewind() const { + static auto meth = javaClassStatic()->getMethod()>("rewind"); + meth(self()); +} + local_ref JByteBuffer::wrapBytes(uint8_t* data, size_t size) { // env->NewDirectByteBuffer requires that size is positive. Android's // dalvik returns an invalid result and Android's art aborts if size == 0.