On 27/03/12 08:40, William S Fulton wrote:
On 26/03/12 17:31, Manuel Massing wrote:

after encountering reproducible crashes with the director feature
on android (crash in JNIEnv::GetObjectClass upon garbage collection), I traced
it to usage of weak global references in a way which is not supported on

The android jni documenation -
- has the following to say about correct usage of weak global refs:

"Weak global" references are implemented, but may only be passed to
NewLocalRef, NewGlobalRef, and DeleteWeakGlobalRef. (The spec strongly
encourages programmers to create hard references to weak globals
before doing anything with them, so this should not be at all

Could someone review or comment on the patch?

I found an old mail apparently referencing the same problem:


(please CC as I am not subscribed)

Hi Manuel.

Can you send me some code that replicates the crash? I can test the fix on Android and on some other Java systems. Actually if you could provide a patch to one of the Android examples in trunk, that would be easiest as the Makefiles in these examples should just work on an Android system. See the docs on these examples here: http://swig.svn.sourceforge.net/viewvc/swig/trunk/Doc/Manual/Android.html.

I've recreated the problem and have committed the patch.