-
Notifications
You must be signed in to change notification settings - Fork 18
Non-default property naming strategy w/o @JsonCreator leads to "Unrecognized field" #18
Comments
Sounds like a bug; thank you for reporting and verifying with rc1. Most likely something is still unsynced: internally references to creator properties are kept in two separate places (map from name to property, creator instance with indexes) and it's possible one is modified but not the other. |
As per notes on the issue filed against |
Since the issue is in jackson-databind (both in code and on tracker), this issue should be closed. |
No problem! This isn't blocking anything on my end. Please feel free to close - I'm following the other issue. I'll share what my workaround was. There's a slim chance that someone out there is in my exact situation, where adding I'm using a customized version of The reason I am so interested in getting rid of all Lombok offers another way I could work around this, which I avoided. It lets me append annotations to its auto-generated constructors:
That "works" in javac's eyes, but IDEs hate it (even with Lombok's IDE plugins), and I think I hate it too. So I went with the modified |
Thank you for sharing this. The work we have been doing has been aimed at eliminating the need, exactly like you describe. Besides Lombok, Scala module would really benefit from this. So let's hope we can figure out how to get property information unified earlier to be available for renaming (or, perhaps if we must, perform late renaming for late-discovered creators). |
@michaelhixson Jackson 2.6 does use bit more heuristics in dealing with single-argument constructors. As long as a single-argument constructor is visible (for which you may need to change visibility settings, or use custom
Given this, it should be possible to find a way to avoid use of |
@cowtowncoder your previous comment was intended for #21, right?
Just to clarify something about my example code in this issue and that other one: I removed the fields and getters from the examples because I didn't realize they were relevant. My real code where I have these issues does have a field and standard getter method for each constructor param (though none of them are annotated). |
@michaelhixson Sorry, yes. Mostly. But it is actually bit related to this issue as well. Alas, I found that there is a blocking issue in 2.6.0 which prevents detection, related to two-pass processing of things (first trying to find individual properties for getters/setters/creators; later on processing actual creators that class has, trying to reconcile). And that part is actually relevant here as well: unfortunately renaming occurs in the first phase, during which implicit creators have not been detected, and thereby properties (arguments) they have are not renamed either. Once that problem is resolved, this issue should get resolved. But until then, use of |
At this point not sure what remains, if anything, and there have been a few changes to |
Actually I think remaining work is captured under still open issue for databind: FasterXML/jackson-databind#806 and there is a failing test. |
I'm trying to use the feature of the parameter names module where I can leave out
@JsonCreator
and@JsonProperty
annotations. This works great, except when I use a different naming strategy such asCAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES
. In that case I do need the@JsonCreator
or else I get an error. This is with Jackson 2.6.0-rc1.Would it be possible to make
@JsonCreator
optional here?Here is some code demonstrating the issue:
Here is the output of the above:
The text was updated successfully, but these errors were encountered: