After enabling AfterburnerModule I am seeing the below warning message in the logs. Without AfterburnerModule everything works fine.
Sep 06, 2017 9:11:39 AM com.fasterxml.jackson.module.afterburner.deser.BeanPropertyMutator _reportProblem
WARNING: Disabling Afterburner deserialization for class com.test.Child (field #0; mutator com.test.Child$Access4JacksonDeserializerdc6e0fab), due to access error (type java.lang.IllegalAccessError, message=tried to access method com.test.test2.Parent.setSurname(Ljava/lang/String;)V from class com.test.Child$Access4JacksonDeserializerdc6e0fab)
java.lang.IllegalAccessError: tried to access method com.test.test2.Parent.setSurname(Ljava/lang/String;)V from class com.test.Child$Access4JacksonDeserializerdc6e0fab
at com.test.Child$Access4JacksonDeserializerdc6e0fab.stringSetter(com/test/Child$Access4JacksonDeserializer.java)
at com.fasterxml.jackson.module.afterburner.deser.BeanPropertyMutator.stringSetter(BeanPropertyMutator.java:123)
at com.fasterxml.jackson.module.afterburner.deser.SettableStringMethodProperty.deserializeAndSet(SettableStringMethodProperty.java:60)
at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:156)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3807)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2797)
at com.test.JacksonStuff.main(JacksonStuff.java:19)
My class are as follows:
package com.test.test2;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Parent {
@JsonProperty("surname")
private String surname;
protected Parent() {
}
public Parent(String surname) {
this.surname = surname;
}
public String getSurname() {
return surname;
}
protected void setSurname(String surname) {
this.surname = surname;
}}
package com.test;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.test.test2.Parent;
public class Child extends Parent {
@JsonProperty("name")
private String test;
public Child() {
super();
}
public Child(String var1) {
super(var1);
}
public String getTest() {
return test;
}
public void setTest(String test) {
this.test = test;
}}
package com.test;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
import java.io.IOException;
public class JacksonStuff {
public static void main(String[] args) throws IOException {
ObjectMapper mapper = new ObjectMapper();
AfterburnerModule module = new AfterburnerModule();
mapper.registerModule(module);
String json = "{\"surname\":\"abc\"}";
Child value = mapper.readValue(json, Child.class);
}}
How do I avoid getting this warning in the logs? I cannot modify parent.java as it is from a third party lib and not under my control.
Because
void setSurname
isprotected
. Set it topublic
.