Language Support
Intrinsic types: byte
, char
, short
, int
, long
, float
, double
, Object
, String
, and arrays are supported. However, there is no 64-bit integral type in JavaScript, so variables of type long
are mapped onto JavaScript double-precision floating point values. To ensure maximum consistency between hosted mode and web mode, we recommend that you use int
variables.
Exceptions:try
, catch
, finally
and user-defined exceptions are supported as normal, although Throwable.getStackTrace()
is not supported for web mode. See Throwable for additional details.
Assertions:The GWT compiler parses Java assert
statements, but it does not emit code JavaScript code for them.
Multithreading and Synchronization:JavaScript interpreters are single-threaded, so while GWT silently accepts the synchronized
keyword, it has no real effect. Synchronization-related library methods are not available, including Object.wait()
, Object.notify()
, and Object.notifyAll()
Reflection:For maximum efficiency, GWT compiles your Java source into a monolithic script, and does not support subsequent dynamic loading of classes. This and other optimizations preclude general support for reflection. It is possible to query an object for its class name using GWT.getTypeName(Object).
Finalization:JavaScript does not support object finalization during garbage collection, so GWT isn't able to be honor Java finalizers in web mode.
Strict Floating-Point:The Java language specification precisely defines floating-point support, including single-precision and double-precision numbers as well as the strictfp
keyword. GWT does not support the strictfp
keyword and can't ensure any particular degree of floating-point precision in translated code, so you may want to avoid calculations in client-side code that require a guaranteed level of floating-point precision.
Runtime Library Support
Some specific areas in which GWT emulation differs from the standard Java runtime:
-
Regular Expressions:The syntax of
Java regular expressions is similar, but not identical, to
JavaScript regular expressions. For example, the replaceAll and split methods use regular expressions. So, you'll probably want to be careful to only use Java regular expressions that have the same meaning in JavaScript.
-
Serialization:Java serialization relies on a few mechanisms that are not available in compiled JavaScript, such as dynamic class loading and reflection. As a result, GWT does not support standard Java serialization. Instead, GWT has an
RPC facility that provides automatic object serialization to and from the server for the purpose of invoking remote methods.
Tip: You'll save yourself a lot of frustration if you make sure that you use only translatable classes in your client-side code from the very beginning. To help you identify problems early, your code is checked against the JRE emulation library whenever you run in hosted mode. As a result, most uses of unsupported libraries will be caught the first time you attempt to run your application. So, run early and often.
Cross-browser Support
Whenever possible, GWT defers to browsers' native user interface elements. For example, GWT's Button widget is a true HTML <button>
rather than a synthetic button-like widget built, say, from a <div>
. That means that GWT buttons render appropriately in different browsers and on different client operating systems. We like the native browser controls because they're fast, accessible, and most familiar to users.
分享到:
相关推荐
gwt学习笔记汇总,包括基础到实例应用,对于初学者很不错的,要慢慢看 !
GWT 自己的学习笔记 全部手写 有助于初学者了解GWT 学习gwt
Gwt-ext学习笔记,Gwt-ext学习笔记,Gwt-ext学习笔记
从研发经验总结的smartGwt的开发与实现
Gwt-ext学习笔记之基础篇、安装、配置、例子。
GWT-Ext 是基于 Google Web Toolkit(GWT)和 ExtJs 的功能强大的网页开发控件库。它非常适用于进行纯 Java 语言的富 ...本文是该系列的第一部分,将带领您快速入门 GWT-Ext,并演示如何快速搭建 GWT-Ext 的开发环境。
关于GWT开发详解,感兴趣的朋友还是很值得一看。
GWT的入门实例和学习笔记,含有HELLOWORLD实例,初学者可以看下
本文档简要描述了gwt的基本知识,对于刚入门的gwt初学者很不错的
该文档是关于在eclipse下进行GWT开发的一个教程文档,与网上其他教程有所区别,此文档为中级篇,建议用户先下载基础篇浏览过后再决定是否下载另外两篇~~
该文档是关于在eclipse下进行GWT开发的一个教程文档,与网上其他教程有所区别,此文档为基础篇,还有进阶和中级篇,建议用户先下载基础篇浏览过后再决定是否下载另外两篇~~
不用为界面烦恼了。使用JAVA语言开发WEB
(本文基于GWT提供的开发指南(Developer Guide),所采用的图片,例子均出自GWT,可以认为是GWT的学习笔记) GWT的核心是通过一个编译器(compiler)把Java代码翻译为JavaScript代码,开发期间,用户以类似开发AWT...
面向 Java 开发人员的 Ajax: Google Web Toolkit 入门 图文教程