[Simple-support] can't serialize an object which uses a parametrized hashmap
Brought to you by:
niallg
|
From: Joe <fis...@ya...> - 2009-04-01 14:45:16
|
Hi,
the following code throws an exception.
But if i replace T by String, serialization is no problem.
Why the parametrized version doesn't work?
Version: 2.0.4
import java.io.File;
import java.util.HashMap;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
public class MyMap<T>
{
@ElementMap
private HashMap<T, String> map = new HashMap<T, String>();
public static void main(String[] args)
{
try
{
serialize(new MyMap<String>());
System.out.println("done");
}
catch (Exception e)
{
e.printStackTrace();
}
}
private static void serialize(Object data) throws Exception
{
Serializer serializer = new Persister();
File xmlFile = new File("test.xml");
serializer.write(data, xmlFile);
}
}
|