Personally, I am married and have a very active two-year old, Kaitlyn, who is an honorary member of the GWT team by virtue of attending several GWT project meetings. Restoring old houses (in specific my own), board games, and politics number highly amongst my hobbies.
It's nice to meet you all!
JavaScriptObject
. JavaScriptObject
.
A JavaScriptObjectshould be able to implement at least a limited set of interfaces.JavaScriptObject
JavaScriptObject
in the following ways: Object
JavaScriptInterface
instanceof
support
JavaScriptObject
, requiring manual wrapping of JavaScriptObject
in many cases. JavaScriptObject
JavaScriptObject
is upcast or are assigned additional fields, they are wrapped in a proxy object. All normal Object operations, such as polymorphism and instance of are supported.
'==' is replaced by a method to first dereference proxies before calling "==" .
The overhead for creating JavaScript method calls is very low , so the expected overhead for replacing '==' is very low.
The overhead for creating int
auto boxing proxy objects is reasonably low so the expected overhead for creating JavaScriptObject
proxy objects is also reasonably low.
Pros
JavaScriptObject
JavaScriptObject
must implement a static instanceOf(JavaScriptObject
) method, which returns whether the passed in JavaScriptObject
is an instance of the given class.
Gather the set of Interfaces any JavaScriptObject
inherits. If a JavaScriptObject
is ever cast as an Object, also include Object.
All dispatches, instanceofs and casts from that set must first check to see if the object extends JavaScriptObject
. If it does, then use the instanceOf methods to check which one.
Dynamic dispatch is supported. No fields can be added to the class.
JavaScriptObject
Object
hashCode, toString, and equals.
instanceOf
method can produce hard-to-debug crashes.
JavaScriptObject
classes can change behavior in working code by "stealing" the object's dispatch
- No casting to Object
Seems like almost a deal breaker to me.
Just a quick question about Proposal #2:
>When JavaScriptObject is upcast or are assigned additional fields, they are
>wrapped in a proxy object. All normal Object operations, such as
>polymorphism and instance of are supported.
Forgive me for not knowing, but it seems like, while in many cases the
overhead of these proxies might be low, the XML DOM classes used in
com.google.gwt.xml.client would seem like they would begin generating
inordinate numbers of proxies, no?
My first response is Proposal #3 would seem to be the best here. While
the Con of:
>5. Complex to explain to user
is a pretty big one, I think the number of end users who are actually
going to be implementing something that directly extends
JavaScriptObject is going to be few.
Between #2 and #3 it seems like the big question is just how much the
speed overhead is for calls to .equals and .hashCode. If it is fairly
minimal, I tend to opt in that direction for the basic reason that a
good sized GWT application can really expand to take a lot of RAM right
now, and on a family computer with 512mb, big browser usage can really
make the performance seem horrible. While the proxies used in #2 might
individually be small, it is my experience that when you want to juggle
JSOs, you want to juggle a LOT of them.
I support not trying to maintain "==" behavior. The example of
auto-boxing an int and using == for auto-boxed int only works up to
127. After that you must use equals because Java only does a lookup for
small ints boxed to Integers.
Just a quick question about Proposal #2:
>When JavaScriptObject is upcast or are assigned additional fields, they are
>wrapped in a proxy object. All normal Object operations, such as
>polymorphism and instance of are supported.
Forgive me for not knowing, but it seems like, while in many cases the
overhead of these proxies might be low, the XML DOM classes used in
com.google.gwt.xml.client would seem like they would begin generating
inordinate numbers of proxies, no?
My first response is Proposal #3 would seem to be the best here. While
the Con of:
>5. Complex to explain to user
is a pretty big one, I think the number of end users who are actually
going to be implementing something that directly extends
JavaScriptObject is going to be few.
> Scott