Marshalling of AbstractList$Sublist
jannis Aug 13, 2014 9:34 AMHello,
we encountered a problem when marshalling a bean with a generic value field:
@Portable public class PortableValueEntity<T> { private T value; public T getValue() { return value; } public void setValue(T value) { this.value = value; } }
If a sub list is passed to the value field we get the following error:" no marshalling definition available for type:java.util.AbstractList$SubList"
Defining an alias like "errai.marshalling.mappingAliases=java.util.AbstractList$SubList->java.util.List" leads to an error if not running in production mode: "could not find class defined in ErraiApp.properties for mapping: java.util.AbstractList$SubList->java.util.List".
If I got it correctly the problem is that in Java there is no nested class SubList in AbstractList (although there is that class in the AbstractList.java file), but the emulated class AbstractList has the nested class SubList.
Is there any solution to this problem?
Thanks in advance
Jannis
A test to reproduce this issue is as follows:
Module: SubListMarshalTest
<module> <inherits name="org.jboss.errai.common.ErraiCommon" /> <inherits name='org.jboss.errai.marshalling.ErraiMarshalling' /> </module>
public class MarshalSubListClientTestGwt extends GWTTestCase { @Override public String getModuleName() { return "path.to.SubListMarshalTest"; } @Override protected void gwtSetUp() throws Exception { super.gwtSetUp(); MarshallerFramework.initializeDefaultSessionProvider(); } public void testMarshallingArraysSubList() { PortableValueEntity<List<Integer>> entity = new PortableValueEntity<>(); List<Integer> values = Arrays.asList(0, 1, 2, 3, 4, 5); // Also works with ArrayList and LinkedList List<Integer> value = values.subList(2, 4); entity.setValue(value); String json = Marshalling.toJSON(entity); PortableValueEntity<List<Integer>> demarshalledEntity = Marshalling.fromJSON(json, PortableValueEntity.class); assertEquals(value, demarshalledEntity.getValue()); } }
The test has to be executed in production mode.