Skip to content

Commit 3b273c9

Browse files
committed
Rearrange handling of Field introspection slightly
1 parent d5c3a70 commit 3b273c9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/BeanPropertyIntrospector.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,22 @@ private static void _introspect(Class<?> currType, Map<String, PropBuilder> prop
116116
// then public fields (since 2.8); may or may not be ultimately included
117117
// but at this point still possible
118118
for (Field f : currType.getDeclaredFields()) {
119-
if (fieldNameMap != null) {
120-
fieldNameMap.put(f.getName(), f);
121-
}
122-
if (!Modifier.isPublic(f.getModifiers()) || f.isEnumConstant() || f.isSynthetic()) {
119+
// First things first: skip synthetics, Enum constants
120+
if (f.isEnumConstant() || f.isSynthetic()) {
123121
continue;
124122
}
125123
// Only include static members if (a) inclusion feature enabled and
126124
// (b) not final (cannot deserialize final fields)
127125
if (Modifier.isStatic(f.getModifiers()) && (noStatics || Modifier.isFinal(f.getModifiers()))) {
128126
continue;
129127
}
130-
_propFrom(props, f.getName()).withField(f);
128+
// But for possible renaming, even non-public Fields have effect so:
129+
if (fieldNameMap != null) {
130+
fieldNameMap.put(f.getName(), f);
131+
}
132+
if (Modifier.isPublic(f.getModifiers())) {
133+
_propFrom(props, f.getName()).withField(f);
134+
}
131135
}
132136

133137
// then get methods from within this class

0 commit comments

Comments
 (0)