我有以下設置有一個基類存儲最終從JNI在JNI
設定指針class Struct {
private long ptr;
long c_ptr() { return ptr; }
}
class NativeInterface {
static native void somefunc(Struct st);
...
}
然後特定的結構將被傳遞到NativeInterface:somefunc需要能夠訪問它的ptr
字段。我的問題是如何將超級SomeStruct
傳遞給本地接口?它應該是這樣或者與演員?
class SomeStruct extends Struct {
void somefunc() {
NativeInterface.somefunc(super);
}
}