diff --git a/src/main/c/src/LibUsb.c b/src/main/c/src/LibUsb.c index 6da314a..f19c6c3 100644 --- a/src/main/c/src/LibUsb.c +++ b/src/main/c/src/LibUsb.c @@ -71,7 +71,8 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, exit) { if (!context) { - if (defaultContextRefcnt <= 0) { + if (defaultContextRefcnt <= 0) + { illegalState(env, "default context is not initialized"); return; } @@ -373,7 +374,7 @@ JNIEXPORT jobject JNICALL METHOD_NAME(LibUsb, getDevice) libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle); if (!dev_handle) return NULL; - return wrapDevice(env, libusb_ref_device(libusb_get_device(dev_handle))); + return wrapDevice(env, libusb_get_device(dev_handle)); } /** diff --git a/src/main/java/de/ailis/usb4java/libusb/LibUsb.java b/src/main/java/de/ailis/usb4java/libusb/LibUsb.java index cceac40..cd75090 100644 --- a/src/main/java/de/ailis/usb4java/libusb/LibUsb.java +++ b/src/main/java/de/ailis/usb4java/libusb/LibUsb.java @@ -652,6 +652,10 @@ public final class LibUsb /** * Get the the parent from the specified device [EXPERIMENTAL]. * + * Please note that the reference count of the returned device is not + * increased. As such, do not *ever* call {@link #unrefDevice(Device)) + * directly on the returned Device. + * * @param device * A device * @return The device parent or NULL if not available. You should issue a @@ -820,8 +824,9 @@ public final class LibUsb /** * Get the underlying device for a handle. * - * This function does not modify the reference count of the returned device, - * so do not feel compelled to unreference it when you are done. + * Please note that the reference count of the returned device is not + * increased. As such, do not *ever* call {@link #unrefDevice(Device)) + * directly on the returned Device. * * @param handle * a device handle.