Hi there,
maybe I have an regression issue with Jackson 2.10.. but maybe I doing 
something wrong... hope you can help me out.

A simple Test shows the problem. We having a class like this:

@JsonTypeInfo(
    use = JsonTypeInfo.Id.MINIMAL_CLASS,
    include = JsonTypeInfo.As.PROPERTY,
    property = "@class"
)
public class EnumContaintingClass <ENUM_TYPE extends Enum<ENUM_TYPE>> {
   private ENUM_TYPE selected;
   private List<ENUM_TYPE> options;

  public EnumContaintingClass(){
  }

  public EnumContaintingClass(ENUM_TYPE selected, Class<ENUM_TYPE> cls) {
    this.selected = selected;
    readOptionsFromEnum(cls);
  }

  private void readOptionsFromEnum(Class < ENUM_TYPE > enumClass) {
    ENUM_TYPE[] enumConstants = enumClass.getEnumConstants();
    options = Arrays.asList(enumConstants);
  }
  // getter and setter here..
}


And a Test for a roundtrip:

public class JacksonTestCase {
  public enum TestEnum { FIRST, SECOND, THIRD; }

  @Test
  public void serialize() throws IOException {
    EnumContaintingClass gui = new EnumContaintingClass(TestEnum.SECOND, 
TestEnum.class);
    ObjectMapper mapper = new ObjectMapper();
    String str = mapper.writer().writeValueAsString(gui);
    Object o = mapper.readerFor(EnumContaintingClass.class).readValue(str);
    Assert.assertNotNull(o);
  }
}


Serializing works fine but deserzializing fails with 

*Cannot deserialize Class java.lang.Enum (of type enum) as a Bean*


This testcase works fine with the latest 2.9 Jackson but with 2.10 it fails.
I tried to add the TypeInfos also to the member but this didn't make it 
works. The only thing I could do is changing from <ENUM_TYPE extends Enum<
ENUM_TYPE>> to <ENUM_TYPE>.
But that is not what we want to have, only Enums shall be allowed there (to 
indicate this I added the readOptionsFromEnum-Method).

So please could you guide me how to make this work in Jackson 2.10 or is 
this an regression issue?

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/00cb0285-019e-4a9d-b3b3-12b38a4786a6%40googlegroups.com.

Reply via email to