Enum serialization error with Java 17
bergerdenes opened this issue · comments
I have created a test scenario, with an enum and a class with a field typed to this enum.
public enum SimpleEnum {
ONE, TWO
}
(...)
public class SimpleClass {
private final String name;
private final SimpleEnum myEnum;
public SimpleClass(String name, SimpleEnum myEnum) {
this.name = name;
this.myEnum = myEnum;
}
public String getName() {
return name;
}
public SimpleEnum getMyEnum() {
return myEnum;
}
}
When I try to serialize this class with Java 17, the enum value is serialized to null
SimpleClass mc = new SimpleClass("MyName", SimpleEnum.ONE);
System.out.println(JsonWriter.objectToJson(mc));
output:
{"@type":"myPackage.SimpleClass","name":"MyName","myEnum":{"name":null}}
#156
maybe this help? i try to set this : "--illegal-access=deny" on jvm parameters, it works, the same between jdk11 and jdk17
#156 maybe this help? i try to set this : "--illegal-access=deny" on jvm parameters, it works, the same between jdk11 and jdk17
OpenJDK 64-Bit Server VM warning: Ignoring option --illegal-access=deny; support was removed in 17.0
And it does not work either.
Recent fixes to include serialization of Enums were added and included in json-io 4.14.0. Please let me know if that corrects this issue for you.
It works now but too late, moved away from this lib to Jackson last July