Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: Upcoming
-
Fix Version/s: 1.3
-
Component/s: Annotations
-
Labels:None
-
JDK version and platform:Sun 1.6.0_02 for Windows
Description
There is a bug (version: 1.3.0-SNAPSHOT Sep 4, 2007) that prevents one from using the @XStreamImplicit annotation on elements that have an interface type as the parameter type. Here is an example that shows the bug:
@XStreamImplicit()
private ArrayList<Map> list = new ArrayList<Map>(); // Notice the parameter type is an interface (Map).
It will work when written like so:
@XStreamImplicit()
private ArrayList<HashMap> list = new ArrayList<HashMap>(); // Notice the parameter type is not an interface (HashMap).
I have tracked the bug down to the if statement on line 233 in com.thoughtworks.xstream.annotations.Annotations.
It checks if the parameterized type is an interface, and if so, it assumes it has an XStreamAlias (seems odd to begin with) annotation and tries to retrieve it (line 235). If the interface does not have an XStreamAlias annotation, the getAnnotation() method returns null, and the statement on line 237 will fail because it tries to invoke the impl() method on a null reference.
Try the attached code for yourself.
Thanks,
Paul van der Maas
P.S. I may write a patch myself, once I figure out how to work with NetBeans/SubVersion/Maven . Any help on that would be appreciated to.
Works on the head revision, you may give it a try.