-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
SequenceWriter.writeAll() could accept Iterable #924
Comments
Yes, this would probably have been better signature. Unfortunately, such change would break binary compatibility, I think, despite not breaking source compatibility. This is actually a bigger problem since projects often (try to) upgrade dependencies, and this can break transitive dependencies (or direct ones if not recompiling). I wonder if it would be possible to add both methods, as their type erasures are not identical. |
There are no casts required, overload resolution process takes the most specific type possible. |
@Shredder121 I said binary compatibility may be a problem, not source compatibility. This because whereas Java compiler does consider overloaded variants, class loader simply matches exact type signatures. If existing method is changed, this will effectively remove existing method signature and lead to linkage error on class loading, if code was compiled against older version, but loaded with newer Jackson version. This is problematic for transitive dependencies where recompilation does not happen. This means that existing method needs to remain in place even if new method is added. |
I also meant binary compatibility, the old one would still be there (my second sentence). However I don't think Anyway, it's of course your call, I just wanted to mention that it is posible, no problem. |
@Shredder121 Ok. Yes, as long as old method is kept. Good point on needing casts, actually, had the relationship wrong way around (that is, in which compiler would have chosen new method). You are right, since the old version is more specific and would match most calls, it would still be used. Would be nice to have a way to incrementally remove the old version, but that is probably not worth bothering about until 3.x. |
One possibility would be to use different name, like |
I agree, I think it's fine like this now. |
Currently the method from ${subject} looks like this:
The only assumption on the container is therefore it can be iterated through it using the for each loop. That being said, the signature can be weaken to accept also the
? extends Iterable
. Could you please change it toCollection extends Iterable, hence no API-breakage.
The text was updated successfully, but these errors were encountered: