Skip to content

Commit d6770bb

Browse files
committed
Merge branch '2.19'
2 parents 17ed10f + 1cd8b4a commit d6770bb

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package tools.jackson.jr.ob.impl;
22

33
import java.lang.reflect.*;
4-
import java.util.HashMap;
5-
import java.util.Map;
6-
import java.util.TreeMap;
4+
import java.util.*;
75

86
import tools.jackson.jr.ob.JSON;
97
import tools.jackson.jr.ob.impl.POJODefinition.Prop;
@@ -28,11 +26,13 @@ public BeanPropertyIntrospector() { }
2826
public static BeanPropertyIntrospector instance() { return INSTANCE; }
2927

3028
public POJODefinition pojoDefinitionForDeserialization(JSONReader r, Class<?> pojoType) {
31-
return _introspectDefinition(pojoType, false, r.features());
29+
return _introspectDefinition(pojoType, false, r.features(),
30+
RecordsHelpers.isRecordType(pojoType));
3231
}
3332

3433
public POJODefinition pojoDefinitionForSerialization(JSONWriter w, Class<?> pojoType) {
35-
return _introspectDefinition(pojoType, true, w.features());
34+
return _introspectDefinition(pojoType, true, w.features(),
35+
RecordsHelpers.isRecordType(pojoType));
3636
}
3737

3838
/*
@@ -42,18 +42,18 @@ public POJODefinition pojoDefinitionForSerialization(JSONWriter w, Class<?> pojo
4242
*/
4343

4444
private POJODefinition _introspectDefinition(Class<?> beanType,
45-
boolean forSerialization, int features)
45+
boolean forSerialization, int features, boolean isRecord)
4646
{
4747
Map<String,PropBuilder> propsByName = new TreeMap<>();
48-
_introspect(beanType, propsByName, features);
48+
_introspect(beanType, propsByName, features, isRecord);
4949

5050
final BeanConstructors constructors;
5151

5252
if (forSerialization) {
5353
constructors = null;
5454
} else {
5555
constructors = new BeanConstructors(beanType);
56-
if (RecordsHelpers.isRecordType(beanType)) {
56+
if (isRecord) {
5757
Constructor<?> canonical = RecordsHelpers.findCanonicalConstructor(beanType);
5858
if (canonical == null) { // should never happen
5959
throw new IllegalArgumentException(
@@ -94,22 +94,22 @@ private POJODefinition _introspectDefinition(Class<?> beanType,
9494
}
9595

9696
private static void _introspect(Class<?> currType, Map<String, PropBuilder> props,
97-
int features)
97+
int features, boolean isRecord)
9898
{
9999
if (currType == null || currType == Object.class) {
100100
return;
101101
}
102102
// First, check base type
103-
_introspect(currType.getSuperclass(), props, features);
103+
_introspect(currType.getSuperclass(), props, features, isRecord);
104104

105105
final boolean noStatics = JSON.Feature.INCLUDE_STATIC_FIELDS.isDisabled(features);
106106

107107
// 14-Jun-2024, tatu: Need to enable "matching getters" naming style for Java Records
108108
// too, regardless of `Feature.USE_FIELD_MATCHING_GETTERS`
109-
final boolean isFieldNameGettersEnabled = JSON.Feature.USE_FIELD_MATCHING_GETTERS.isEnabled(features)
110-
|| RecordsHelpers.isRecordType(currType);
109+
final boolean isFieldNameGettersEnabled = isRecord
110+
|| JSON.Feature.USE_FIELD_MATCHING_GETTERS.isEnabled(features);
111111

112-
final Map<String, Field> fieldNameMap = isFieldNameGettersEnabled ? new HashMap<>() : null;
112+
final Map<String, Field> fieldNameMap = isFieldNameGettersEnabled ? new LinkedHashMap<>() : null;
113113

114114
// then public fields (since 2.8); may or may not be ultimately included
115115
// but at this point still possible

0 commit comments

Comments
 (0)