{"action":"created","issue":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/825","labels_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/825/labels{/name}","comments_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/825/comments","events_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/825/events","html_url":"https://github.com/FasterXML/jackson-databind/issues/825","id":87653553,"number":825,"title":"Unresolved forward reference error - JsonIdentityInfo, default typing","user":{"login":"muellekl","id":12857337,"avatar_url":"https://avatars.githubusercontent.com/u/12857337?v=3","gravatar_id":"","url":"https://api.github.com/users/muellekl","html_url":"https://github.com/muellekl","followers_url":"https://api.github.com/users/muellekl/followers","following_url":"https://api.github.com/users/muellekl/following{/other_user}","gists_url":"https://api.github.com/users/muellekl/gists{/gist_id}","starred_url":"https://api.github.com/users/muellekl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muellekl/subscriptions","organizations_url":"https://api.github.com/users/muellekl/orgs","repos_url":"https://api.github.com/users/muellekl/repos","events_url":"https://api.github.com/users/muellekl/events{/privacy}","received_events_url":"https://api.github.com/users/muellekl/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-06-12T08:19:48Z","updated_at":"2015-06-17T16:57:53Z","closed_at":"2015-06-17T14:15:09Z","body":"I've already reported my problem here: http://jackson-users.ning.com/forum/topics/unresolvedforwardreference-when-using-jsonidentityinfo-jackson-2\r\n\r\nTo briefly sum it up: The test classes I'm using are annotated with @JsonIdentityInfo and for the serialization I activated default typing. When trying to deserialize my json string, I receive a \"UnresolvedForwardReference\" error. \r\n\r\nThe following JUnit4 test demonstrates this.\r\n```\r\nimport java.io.IOException;\r\n\r\nimport org.junit.Test;\r\n\r\nimport com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;\r\nimport com.fasterxml.jackson.annotation.JsonInclude.Include;\r\nimport com.fasterxml.jackson.annotation.PropertyAccessor;\r\nimport com.fasterxml.jackson.databind.DeserializationFeature;\r\nimport com.fasterxml.jackson.databind.ObjectMapper;\r\n\r\nimport de.jackson.test.TestA;\r\nimport de.jackson.test.TestC;\r\nimport de.jackson.test.TestD;\r\n\r\npublic class JsonTest {\r\n\r\n    @Test\r\n    public void testDeserialize() throws IOException {\r\n        TestA a = new TestA();\r\n        a.setOidString(\"oidA\");\r\n        \r\n        TestC c = new TestC();\r\n        c.setOidString(\"oidC\");\r\n        \r\n        a.setTestAbst(c);\r\n        \r\n        TestD d = new TestD();\r\n        d.setOidString(\"oidD\");\r\n        \r\n        c.setD(d);\r\n        a.setD(d);\r\n        \r\n        String json = serializeIntoString(a);\r\n        System.out.println(\"JSON: \" + json);\r\n        TestA testADeserialized = deserializeFromString(json, TestA.class);\r\n        //access testADeserialized\r\n    }\r\n    \r\n    protected <T> String serializeIntoString(T obj) throws IOException {\r\n        ObjectMapper om = new ObjectMapper();\r\n        om.enableDefaultTyping(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE);\r\n        om.setSerializationInclusion(Include.NON_NULL);\r\n        om.setSerializationInclusion(Include.NON_EMPTY);\r\n        om.setVisibility(PropertyAccessor.ALL, Visibility.NONE);\r\n        om.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);\r\n        \r\n        return om.writeValueAsString(obj);\r\n    }\r\n    \r\n    public static <T> T deserializeFromString(String jsonStr, Class<T> classFile) throws IOException {\r\n        ObjectMapper om = new ObjectMapper();\r\n        om.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);\r\n        om.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);\r\n        om.enableDefaultTyping(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE);\r\n        T obj = om.readValue(jsonStr, classFile);\r\n        return obj;\r\n    }\r\n}\r\n```\r\n\r\nMoreover, here is the source code of the test classes used. In the following, at first AbstractEntity:\r\n\r\n```\r\npackage de.jackson.test;\r\n\r\nimport com.fasterxml.jackson.annotation.JsonIdentityInfo;\r\nimport com.fasterxml.jackson.annotation.ObjectIdGenerators;\r\n\r\n@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property=\"oidString\")\r\npublic class AbstractEntity {\r\n\r\n    private String oidString;\r\n\r\n    public String getOidString() {\r\n        return oidString;\r\n    }\r\n\r\n    public void setOidString(String oidString) {\r\n        this.oidString = oidString;\r\n    }\r\n}\r\n```\r\n\r\nNext TestA:\r\n```\r\npackage de.jackson.test;\r\n\r\npublic class TestA extends AbstractEntity {\r\n    private TestAbst testAbst;\r\n    private TestD d;\r\n    \r\n    public TestAbst getTestAbst() {\r\n        return testAbst;\r\n    }\r\n    public void setTestAbst(TestAbst testAbst) {\r\n        this.testAbst = testAbst;\r\n    }\r\n    public TestD getD() {\r\n        return d;\r\n    }\r\n    public void setD(TestD d) {\r\n        this.d = d;\r\n    }\r\n}\r\n```\r\nNext TestAbst:\r\n```\r\npackage de.jackson.test;\r\n\r\npublic class TestAbst extends AbstractEntity {\r\n}\r\n```\r\n\r\nNext TestC:\r\n```\r\npackage de.jackson.test;\r\n\r\npublic class TestC extends TestAbst {\r\n    private TestD d;\r\n\r\n    public TestD getD() {\r\n        return d;\r\n    }\r\n\r\n    public void setD(TestD d) {\r\n        this.d = d;\r\n    }\r\n}\r\n```\r\n\r\nNext TestD:\r\n```\r\npackage de.jackson.test;\r\n\r\npublic class TestD extends AbstractEntity {\r\n}\r\n```\r\n\r\nI tested this with Jackson 2.4.0 and Jackson 2.5.0."},"comment":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/comments/112876499","html_url":"https://github.com/FasterXML/jackson-databind/issues/825#issuecomment-112876499","issue_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/825","id":112876499,"user":{"login":"cowtowncoder","id":55065,"avatar_url":"https://avatars.githubusercontent.com/u/55065?v=3","gravatar_id":"","url":"https://api.github.com/users/cowtowncoder","html_url":"https://github.com/cowtowncoder","followers_url":"https://api.github.com/users/cowtowncoder/followers","following_url":"https://api.github.com/users/cowtowncoder/following{/other_user}","gists_url":"https://api.github.com/users/cowtowncoder/gists{/gist_id}","starred_url":"https://api.github.com/users/cowtowncoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cowtowncoder/subscriptions","organizations_url":"https://api.github.com/users/cowtowncoder/orgs","repos_url":"https://api.github.com/users/cowtowncoder/repos","events_url":"https://api.github.com/users/cowtowncoder/events{/privacy}","received_events_url":"https://api.github.com/users/cowtowncoder/received_events","type":"User","site_admin":false},"created_at":"2015-06-17T16:57:53Z","updated_at":"2015-06-17T16:57:53Z","body":"`NON_FINAL` should still work as long as the actual type being serialized and nominal type used for deserialization are both non-final. If not, that would still be a bug.\r\n\r\n"}}