The only alternative is to use XStream annotations :
package com.my.incredibly.long.package.name; @XStreamAlias("dic") public class Dic { ...
Then in your code, where you configure XStream:
xstream.processAnnotations(Dic.class); // OR xstream.autodetectAnnotations(true);
The problem is that XStream already knows its aliases to deserialize your classes, so autodetectAnnotations(true) will NOT help if you cannot guarantee that you will serialize the class before deserializing. Plus (and this may or may not be a problem for you), you introduce an explicit XStream dependency with your objects.
I put the tags of all the classes that I need, are serialized (here are several options: annotate them via XStream or my own annotation, embed the marker interface in them, capture all classes from a specific package (s)), auto-detect them to load, and explicitly configure the XStream instance for an alias as a class name without a package name.
source share