You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per the current TCK Process documentation, please find bellow a challenge related to JSON-B TCK. Can someone please add the challenge label which is required by the TCK Process but not available to everyone to add.
The relevant specification version and section number(s)
Only following test in the class are related to the challenge
#testCreatorDeserialization
The exact TCK version
JSON-B TCK version 3.0.0
The implementation being tested, including name and company
Apache Johnzon 2.0.0-SNAPSHOT from the Apache Software Foundation
A full description of why the test is invalid and what the correct behavior is believed to be
The test aims at covering the polymorphic mapping using JsonbTypeInfo and JsonbSubtype which is fine. The DateConstructor, in its current form
public static final class DateConstructor implements SomeDateType {
public LocalDate localDate;
@JsonbCreator
public DateConstructor(@JsonbProperty("localDate") @JsonbDateFormat(value = "dd-MM-yyyy", locale = "nl-NL") LocalDate localDate) {
this.localDate = localDate;
}
}
There is an ambiguity there in the way the localDate field should be deserialized. We have 2 candidates
the factory (constructor from DateConstruct)
the setter (direct field access which is public without a private setter)
The test implies that only one, the DateConstructor constructor and not the direct field.
In Johnzon we call first the factory and then the setters, because we see them as callback for the user to use after the object is constructed.
In this situation, the specification does not provide with a clear order. I'm going to create a issue to clarify this point but meanwhile, we need a challenge for this test.
I propose to create a PR in order to change the localDate modifier from public to private so there is no ambiguty anymore. We can add a public getter so we can even write an assert in the test using the deserialized value.
Any chance we can get this challenge accepted and resolved? Its one of the two excludes we carry on right now in apache johnzon that blocks us from actually being certified
Sorry for the ping @KyleAure but i've seen you active here the last couple weeks and maybe we can finally get this done
I agree that there is some ambiguity in the specification that needs to be handled, but I'm not sure the way Johnzon is handling this situation is how I would like the specification settle on.
If I understand correctly the issue here is name collision.
For example if we have the following POJO:
I think this goes against the intention of the @JsonbCreator to create an alternative path for deserialization.
The spec says:
In many scenarios instantiation with the use of default constructor is not enough. To support these scenarios, JSON Binding provides jakarta.json.bind.annotation.JsonbCreator annotation.
I think the intention here is to say that when using the @JsonbCreator we do not intend to go down the default deserialization path.
Not to mention if you were to switch the CreatorNameConflicts class with an equivalent record then fromJson would have to be null since what is returned from the constructor would be immutable.
I would like our behavior between classes and records to be as closely aligned as possible.
I tried to clarify this in this PR: #411
I would appreciate your feedback on this PR.
For the purpose of 3.0, I do agree the behavior is ambiguous and am willing to accept this challenge and disable the test in a 3.0.3 service release to be used by Johnzon for certification, but I think for 3.1.0 I'd rather clarify the ambiguous behavior and leave the test as is.
it is important to keep setters or field initialization cause they are different from constructor/factory initialization in terms of callback, lifecycle and backward compatibility - worse for records than pojo, ack that.
so don't think we can say we do bypass them, in particular
the immutable case is the extreme constructor case where there is only ambiguities for public fields (let say never else you dont use a jsonbcreator and just let it be bound by the public fields) but all in between cases require both support so (obviously) I think Apache Johnzon is the only viable option else you enforce to move all the logic to the constructor which is not always possible or factories with potentially a lot of duplication when you mix programming model on your DTO (you can say it is wrong but it is not that uncommon and vert convenient for migrations so think we should cover these case)
I agree that public fields and setters should still be used when avaiablle, just not when they have conflicting names with parameters in the @JsonbCreator.
I think the intention here is to say that when using the @JsonbCreator we do not intend to go down the default deserialization path.
Disagree with that one, IMO its just about how the object is being created. Other properties should still be mapped, this behaviour is also required by the TCK already in testCustomConstructorPlusFields.
I do however agree with Kyles standpoint that once a property has been passed to a creator it should be seen as "consumed" and not be passed on to mapping it into setters/fields anymore for a future spec release
Why not allowing to consume twice since the lifecycle is clearly defined by design there?
While I get the "we can prevent multiple mapping" - a set more or less technically, I dont see why making it an exception would help, if done it is intentional from user standpoint so we should respect it and not try to be clever IMHO.
Exceptions are always overcomplex for a poor gain, fine to mention implémentation can log a warning or a like.
Ideally I would be happy to enable to "eat" attributes explicitly (@JsonbIgnoreDeserialization - with a better name) either on the prop or paramétrer, but not the opposite.
I think the intention here is to say that when using the @JsonbCreator we do not intend to go down the default deserialization path.
Disagree with that one, IMO its just about how the object is being created. Other properties should still be mapped, this behaviour is also required by the TCK already in testCustomConstructorPlusFields.
When I said we do not intend to go down the default deserialization path my intention was to say that the purpose of @JsonbCreator is itself to define an alternative path for deserialization. Therefore a user declaring a constructor with @JsonbCreator would expect that alternative path to be used.
However, the way you have described Johnzon's implementation there would be scenarios where it looks like that alternative path is skipped. Namely, when there are name conflicts on between parameters on the @JsonbCreator constructor/method and the fields of the class / bean properties.
While I get the "we can prevent multiple mapping" - a set more or less technically, I dont see why making it an exception would help, if done it is intentional from user standpoint so we should respect it and not try to be clever IMHO.
In a sense I agree, but IMO if a user were to write the following:
Then I think the intention is clear that they want a to be uppercase at the end of deserialization.
However, IIUC you are saying that the users intention is the opposite because they didn't set the field a on the class Test to a different name?
Then I think the intention is clear that they want a to be uppercase at the end of deserialization.
Can agree on this one, will disagree if you update your sample to use public void setA(String v) and I don't think making public fields an exception would be very understandable and neat for end users, therefore my proposal to just stay dumb and use all options which are available. Similarly factories are different from constructors (cause "external" of the bean self lifecycle) but I dont think making constructor an exception (compared to static methods) would be understandable (+ valuable).
So overall I think it makes sense to not try to be clever but maybe only document these cases in the spec?
Activity
feat: Add a test related to the challenge jakartaee/jsonb-api#347
jungm commentedon Aug 11, 2026
Any chance we can get this challenge accepted and resolved? Its one of the two excludes we carry on right now in apache johnzon that blocks us from actually being certified
Sorry for the ping @KyleAure but i've seen you active here the last couple weeks and maybe we can finally get this done
KyleAure commentedon Aug 11, 2026
@jeanouii @jungm
I agree that there is some ambiguity in the specification that needs to be handled, but I'm not sure the way Johnzon is handling this situation is how I would like the specification settle on.
If I understand correctly the issue here is name collision.
For example if we have the following POJO:
And we perform the following deserialization:
Then the way you have described the behavior in Johnzon, deserialization would result in the following object:
I think this goes against the intention of the
@JsonbCreatorto create analternativepath for deserialization.The spec says:
I think the intention here is to say that when using the
@JsonbCreatorwe do not intend to go down the default deserialization path.Not to mention if you were to switch the
CreatorNameConflictsclass with an equivalent record thenfromJsonwould have to benullsince what is returned from the constructor would be immutable.I would like our behavior between classes and records to be as closely aligned as possible.
I tried to clarify this in this PR: #411
I would appreciate your feedback on this PR.
KyleAure commentedon Aug 11, 2026
For the purpose of 3.0, I do agree the behavior is ambiguous and am willing to accept this challenge and disable the test in a 3.0.3 service release to be used by Johnzon for certification, but I think for 3.1.0 I'd rather clarify the ambiguous behavior and leave the test as is.
I'd appreciate input for others as well.
rmannibucau commentedon Aug 11, 2026
it is important to keep setters or field initialization cause they are different from constructor/factory initialization in terms of callback, lifecycle and backward compatibility - worse for records than pojo, ack that.
so don't think we can say we do bypass them, in particular
the immutable case is the extreme constructor case where there is only ambiguities for public fields (let say never else you dont use a jsonbcreator and just let it be bound by the public fields) but all in between cases require both support so (obviously) I think Apache Johnzon is the only viable option else you enforce to move all the logic to the constructor which is not always possible or factories with potentially a lot of duplication when you mix programming model on your DTO (you can say it is wrong but it is not that uncommon and vert convenient for migrations so think we should cover these case)
hope it makes sense (from the phone)
KyleAure commentedon Aug 11, 2026
@rmannibucau
I agree that public fields and setters should still be used when avaiablle, just not when they have conflicting names with parameters in the
@JsonbCreator.For example if we deserialized the following:
I would expect the following instance to be returned:
Which sadly I do not think we currently do in Yasson.Does that align with your comment?
jungm commentedon Aug 12, 2026
Disagree with that one, IMO its just about how the object is being created. Other properties should still be mapped, this behaviour is also required by the TCK already in
testCustomConstructorPlusFields.I do however agree with Kyles standpoint that once a property has been passed to a creator it should be seen as "consumed" and not be passed on to mapping it into setters/fields anymore for a future spec release
rmannibucau commentedon Aug 12, 2026
Why not allowing to consume twice since the lifecycle is clearly defined by design there?
While I get the "we can prevent multiple mapping" - a set more or less technically, I dont see why making it an exception would help, if done it is intentional from user standpoint so we should respect it and not try to be clever IMHO.
Exceptions are always overcomplex for a poor gain, fine to mention implémentation can log a warning or a like.
Ideally I would be happy to enable to "eat" attributes explicitly (@JsonbIgnoreDeserialization - with a better name) either on the prop or paramétrer, but not the opposite.
KyleAure commentedon Aug 12, 2026
@jungm
When I said
we do not intend to go down the default deserialization pathmy intention was to say that the purpose of@JsonbCreatoris itself to define an alternative path for deserialization. Therefore a user declaring a constructor with@JsonbCreatorwould expect that alternative path to be used.However, the way you have described Johnzon's implementation there would be scenarios where it looks like that alternative path is skipped. Namely, when there are name conflicts on between parameters on the
@JsonbCreatorconstructor/method and the fields of the class / bean properties.@rmannibucau
In a sense I agree, but IMO if a user were to write the following:
Then I think the intention is clear that they want
ato be uppercase at the end of deserialization.However, IIUC you are saying that the users intention is the opposite because they didn't set the field
aon the classTestto a different name?rmannibucau commentedon Aug 12, 2026
Can agree on this one, will disagree if you update your sample to use
public void setA(String v)and I don't think making public fields an exception would be very understandable and neat for end users, therefore my proposal to just stay dumb and use all options which are available. Similarly factories are different from constructors (cause "external" of the bean self lifecycle) but I dont think making constructor an exception (compared to static methods) would be understandable (+ valuable).So overall I think it makes sense to not try to be clever but maybe only document these cases in the spec?
KyleAure commentedon Aug 12, 2026
Sounds good. I'll draft a PR and see if we can come to a consensus on language.