-
-
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
Fix type resolution for static methods (regression in 2.11.3) #2894
Fix type resolution for static methods (regression in 2.11.3) #2894
Conversation
} | ||
|
||
@JsonCreator | ||
public static <T> WrapperWithFactoryMethod<T> fromValues(@JsonProperty("values") List<T> values) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that T
here is NOT related to type variable T
for class, and as such can not realistically be used as a creator method. It just happens to have same name, but being static method is not part of the class or bindings in that sense.
Unfortunately usage as indicated is wrong: static methods type variable is not bound to class at all, even if name happens to be same. For static methods If this has seemingly worked before that is unfortunate but I don't think such usage such "work" in the sense indicated. |
Hmmmh. Actually, thinking about this bit more -- while it is, fundamentally, assuming something that Java does not do (implicit linkage), the fact that behavior has been such that it has worked means that usage may be widespread. Still, I'll have to think about this as I think it has been reported wrt Immutables as well. |
Hi @lukasz-walkiewicz, I've attempted a fix which does not reintroduce bugs here: #2895. Any chance you could take a look to make sure I haven't missed relevant test cases? |
I resolved the issue with bit more localized patch, added modified unit test. |
@cowtowncoder Thank you very much for taking care of this. As you said, this "misuse" of type resolution mechanism is pretty widespread (eg. in Presto) so dropping it without prior notice would refrain many users from updating. |
@lukasz-walkiewicz yes, agreed. It's just too bad there were no unit tests for this usage, leading to failures. |
I'd be happy to submit additional test cases for this behavior based on uses in a few internal codebases :-) |
@carterkozak that'd be great! As I said, for 2.11 I'd hope to keep things that worked working; and we can work on #2895 wrt 2.12 improvements. |
Updating Jackson (2.10.4 => 2.11.3) in https://github.com/prestosql/presto introduced a regression in types resolution for factory methods, ie. type reference is being dropped for static methods.
Given simplified scenario:
out
contains values of typeLinkedHashMap
produced byUntypedObjectDeserializer
.I think it's due to changes introduced in 1014493.