-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Java] Exception on BytBuffer position() #6657
Comments
Your link seems to suggest it is about the return value of Can you point to a use of |
I actually observed the behavior on the overload setting the position in |
That does |
The actual return value is not relevant - the issue is with the VM not finding the right method to call. It tries to look for a one returning a Buffer, but only finds one returning a ByteBuffer, hence the exception. It simply doesn't handle covariant return types. Upcasting forces it to use the one returning Buffer. |
Ok, thanks for the explanation. That is pretty bad bad breakage of the Java APIs, surprised they thought that was a good idea. This should affect the setter version of Remains the issue of what the costs is of all these extra casts. If its only the setter it may be ok? Yes, and don't understand why this is only now an issue.. |
I may have gone a bit overboard with replacing calls. I'll revert changes to the getters in ~9h. |
Just pushed an update. Seems to work. |
After updating to Java 2.0.0, I've encountered https://stackoverflow.com/questions/58120357/jeromq-on-android-no-virtual-method-clearljava-nio-bytebuffer on Android. The fix is simple: replace all
bb.position()
calls with((Buffer) bb).position()
. Unfortunately, I don't see a client-side workaround.The text was updated successfully, but these errors were encountered: