jni-rs v0.13.0 Release Notes

Release Date: 2019-07-05 // over 4 years ago
  • 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
      with JavaVM::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

    • 0๏ธโƒฃ The default JNI API version in InitArgsBuilder from V1 to V8. (#178)
    • Extended the lifetimes of AutoLocal to make it more flexible. (#190)
    • 0๏ธโƒฃ Default exception type from checked java.lang.Exception to unchecked java.lang.RuntimeException.
      ๐Ÿ‘ป It is used implicitly when JNIEnv#throw is invoked with exception message:
      ๐Ÿ‘ป env.throw("Exception message"); however, for efficiency reasons, it is recommended
      to specify the exception type explicitly and use throw_new:
      ๐Ÿ†• env.throw_new(exception_type, "Exception message"). (#194)

    ๐Ÿ›  Fixed

    • Native threads attached with JavaVM::attach_current_thread_as_daemon now automatically detach
      themselves on exit, preventing Java Thread leaks. (#179)
    • Local reference leaks in JList, JMap and JMapIter. (#190, #191)