History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-404
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Guilherme Silveira
Reporter: Klaus Rheinwald
Votes: 0
Watchers: 2
Operations

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

@XStreamImplicit() for ArrayList<ArrayList<Type>> throws ClassCastException

Created: 01/Jun/07 06:13 PM   Updated: 25/Feb/08 05:01 PM
Component/s: Core
Affects Version/s: 1.2.2
Fix Version/s: 1.3

JDK version and platform: Sun 1.5.0_1 for Windows


 Description  « Hide
...
@XStreamImplicit(itemFieldName="line")
ArrayList<ArrayList<Point>> lines;
...
Annotations.configureAliases(xstream, PolyLine.class); ...

throws

java.lang.ClassCastException:
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
         at com.thoughtworks.xstream.annotations.Annotations.getFieldParameterizedType(Annotations.java:226)
        at com.thoughtworks.xstream.annotations.Annotations.configureClass(Annotations.java:161)
        at com.thoughtworks.xstream.annotations.Annotations.configureAliases(Annotations.java:49)

when configureAliases() is executed.

The old code I used for 1.2.1 still works and is a viable (although ugly) workaround:

xstream.addImplicitCollection(PolyLine.class, "lines", "line", ArrayList.class); // Workaround


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Guilherme Silveira - 01/Jun/07 08:56 PM
Commited possible solution which allows ParameterizedTypes to contain other ParameterizedTypes.

Joerg Schaible - 11/Jun/07 04:34 AM
Set resolution to fixed, still waiting for Klaus' comment and closing of the issue ...

Paul van der Maas - 03/Sep/07 09:26 PM
This fix probably also fixes my issue, but I wanted to let you know anyway, so you can test it.

The problem Klaus is referring to also comes up when you use the @XStreamContainedType annotation on a type where the parameter type is also a parameterized type:

@XStreamContainedType()
public List<List<CarModel>> carModels = new ArrayList<List<CarModel>>();

Here's the exception:

java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
        at com.thoughtworks.xstream.annotations.Annotations.configureParameterizedTypes(Annotations.java:249)
        at com.thoughtworks.xstream.annotations.Annotations.configureClass(Annotations.java:132)
        at com.thoughtworks.xstream.annotations.Annotations.configureAliases(Annotations.java:49)

Also, I was wondering if the fix actually looked at contained types in contained types, or if it is just a superficial fix.
For instance, in my example, if I had an alias defined for CarModel, would the alias be registered or not? I think it should be.

I couldn't get a 'lastest snapshot' from your repository, the links on this page don't work:
http://xstream.codehaus.org/download.html

How do I get a recent snapshot?

Thanks,

Paul

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