src: update Java and C++ FFI to use `self`