Thursday 15 August 2013

c++ - How to expose Java enum to native code through JNI -


I am using enum pattern to define singleton in my application. I need to reach the methods of this singleton, but I can not pass the singleton correctly.

I have tried to pass enum and thus it is called globalRef Has tried to create a job in:

  class frames edled: people gkEngine :: listener {public: JNIEnv * env; Job manager unit manager; FrameElapsedListener (JNIEnv * env, jobject entityManager): env (env), entityManager (env-> NewGlobalRef (entityManager) {} ~ FrameElapsedListener () {env- & gt; DeleteGlobalRef (entityManager); } Zero tick (GKSLayer rate); };   

But I got crashes while using it that "local ref" was out of the scope like this:

  jclass entityManagerClass = env-> ; FindClass (entityManagerClassPath.c_str ()); JmethodID entityManagerFrameElapsedMethodId = env- & gt; GetMethodID (Unit Manager Class, "Frame Elapsed", "(F) V"); Env-> Callwheid system (unit manager, unit manager sheds removed method, rate); // here crashes   

Now I'm just trying to get a singleton out of enum, but I'm not sure how to grab enum values ​​like that. Any advice?

You can not save a JNIEnv pointer to a different formula for use. You know, to get a new thread in the AttachCurrentThread () by calling

No comments:

Post a Comment