Hi Tobias,
it seems you're the first one who tries to serialize something like that.
Please open a JIRA issue and I try to look into it in the next two weeks.
Cheers,
Jörg
Tobias Gierke wrote:
> Hi,
>
> It seems we're not able to deserialize Lambda expressions with XStream
> 1.4.7
>
> The code in question looks roughly like this:
>
> @FunctionalInterface
> public interface Visible extends Serializable {
> public boolean isVisible();
> }
>
> public interface IMenuItem extends Serializable {
> // ... stuff omitted ...
> }
>
> public abstract class AbstractMenuItem implements IMenuItem {
> private final Visible visibilityFunction;
> // ... stuff omitted ...
> }
>
> The method that is invoked with lambda expressions (that later get
> stored in the 'visibilityFunction' field of an AbstractMenuItem subclass
> instance) looks like this:
>
> public <T extends Page> void addEntry(String resourceLabel , Class<T>
> pageClazz,Visible visibilityFunction);
>
> Since the Visible interface extends Serializable , the compiler
> generates code for a serializable Lambda (and in fact it does, I checked
> the generated .class file with javap).
>
> The code used to setup XStream looks like this:
>
> private XStream createXStream()
> {
> final XStream xstream = new XStream( new StaxDriver() ) {
> @Override
> protected MapperWrapper wrapMapper(MapperWrapper next) {
> return new WicketProxyMapper( new CGLIBMapper( new
> HibernateMapper(next) ) ); //
> }
> };
>
> // override the built-in DynamicProxyConverter that chokes on
> Apache Wicket proxies
> xstream.registerConverter( new WicketProxyConverter() ,
> XStream.PRIORITY_VERY_HIGH );
>
> // register Hibernate-specific converters
> xstream.registerConverter(new HibernateProxyConverter());
> xstream.registerConverter(new
> HibernatePersistentCollectionConverter(xstream.getMapper()));
> xstream.registerConverter(new
> HibernatePersistentMapConverter(xstream.getMapper()));
> xstream.registerConverter(new
> HibernatePersistentSortedMapConverter(xstream.getMapper()));
> xstream.registerConverter(new
> HibernatePersistentSortedSetConverter(xstream.getMapper()));
>
> // register CGLLib converters
> xstream.registerConverter(new
> CGLIBEnhancedConverter(xstream.getMapper(),
> xstream.getReflectionProvider() , getClass().getClassLoader() ) );
>
> return xstream;
> }
>
>
> Before I start diving into the world of invokedynamic and method handles
> , did anybody else encounter this issue and knows how to solve it ?
>
> Cheers,
> Tobias
>
>
> com.thoughtworks.xstream.converters.ConversionException:
>
com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$$Lambda$124/1803727536
> :
>
com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$$Lambda$124/1803727536
> ---- Debugging information ----
> message :
>
com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$$Lambda$124/1803727536
> cause-exception :
> com.thoughtworks.xstream.mapper.CannotResolveClassException
> cause-message :
>
com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$$Lambda$124/1803727536
> class :
> com.vodecc.voipmng.boundary.wicket.general.PageWithHeaderAndFooter$11
> required-type :
> com.vodecc.voipmng.boundary.wicket.general.PageWithHeaderAndFooter$11
> converter-type :
> com.thoughtworks.xstream.converters.reflection.ReflectionConverter
> path :
>
/com.vodecc.voipmng.boundary.wicket.trunkmonitor.TrunkMonitorPage/children/com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$1/children/com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$1$1[2]/children/com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$SubMenuList/children/children/org.apache.wicket.markup.html.list.ListItem/children/children/com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$NestedListEntry$1/children/org.apache.wicket.markup.html.list.ListItem[3]/children/children/val$visibilityFunction
> line number : 1
> class[1] :
> com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$SimpleListEntry
> class[2] : org.apache.wicket.markup.html.list.ListItem
> class[3] : [Ljava.lang.Object;
> converter-type[1] :
> com.thoughtworks.xstream.converters.collections.ArrayConverter
> class[4] :
> com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$NestedListEntry$1
> class[5] :
> com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$NestedListEntry
> class[6] :
> com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$SubMenuList$1
> class[7] :
> com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$SubMenuList
> class[8] :
> com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$1$1
> class[9] :
> com.vodecc.voipmng.boundary.wicket.general.PageWithMenu$1
> class[10] :
> com.vodecc.voipmng.boundary.wicket.trunkmonitor.TrunkMonitorPage
> version : not available
> -------------------------------
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email