diff --git a/CHANGES.current b/CHANGES.current index 3b283bd75..fc17331c8 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-12-10: wsfulton + [Android/Java] Fix directors to compile on Android. + + Added documentation and examples for Android. + 2011-12-08: vadz Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes (they could be sometimes mysteriously not renamed or ignored there before). diff --git a/Lib/java/director.swg b/Lib/java/director.swg index 07e5a1af1..d45cdbbcf 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -112,21 +112,29 @@ namespace Swig { class JNIEnvWrapper { const Director *director_; JNIEnv *jenv_; + int env_status; public: - JNIEnvWrapper(const Director *director) : director_(director), jenv_(0) { + JNIEnvWrapper(const Director *director) : director_(director), jenv_(0), env_status(0) { +#if defined(__ANDROID__) + JNIEnv **jenv = &jenv_; +#else + void **jenv = (void **)&jenv_; +#endif + env_status = director_->swig_jvm_->GetEnv((void **)&jenv_, JNI_VERSION_1_2); #if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON) // Attach a daemon thread to the JVM. Useful when the JVM should not wait for // the thread to exit upon shutdown. Only for jdk-1.4 and later. - director_->swig_jvm_->AttachCurrentThreadAsDaemon((void **) &jenv_, NULL); + director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, NULL); #else - director_->swig_jvm_->AttachCurrentThread((void **) &jenv_, NULL); + director_->swig_jvm_->AttachCurrentThread(jenv, NULL); #endif } ~JNIEnvWrapper() { #if !defined(SWIG_JAVA_NO_DETACH_CURRENT_THREAD) // Some JVMs, eg jdk-1.4.2 and lower on Solaris have a bug and crash with the DetachCurrentThread call. // However, without this call, the JVM hangs on exit when the thread was not created by the JVM and creates a memory leak. - director_->swig_jvm_->DetachCurrentThread(); + if (env_status == JNI_EDETACHED) + director_->swig_jvm_->DetachCurrentThread(); #endif } JNIEnv *getJNIEnv() const {