1
1
package tools .jackson .databind .deser ;
2
2
3
+ import java .lang .reflect .Modifier ;
3
4
import java .util .*;
4
5
5
6
import com .fasterxml .jackson .annotation .*;
@@ -935,14 +936,15 @@ protected SettableBeanProperty constructSettableProperty(DeserializationContext
935
936
// Does the Method specify the deserializer to use? If so, let's use it.
936
937
TypeDeserializer typeDeser = (TypeDeserializer ) type .getTypeHandler ();
937
938
SettableBeanProperty prop ;
938
- if (mutator instanceof AnnotatedMethod ) {
939
- prop = new MethodProperty (propDef , type , typeDeser ,
940
- beanDesc .getClassAnnotations (), (AnnotatedMethod ) mutator );
941
- } else {
942
- // 08-Sep-2016, tatu: wonder if we should verify it is `AnnotatedField` to be safe?
943
- prop = new FieldProperty (propDef , type , typeDeser ,
944
- beanDesc .getClassAnnotations (), (AnnotatedField ) mutator );
939
+ // 06-04-2025, scs: we cannot always see members if e.g. they are in a different module that does not
940
+ // allow our access, so filter such cases out here.
941
+ if (!ClassUtil .checkAndFixAccess (mutator .getMember (), ctxt .isEnabled (MapperFeature .OVERRIDE_PUBLIC_ACCESS_MODIFIERS ))) {
942
+ return null ;
945
943
}
944
+ if (isFinalField (mutator )) {
945
+ return null ;
946
+ }
947
+ prop = new MethodProperty (propDef , type , typeDeser , beanDesc .getClassAnnotations (), mutator );
946
948
ValueDeserializer <?> deser = findDeserializerFromAnnotation (ctxt , mutator );
947
949
if (deser == null ) {
948
950
deser = (ValueDeserializer <?>) type .getValueHandler ();
@@ -963,6 +965,11 @@ protected SettableBeanProperty constructSettableProperty(DeserializationContext
963
965
return prop ;
964
966
}
965
967
968
+ private boolean isFinalField (AnnotatedMember am ) {
969
+ return am instanceof AnnotatedField
970
+ && Modifier .isFinal (am .getMember ().getModifiers ());
971
+ }
972
+
966
973
/**
967
974
* Method that will construct a regular bean property setter using
968
975
* the given setter method.
0 commit comments