I've found the bug in the logic of handling enums: in the method org.simpleframework.xml.transform.PackageMatcher#matchEnum this is not sufficient to check if class is enum, also check of the parent class is needed. Here is the example of failing test:
@Test
public void testFoo() throws Exception {
final Serializer serializer = new Persister();
final FooObject fooObject = new FooObject();
fooObject.setFoo(Foo.NAY);
serializer.write(fooObject, new StringWriter());
}
@Root
public static class FooObject {
@Element
private Foo foo;
public FooObject() {
}
public Foo getFoo() {
return foo;
}
public void setFoo(Foo foo) {
this.foo = foo;
}
}
public static enum Foo {
YEA {
public boolean foo() {
return true;
}
},
NAY {
public boolean foo() {
return false;
}
};
public abstract boolean foo();
}
The problem is in the abstract method in the enum.