diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/core/ByteBufferArrayBuffer.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/core/ByteBufferArrayBuffer.hpp index fa79c2b7..9d504798 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/core/ByteBufferArrayBuffer.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/core/ByteBufferArrayBuffer.hpp @@ -36,7 +36,7 @@ class ByteBufferArrayBuffer final : public ArrayBuffer { } public: - [[nodiscard]] jni::alias_ref getBuffer() const { + [[nodiscard]] const jni::global_ref& getBuffer() const { return _byteBuffer; } diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/core/JArrayBuffer.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/core/JArrayBuffer.hpp index 61da1fe1..34712073 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/core/JArrayBuffer.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/core/JArrayBuffer.hpp @@ -68,11 +68,11 @@ class JArrayBuffer final : public jni::HybridClass { * `ByteBuffer`. In this case, `getBuffer()` will **copy** the data into a new `ByteBuffer` if * `copyIfNeeded` is `true`, and **wrap** the data into a new `ByteBuffer` if `copyIfNeeded` is false. */ - jni::alias_ref getByteBuffer(bool copyIfNeeded) { + jni::local_ref getByteBuffer(bool copyIfNeeded) { auto byteBufferArrayBuffer = std::dynamic_pointer_cast(_arrayBuffer); if (byteBufferArrayBuffer != nullptr) { // It is a `ByteBufferArrayBuffer`, which has a `ByteBuffer` underneath! - return byteBufferArrayBuffer->getBuffer(); + return jni::make_local(byteBufferArrayBuffer->getBuffer()); } else { // It is a different kind of `ArrayBuffer`, we need to copy or wrap the data. size_t size = _arrayBuffer->size();