Issue Details (XML | Word | Printable)

Key: XSTR-425
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Joerg Schaible
Reporter: Paul van der Maas
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
XStream

NPE thrown when @XStreamImplicit is used on collection with interface parameter type

Created: 04/Sep/07 04:06 PM   Updated: 25/Feb/08 05:01 PM
Component/s: Annotations
Affects Version/s: Upcoming
Fix Version/s: 1.3

File Attachments: 1. Java Source File Main.java (0.4 kB)
2. Java Source File XStreamTest.java (0.3 kB)

Issue Links:
Duplicate
 

JDK version and platform: Sun 1.6.0_02 for Windows


 Description  « Hide
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.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Joerg Schaible added a comment - 23/Nov/07 04:37 PM
Works on the head revision, you may give it a try.

Joerg Schaible added a comment - 25/Feb/08 05:01 PM
Closing issues before next release.