Hi Jackson-Users,
I have a problem after updating to Jackson 2.10. on 2.9 everythings works 
fine.

This is a tiny Test that reproduce the problem.
We have a class with a generic parameter that has to be an enum.

@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 setters here
}



And a Test trying to serialize and deserialize an entity of this class:

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);
  }
}




With Jackson 2.9.10 this works fine but after a update to 2.10 this fails 
on deserializing with the Message:
"Cannot deserialize Class java.lang.Enum (of type enum) as a Bean"

I tried adding the TypeInfos also to the members but that doesn't helped.
When I change <ENUM_TYPE extends Enum<ENUM_TYPE>> to <ENUM_TYPE>. 
Everything is fine, but then I can not ensure that only Enums are used for 
this generic parameter (to show this i added the readOptionsFromEnum-Method
). 


Hope you can help me get this working with Jackson 2.10.

Kind regards
Tim 

P.S. hope I didn't post twice, but I can not find my first attempt to post 
this :-/

-- 
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/0b7c7a9f-95ff-4968-ad8b-2736e6141de5%40googlegroups.com.

Reply via email to