To sum this up:

The problem lies partly in the JSON-B spec. It doesn't define what happens if 
there are class hierarchies like class A extends B.

In 3.7.1 it states that 
For a serialization operation, if a matching public getter method exists, the 
method is called to obtain the value of the property. If a matching getter 
method with private, protected, or defaulted to package-only access exists, 
then this field is ignored. If no matching getter method exists and the field 
is public, then the value is obtained directly from the field.

This can get changed y using a @JsonbVisibility

4.6 Custom visibility
To customize scope and field access strategy as specified in section 3.7.1, it 
is possible to specify javax.json.bind.annotation.JsonbVisibility annotation or 
to override default behavior globally calling 
JsonbConfig::withPropertyVisibilityStrategy method with given custom property 
visibility strategy.


The problem is that that the PropertyVisibilityStrategy is simply not ready to 
implement the rules of 3.7.1 in a portable way when it comes to class 
hierarchies
https://github.com/apache/geronimo-specs/blob/trunk/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/config/PropertyVisibilityStrategy.java
 
<https://github.com/apache/geronimo-specs/blob/trunk/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/config/PropertyVisibilityStrategy.java>

So either we say that the spec simply does not define what should happen in 
case of hierarchic classes (totally valid imo) or we need to ditch our 
DefaultPropertyVisibility logic completely. It's simply not possible to 
implement it that way.

The reason why I removed the logic from the Reader is the following: Even if 
the reader says 'oh there is a getter, so let's hide the property' you STILL 
are perfectly allowed - as per the spec - to have Visibility strategies which 
do disable ALL methods and ONLY use field access.
That means the current impl is surely more correct than before, but not yet 
perfect.

LieGrue,
strub



> Am 28.02.2022 um 11:17 schrieb Romain Manni-Bucau <rmannibu...@gmail.com>:
> 
> Hi JL,
> 
> Last commit broke some stuff.
> Dicussed it quickly offline with Mark but Im AFK for a few days, can it
> wait some days? Otherwise maybe just pick this commit?
> 
> Le lun. 28 févr. 2022 à 10:37, Jean-Louis Monteiro <jlmonte...@tomitribe.com>
> a écrit :
> 
>> Hi all,
>> 
>> Is it ok to release a 1.2.17?
>> I'm looking for a Jakarta EE fix -
>> 
>> https://github.com/apache/johnzon/commit/a1c53d99c3280cbfc35b369ac4ce138e12f1d5ff
>> 
>> Do you guys have some additional fixes to push?
>> --
>> Jean-Louis Monteiro
>> http://twitter.com/jlouismonteiro
>> http://www.tomitribe.com
>> 

Reply via email to