On my Android installation with -Xcheck:jni enabled, it will abort with the error "JNI ERROR: non-nullable address is NULL". In other cases the behaviour is undefined.
Fix: check for zero-length C++ buffer and in that case use an empty Java array-backed ByteBuffer to pass to the Java deserializer.
Protobuf objects that contain only empty or default values take up zero bytes on the wire. In this case the JNI fromCpp() marshaller will try to map a DirectByteBuffer onto a zero-length nullptr C++ buffer, which is forbidden (https://docs.oracle.com/en/java/javase/20/docs/specs/jni/functions.html#newdirectbytebuffer).
On my Android installation with -Xcheck:jni enabled, it will abort with the error "JNI ERROR: non-nullable address is NULL". In other cases the behaviour is undefined.
Fix: check for zero-length C++ buffer and in that case use an empty Java array-backed ByteBuffer to pass to the Java deserializer.