Package com.google.gwt.core.client
Class GWT
java.lang.Object
com.google.gwt.core.client.GWT
Supports core functionality that in some cases requires direct support from
the compiler and runtime systems such as runtime type information and
deferred binding.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
This interface is used to catch exceptions at the "top level" just before they escape to the browser. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
This constant is used bygetPermutationStrongName()
when running in Development Mode. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
Instantiates a class via deferred binding.static void
debugger()
Emits a JavaScript "debugger" statement on the line that called this method.static String
Gets the URL prefix of the hosting page, useful for prepending to relative paths of resources which may be relative to the host page.static String
Gets the URL prefix that should be prepended to URLs that point to static files generated by the GWT compiler, such as files in the module's public path.static String
Gets the URL prefix that should be prepended to URLs that are intended to be module-relative, such as RPC entry points.static String
Gets the name of the running module.static String
Returns the permutation's strong name.static String
Deprecated.static GWT.UncaughtExceptionHandler
Returns the currently active uncaughtExceptionHandler.static String
Returns the empty string when running in Production Mode, but returns a unique string for each thread in Development Mode (for example, different windows accessing the dev mode server will each have a unique id, and hitting refresh without restarting dev mode will result in a new unique id for a particular window.static String
static boolean
isClient()
Returnstrue
when running inside the normal GWT environment, either in Development Mode or Production Mode.static boolean
Returnstrue
when running in production mode.static boolean
isScript()
Determines whether or not the running program is script or bytecode.static void
Logs a message to the development shell logger in Development Mode, or to the console in Super Dev Mode.static void
Logs a message to the development shell logger in Development Mode, or to the console in Super Dev Mode.static void
Reports an exception caught at the "top level" to a handler set viasetUncaughtExceptionHandler(UncaughtExceptionHandler)
.static void
runAsync
(RunAsyncCallback callback) Run the specified callback once the necessary code for it has been loaded.static void
runAsync
(Class<?> name, RunAsyncCallback callback) The same asrunAsync(RunAsyncCallback)
, except with an extra parameter to provide a name for the call.(package private) static void
Called via reflection in Development Mode; do not ever call this method in Production Mode.static void
Sets a custom uncaught exception handler.
-
Field Details
-
HOSTED_MODE_PERMUTATION_STRONG_NAME
This constant is used bygetPermutationStrongName()
when running in Development Mode.- See Also:
-
-
Constructor Details
-
GWT
public GWT()
-
-
Method Details
-
create
Instantiates a class via deferred binding.The argument to
create(Class)
must be a class literal because the Production Mode compiler must be able to statically determine the requested type at compile-time. This can be tricky because using aClass
variable may appear to work correctly in Development Mode.- Parameters:
classLiteral
- a class literal specifying the base class to be instantiated- Returns:
- the new instance, which must be cast to the requested class
-
getHostPageBaseURL
Gets the URL prefix of the hosting page, useful for prepending to relative paths of resources which may be relative to the host page. Typically, you should usegetModuleBaseURL()
unless you have a specific reason to load a resource relative to the host page.- Returns:
- if non-empty, the base URL is guaranteed to end with a slash
-
getModuleBaseForStaticFiles
Gets the URL prefix that should be prepended to URLs that point to static files generated by the GWT compiler, such as files in the module's public path.Normally this will be the same value as
getModuleBaseURL()
, but may be different when a GWT app is configured to get its static resources from a different server.- Returns:
- if non-empty, the base URL is guaranteed to end with a slash
-
getModuleBaseURL
Gets the URL prefix that should be prepended to URLs that are intended to be module-relative, such as RPC entry points.If the URL points to an output file of the GWT compiler (such as a file in the public path), use
getModuleBaseForStaticFiles()
instead.- Returns:
- if non-empty, the base URL is guaranteed to end with a slash
-
getModuleName
Gets the name of the running module. -
getPermutationStrongName
Returns the permutation's strong name. This can be used to distinguish between different permutations of the same module. In Development Mode, this method will return "HostedMode". -
getTypeName
Deprecated. -
getUncaughtExceptionHandler
Returns the currently active uncaughtExceptionHandler.- Returns:
- the currently active handler, or null if no handler is active.
- See Also:
-
reportUncaughtException
Reports an exception caught at the "top level" to a handler set viasetUncaughtExceptionHandler(UncaughtExceptionHandler)
. This is used in places where the browser calls into user code such as event callbacks, timers, and RPC.If no
UncaughtExceptionHandler
is set, the exception is reported to browser. Browsers usually log these exceptions to the JavaScript console. -
getUniqueThreadId
Returns the empty string when running in Production Mode, but returns a unique string for each thread in Development Mode (for example, different windows accessing the dev mode server will each have a unique id, and hitting refresh without restarting dev mode will result in a new unique id for a particular window. TODO(unnurg): Remove this function once Dev Mode rewriting classes are in gwt-dev. -
getVersion
-
isClient
public static boolean isClient()Returnstrue
when running inside the normal GWT environment, either in Development Mode or Production Mode. Returnsfalse
if this code is running in a plain JVM. This might happen when running shared code on the server, or during the bootstrap sequence of a GWTTestCase test. -
isProdMode
public static boolean isProdMode()Returnstrue
when running in production mode. Returnsfalse
when running either in development mode, or when running in a plain JVM. -
isScript
public static boolean isScript()Determines whether or not the running program is script or bytecode. -
log
Logs a message to the development shell logger in Development Mode, or to the console in Super Dev Mode. Calls are optimized out in Production Mode. -
log
Logs a message to the development shell logger in Development Mode, or to the console in Super Dev Mode. Calls are optimized out in Production Mode. -
debugger
public static void debugger()Emits a JavaScript "debugger" statement on the line that called this method. If the user has the browser's debugger open, the debugger will stop when the GWT application executes that line. There is no effect in Dev Mode or in server-side code. -
runAsync
The same asrunAsync(RunAsyncCallback)
, except with an extra parameter to provide a name for the call. The name parameter should be supplied with a class literal. If two GWT.runAsync calls use the same class literal, the codesplitter will put the corresponding code in the same code fragment. -
runAsync
Run the specified callback once the necessary code for it has been loaded. -
setUncaughtExceptionHandler
Sets a custom uncaught exception handler. SeegetUncaughtExceptionHandler()
for details.- Parameters:
handler
- the handler that should be called when an exception is about to escape to the browser, ornull
to clear the handler and allow exceptions to escape.
-
setBridge
Called via reflection in Development Mode; do not ever call this method in Production Mode.
-
Object.getClass()
,Class.getName()