toNative(Object instance, NativeObjectConstructionInfo info)¶
Creates a native callback from a Java instance.
At first this computes the method index that is used for cache indexing. Then it tries to get or create a cache through the NatJ interface. If this results in a failure that means the Java instance has no cache field, in this case it uses
instance2callbacksas cache. If the cache has a generated
Pointerat the computed index, then it uses it as a result, otherwise, if the cache does not contain anything for the method, then it creates the native callback and saves it in the cache at the computed index. And at last it returns the created native callback.