To anyone interested.
The only way I've found to write "GWT.create(A<T>.class) is to define
an intermediary class/interface:
interface FileSystemParser extends Parser<FileSystem> {}
So I wrote:
GWT.create(FileSystemParser.class) ;
And in my generator i walk through the implemented interfaces to find
my marker (Parser<T>) and the enclosed type (ie. FileSystem):
JClassType markerClass =
((JClassType) context.getTypeOracle().parse(
Parser.class.getName())).getErasedType();
JClassType dataClass = null;
JClassType typeClass =
(JClassType) context.getTypeOracle().parse(typeName);
JClassType interfs[] = typeClass.getImplementedInterfaces();
for (int i = 0; i < interfs.length; ++i) {
JClassType interf = interfs[i];
if ((interf instanceof JParameterizedType)
&& (((JParameterizedType) interf).getErasedType() ==
markerClass)) {
dataClass = ((JParameterizedType) interf).getTypeArgs()[0];
}
}
// dataClass contains FileSystem
This works but need more code (an intermediary interface) that can
become heavy if you have many generics that use deferred binding. For
my purpose it's the problem. JAXB can generate one class per XML
element. And each class need its parser. So I have to write an
interface per class (this can be automatic generated for child element
in father element's parser...).
The only other way is to add a GWT.create method that takes more than
one argument; the second and so on being the enclosed types. But it
need change in many compiler classes.
If this can help someone...
Olivier.