Reputation: 11
I want to check implementation of the native method before use it, but I don't know how.
Upvotes: 0
Views: 426
Reputation: 7564
If a native method of a class isn't defined for your platform, the classloader will throw an java.lang.UnsatisfiedLinkError
. So your test could be
try {
Class.forName("your.class.with.NativeCode");
} catch (UnsatisfiedLinkError e) {
// the implementation for the methods cannot be linked.
}
This code would need to be in an unrelated class that doesn't have any direct dependency to the class with native code. Otherwise this class cannot be loaded as well.
Upvotes: 1