- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.4k
 
Closed
Labels
RecordIssue related to JDK17 java.lang.Record supportIssue related to JDK17 java.lang.Record supporthas-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issueIndicates that there exists a test case (under `failing/`) to reproduce the issue
Milestone
Description
Search before asking
- I searched in the issues and found nothing similar.
 
Describe the bug
When deserializing a record, jackson fails with
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of ... (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
It looks like jackson does not see default constructor.
Version Information
2.16.0-rc1
Reproduction
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
class TestObjectTest {
    @Test
    public void shouldDeserialize() throws JsonProcessingException {
        TestObject testObject = new ObjectMapper().readValue("{\"text\":\"anything\"}", TestObject.class);
        Assertions.assertEquals("anything", testObject.text());
    }
    private record TestObject(String text) {}
}When I add compact constructor with @JsonCreator to TestObject, it works correctly:
    private record TestObject(String text) {
        @JsonCreator
        private TestObject {
        }
    }Additional context
- It works correctly in version 2.15.3
 - tested on java 21
 - May be related to Exception when deserialization uses a record with a constructor property with 
access=READ_ONLY#4119 
Metadata
Metadata
Assignees
Labels
RecordIssue related to JDK17 java.lang.Record supportIssue related to JDK17 java.lang.Record supporthas-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issueIndicates that there exists a test case (under `failing/`) to reproduce the issue