0.13 brings major improvements in thread management, allowing to attach the native threads
permanently and safely; Executor
for extra convenience and safety; and other
improvements and fixes.
⚠️ If your code attaches native threads — make sure to check the updated documentation
of JavaVM to learn about the new features!
Added
JavaVM::attach_current_thread_permanently
method, which attaches the current
thread and detaches it when the thread finishes. Daemon threads attached
withJavaVM::attach_current_thread_as_daemon
also automatically detach themselves
when finished. The number of currently attached threads may be acquired using
JavaVM::threads_attached
method. (#179, #180)Executor
— a simple thread attachment manager which helps to safely
execute a closure in attached thread context and to automatically free
created local references at closure exit. (#186)
Changed
- The default JNI API version in
InitArgsBuilder
from V1 to V8. (#178) - Extended the lifetimes of
AutoLocal
to make it more flexible. (#190) - Default exception type from checked
java.lang.Exception
to uncheckedjava.lang.RuntimeException
.
It is used implicitly whenJNIEnv#throw
is invoked with exception message:
env.throw("Exception message")
; however, for efficiency reasons, it is recommended
to specify the exception type explicitly and usethrow_new
:
env.throw_new(exception_type, "Exception message")
. (#194)