@@ -61,6 +61,11 @@ public class POJOPropertiesCollector
6161 */
6262 protected final boolean _useAnnotations ;
6363
64+ /**
65+ * @since 2.15
66+ */
67+ protected final boolean _isRecordType ;
68+
6469 /*
6570 /**********************************************************
6671 /* Collected property information
@@ -170,6 +175,7 @@ protected POJOPropertiesCollector(MapperConfig<?> config, boolean forSerializati
170175 _forSerialization = forSerialization ;
171176 _type = type ;
172177 _classDef = classDef ;
178+ _isRecordType = _type .isRecordType ();
173179 if (config .isAnnotationProcessingEnabled ()) {
174180 _useAnnotations = true ;
175181 _annotationIntrospector = _config .getAnnotationIntrospector ();
@@ -225,7 +231,7 @@ public JavaType getType() {
225231 * @since 2.15
226232 */
227233 public boolean isRecordType () {
228- return _type . isRecordType () ;
234+ return _isRecordType ;
229235 }
230236
231237 public AnnotatedClass getClassDef () {
@@ -431,7 +437,12 @@ protected void collectAll()
431437 LinkedHashMap <String , POJOPropertyBuilder > props = new LinkedHashMap <String , POJOPropertyBuilder >();
432438
433439 // First: gather basic data
434- _addFields (props ); // note: populates _fieldRenameMappings
440+
441+ // 15-Jan-2023, tatu: [databind#3736] Let's avoid detecting fields of Records
442+ // altogether (unless we find a good reason to detect them)
443+ if (!isRecordType ()) {
444+ _addFields (props ); // note: populates _fieldRenameMappings
445+ }
435446 _addMethods (props );
436447 // 25-Jan-2016, tatu: Avoid introspecting (constructor-)creators for non-static
437448 // inner classes, see [databind#1502]
@@ -994,7 +1005,10 @@ protected void _removeUnwantedProperties(Map<String, POJOPropertyBuilder> props)
9941005 */
9951006 protected void _removeUnwantedAccessor (Map <String , POJOPropertyBuilder > props )
9961007 {
997- final boolean inferMutators = _config .isEnabled (MapperFeature .INFER_PROPERTY_MUTATORS );
1008+ // 15-Jan-2023, tatu: Avoid pulling in mutators for Records; Fields mostly
1009+ // since there should not be setters.
1010+ final boolean inferMutators = !isRecordType ()
1011+ && _config .isEnabled (MapperFeature .INFER_PROPERTY_MUTATORS );
9981012 Iterator <POJOPropertyBuilder > it = props .values ().iterator ();
9991013
10001014 while (it .hasNext ()) {
0 commit comments