yields infinite loop in export() method in some instances
Comment #1
Posted on Mar 2, 2009 by Happy MonkeyHello,
This happens for this two classes (with gwt-exporter checked out from trunk):
@Exportable class A { public B convertToB() { new A(); } }
@Exportable class B { public A convertToA() { new B(); } }
gwt-exporter generates two additional classes:
class AExporterImpl {
void export0() { ... }
void export() {
...;
((Exporter) GWT.create(B.class)).export(); // [*]
}
}
class BExporterImpl {
void export0() { ... }
void export() {
...;
((Exporter) GWT.create(A.class)).export(); // [*]
}
}
I think lines marked with [*] are generated to not force programmer to call "GWT.create(..).export()" for all exported classes. But it does not work not only with above classes. Consider simple class hierarchy:
@Export class A { }
@Export class B extends A { }
@Export class C extends A { }
There is no way for programmer to not call GWT.create(...).export() for at lest two classes.
All this convince me that it is bad approach to call GWT.create(...).export() from export() method. Programmer should do this in EntryPoint.
Commenting out for loop in method genExportMethod() in class ClassExporter is enough to fix above problems. Unfortunately this simple fix leads to lots of unused or unnecessary code: methods exportDependentClass(), exportDependentParams() and fields "visited" and "exported" in class ClassExporter.
Best regards, Radoslaw Kintzi
PS. gwt-exporter is really good piece of code
Comment #2
Posted on Jun 30, 2011 by Grumpy ElephantThe loop does not happen anymore since each exported class maintain a flat in order not to export twice.
Super classes are not exported unless they are used in any exported method or the programmer calls exportAll. When the programmer uses GWT.create() he has the control of which classes to export (except for exportable classes used in methods which will be export by convenience). BTW export() method is deprecated GWT.create() is enough to export any class. See r50.
- Manolo
Status: Fixed
Labels:
Type-Defect
Priority-Medium