Public constructors in exportable classes

91 views
Skip to first unread message

Douglas Hoskins

unread,
Sep 25, 2012, 6:50:33 AM9/25/12
to gwtex...@googlegroups.com
Hi

Not sure if anybody is around on this group at the moment...

GWT Exporter currently fails silently if it meets an Exportable class whose public constructor accepts arguments other than a JavaScriptObject.

Two unrelated questions about this:

1)  Is there a technical reason why can't exportable classes can't have constructors accepting Strings, primitives, other Exportables, and arrays of those?
2)  Could we have at least a warning at compile time about this?  It would be most helpful (IMO compilation should actually fail because of this).

Manuel Carrasco Moñino

unread,
Sep 27, 2012, 12:15:39 PM9/27/12
to gwtex...@googlegroups.com
On Tue, Sep 25, 2012 at 12:50 PM, Douglas Hoskins <douglas...@futureplatforms.com> wrote:
Hi

Not sure if anybody is around on this group at the moment...

Yes, normally I read it periodically
 

GWT Exporter currently fails silently if it meets an Exportable class whose public constructor accepts arguments other than a JavaScriptObject.

This should work, what it is unsupported in exporter is constructor overloading with the same number of arguments, but you could pass any object as parameter. 

 

Two unrelated questions about this:

1)  Is there a technical reason why can't exportable classes can't have constructors accepting Strings, primitives, other Exportables, and arrays of those?

see comment above 
 
2)  Could we have at least a warning at compile time about this?  It would be most helpful (IMO compilation should actually fail because of this).

Yes, generator could fail in certain circumstances, but we have not added those assertions.
Maybe we could define all the cases where compiler should fail, not only in this case.
 

--
 
 

Rich Burdon

unread,
Mar 20, 2013, 3:49:32 PM3/20/13
to gwtex...@googlegroups.com
It seems to me also that non-default constructors are not supported. (i.e., currently broken in 2.4.0)

E.g., 

@Export
@ExportPackage("test")
public class Test implements Exportable {
  public Test(String foo) {}
}

Causes the following runtime error.

[INFO] [[[TypeError: net.sourceforge.htmlunit.corejs.javascript.Undefined@4300ec4 is not a function, it is undefined.]]]

Similarly, ExportConstructor fails silently. And I found several other bugs while building my own tests. (I don't know if this project is still underdevelopment, but adding some unit tests would be really useful.)

Rich

Manuel Carrasco Moñino

unread,
Apr 3, 2013, 8:22:11 AM4/3/13
to gwtex...@googlegroups.com
On Wed, Mar 20, 2013 at 8:49 PM, Rich Burdon <rich....@gmail.com> wrote:
It seems to me also that non-default constructors are not supported. (i.e., currently broken in 2.4.0)

E.g., 

@Export
@ExportPackage("test")
public class Test implements Exportable {
  public Test(String foo) {}
}

Non-default constructors are supported, this code works to me with 2.5.0-SNAPSHOT and 2.4.0, and this code works in js:

var v1 = new test.Test();
var v2 = new test.Test("foo");
 

Causes the following runtime error.

[INFO] [[[TypeError: net.sourceforge.htmlunit.corejs.javascript.Undefined@4300ec4 is not a function, it is undefined.]]]


Could you send your junit test?
 

Similarly, ExportConstructor fails silently. And I found several other bugs while building my own tests. (I don't know if this project is still underdevelopment, but adding some unit tests would be really useful.)

This project is very stable and issues are fixed or new features are added periodically.

Gwtexporter is full junit-tested, take a look to it testsuite:

If your look into the core test class, you can see all use-cases gwt-query supports







 

Rich








On Thursday, September 27, 2012 12:15:40 PM UTC-4, Manuel Carrasco Moñino wrote:


On Tue, Sep 25, 2012 at 12:50 PM, Douglas Hoskins <douglas...@futureplatforms.com> wrote:
Hi

Not sure if anybody is around on this group at the moment...

Yes, normally I read it periodically
 

GWT Exporter currently fails silently if it meets an Exportable class whose public constructor accepts arguments other than a JavaScriptObject.

This should work, what it is unsupported in exporter is constructor overloading with the same number of arguments, but you could pass any object as parameter. 

 

Two unrelated questions about this:

1)  Is there a technical reason why can't exportable classes can't have constructors accepting Strings, primitives, other Exportables, and arrays of those?

see comment above 
 
2)  Could we have at least a warning at compile time about this?  It would be most helpful (IMO compilation should actually fail because of this).

Yes, generator could fail in certain circumstances, but we have not added those assertions.
Maybe we could define all the cases where compiler should fail, not only in this case.
 

--
 
 

--
Has recibido este mensaje porque estás suscrito al grupo "gwtexporter" de Grupos de Google.
Para anular la suscripción a este grupo y dejar de recibir sus correos electrónicos, envía un correo electrónico a gwtexporter...@googlegroups.com.
Para obtener más opciones, visita https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages