На Яве у меня есть интерфейс:
public interface I {...}
объявление функции пустота f()
, и некоторые классы:
public class A implements I {...}
public class B implements I {...}
public class C implements I {...}
...
Я часто вызываю родную функцию:
public native void nativeFunc(I obj);
В C++ я получаю a
jobject jobj
Цель состоит в том, чтобы звонить
jobj.f();
не идя каждый раз через цепь
cls = jenv->GetObjectClass(jobj); (1)
mid = jenv->GetMethodID(cls, "f", "()V"); (2)
jenv->CallVoidMethod(jobj, mid); (3)
I can't seem to cache mid
between native calls. As another suggestion, I could start with line (1), then use a cached map
. However, this probably won't work, too, since jclass
references might differ for the same class.
Там кто-либо оптимизирует решение?