Skip to content

Commit dc10783

Browse files
Migrate legacy reflection properties to use MethodHandles, take 2 (#5090)
1 parent d3c0ed9 commit dc10783

File tree

12 files changed

+335
-403
lines changed

12 files changed

+335
-403
lines changed

src/main/java/tools/jackson/databind/deser/BeanDeserializerFactory.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package tools.jackson.databind.deser;
22

3+
import java.lang.reflect.Modifier;
34
import java.util.*;
45

56
import com.fasterxml.jackson.annotation.*;
@@ -938,19 +939,16 @@ protected SettableBeanProperty constructSettableProperty(DeserializationContext
938939
JavaType type = resolveMemberAndTypeAnnotations(ctxt, mutator, propType0);
939940
// Does the Method specify the deserializer to use? If so, let's use it.
940941
TypeDeserializer typeDeser = (TypeDeserializer) type.getTypeHandler();
941-
SettableBeanProperty prop;
942-
if (mutator instanceof AnnotatedMethod) {
943-
prop = new MethodProperty(propDef, type, typeDeser,
944-
beanDescRef.getClassAnnotations(), (AnnotatedMethod) mutator);
945-
} else {
946-
// 08-Sep-2016, tatu: wonder if we should verify it is `AnnotatedField` to be safe?
947-
prop = new FieldProperty(propDef, type, typeDeser,
948-
beanDescRef.getClassAnnotations(), (AnnotatedField) mutator);
942+
// 05-May-2025, tatu: [databind#5090]/[databind#2083] Need to skip these for some reason
943+
if (isFinalField(mutator)) {
944+
return null;
949945
}
950946
ValueDeserializer<?> deser = findDeserializerFromAnnotation(ctxt, mutator);
951947
if (deser == null) {
952948
deser = (ValueDeserializer<?>) type.getValueHandler();
953949
}
950+
SettableBeanProperty prop = new MethodProperty(propDef, type, typeDeser,
951+
beanDescRef.getClassAnnotations(), mutator);
954952
if (deser != null) {
955953
deser = ctxt.handlePrimaryContextualization(deser, prop, type);
956954
prop = prop.withValueDeserializer(deser);
@@ -967,6 +965,11 @@ protected SettableBeanProperty constructSettableProperty(DeserializationContext
967965
return prop;
968966
}
969967

968+
private boolean isFinalField(AnnotatedMember am) {
969+
return am instanceof AnnotatedField
970+
&& Modifier.isFinal(am.getMember().getModifiers());
971+
}
972+
970973
/**
971974
* Method that will construct a regular bean property setter using
972975
* the given setter method.

src/main/java/tools/jackson/databind/deser/SettableBeanProperty.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ protected void _throwAsJacksonE(JsonParser p, Throwable e, Object value)
633633

634634
protected void _throwAsJacksonE(JsonParser p, Throwable e) throws JacksonException
635635
{
636+
ClassUtil.throwIfError(e);
636637
ClassUtil.throwIfRTE(e);
637638
ClassUtil.throwIfJacksonE(e);
638639

src/main/java/tools/jackson/databind/deser/impl/FieldProperty.java

Lines changed: 0 additions & 213 deletions
This file was deleted.

0 commit comments

Comments
 (0)