java plugin: Implement a reference counter for the JVMEnv pointers.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 21 Feb 2009 08:13:43 +0000 (09:13 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 21 Feb 2009 08:19:07 +0000 (09:19 +0100)
commit531779b6deedaf8cb6249c3009380b064cd80c8b
tree841ebfef2096c64234d7b5b751ba16ba174eb083
parentb2bf65d02a4c5d35e1d01f2e2f0e1dc2a1b3995b
java plugin: Implement a reference counter for the JVMEnv pointers.

This way one thread entering the Java plugin twice, e. g. with the
following call-chain, will not detach itself from the JVM before it is
completely done with it.

The problematic situation is:
  -> cjni_read
  -> ALLOC JVM
  -> `Read' (in Java)
  -> `DispatchValues' (in Java)
  -> plugin_dispatch_values
  -> cjni_write
  -> ALLOC JVM (this is a no-op!)
  -> `Write' (in Java)
  -> DEALLOC JVM

This last dealloc is prematurely, because the thread is not done with
the JVM yet: It'd like to continue and return from `DispatchValues' to
execute some more Java code..
src/java.c