Issue expected exception when default context refcount is zero or smaller. Make sure that returning a new reference always leads to a new Java object being created, else freeing/unref'ing that one would lead to the reset of the original object too. Furthermore, ensure that getDevice also increments the reference count, since if you then free it, which is usual and not forbidden (libusbx docs just tell you are not obligated to unref it), the reference count would be wrong and lead to a segfault. This way it would lead at most to keeping a device around, instead of segfaulting. Still, always free your references!!!
Issue expected exception when default context refcount is zero or smaller.
Make sure that returning a new reference always leads to a new Java object being created, else
freeing/unref'ing that one would lead to the reset of the original object too.
Furthermore, ensure that getDevice also increments the reference count, since if you then free it,
which is usual and not forbidden (libusbx docs just tell you are not obligated to unref it), the
reference count would be wrong and lead to a segfault. This way it would lead at most to keeping a
device around, instead of segfaulting. Still, always free your references!!!

usb4java/usb4java,zodsoft/usb4java