Be careful with JVM library location while building JNI based code
In case you want to compile JNI based code on macOS, be careful. Pay attention to @rpath.
If you compile the code like this
ld -L${JAVA_HOME}/lib/server -ljvm ...
you will end up with reference to /usr/local/lib/libjvm.dylib. You may face lots of issues related to incorrect `JVM` version used while linking `JNI`.
If you want to make sure that your code is properly linked, use -rpath
ld -rpath ${JAVA_HOME}/lib/server -ljvm ...
This time, you will use libjvm.dylib that is coming from the `JVM` you are interested in.