If you use JavaScriptObjects, r8249 changes Dev (Hosted)
Mode in three ways you might care about. Production (Web) mode
behavior is unaffected by this change.

 1) Method invocations on null JSO instances will throw a
NullPointerException instead of quasi-succeeding [1].  This should
help catch errors before code is deployed.

 2) You can use Generators to produce new subtypes of JavaScriptObject.

 3) If you cast a JSO instance to an interface type which is
implemented by a JSO subtype, you will receive a ClassCastException if
the JSO subtype has not yet been loaded in DevMode.  If you wrote code
that looks like:

   interface ProtocolMessage { void someMethod(); }
   class JsoProtocolMessage extends JavaScriptObject implements
ProtocolMessage {}
   field = (ProtocolMessage) evalAndReturnJso("someJson");

and see a ClassCastException with the following message:

 There is no known JavaScriptObject subtype that implements
com.google.ProtocolMessage. Fix by adding an @SingleJsoImpl annotation
to ProtocolMessage or by referencing the concrete JSO type.

This can be remedied in all situations by applying the
com.google.gwt.core.client.SingleJsoImpl annotation to the interface,
which specifies the JSO subtype that will implement the interface.

 @SingleJsoImpl(JsoProtocolMessage.class)
 interface ProtocolMessage { void someMethod(); }

 For interfaces shared between client and server code, or cases where
the implementing JSO type isn't normally available to your IDE (such
as externally generated JSO types), the SingleJsoImplName
annotation takes the binary name of the implementing type instead of a
class literal.

 @SingleJsoImplName("com.google.JsoProtocolMessage")
 interface ProtocolMessage { void someMethod(); }

[1] Except for JavaScriptObject.cast(), because there's no way to
cross-cast between two un-related Java types except for an
intermediate cast to JavaScriptObject, and that's ugly.

-- 
Bob Vawter
Google Web Toolkit Team

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to