1
1
package tools .jackson .databind .deser ;
2
2
3
+ import java .lang .invoke .MethodHandles ;
4
+ import java .lang .reflect .Field ;
5
+ import java .lang .reflect .Modifier ;
3
6
import java .util .*;
4
7
5
8
import com .fasterxml .jackson .annotation .*;
@@ -935,14 +938,13 @@ protected SettableBeanProperty constructSettableProperty(DeserializationContext
935
938
// Does the Method specify the deserializer to use? If so, let's use it.
936
939
TypeDeserializer typeDeser = (TypeDeserializer ) type .getTypeHandler ();
937
940
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 );
941
+ if (!ClassUtil .checkAndFixAccess (mutator .getMember (), ctxt .getConfig ().isEnabled (MapperFeature .OVERRIDE_PUBLIC_ACCESS_MODIFIERS ))) {
942
+ return null ;
945
943
}
944
+ if (finalField (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 finalField (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