jni: fix startup crash

This is the same change as mainline 49ccdbae.