public final class

GWT

extends Object
java.lang.Object
   ↳ com.google.gwt.core.client.GWT

Class Overview

Supports core functionality that in some cases requires direct support from the compiler and runtime systems such as runtime type information and deferred binding.

Summary

Nested Classes
interface GWT.UncaughtExceptionHandler This interface is used to catch exceptions at the "top level" just before they escape to the browser. 
Constants
String HOSTED_MODE_PERMUTATION_STRONG_NAME This constant is used by getPermutationStrongName() when running in Development Mode.
Public Constructors
GWT()
Public Methods
static <T> T create(Class<?> classLiteral)
Instantiates a class via deferred binding.
static String 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.
static String getModuleBaseURL()
Gets the URL prefix of the module which should be prepended to URLs that are intended to be module-relative, such as RPC entry points and files in the module's public path.
static String getModuleName()
Gets the name of the running module.
static String getPermutationStrongName()
Returns the permutation's strong name.
static String getTypeName(Object o)
This method is deprecated. Use getClass(), getName()
static GWT.UncaughtExceptionHandler getUncaughtExceptionHandler()
Returns the currently active uncaughtExceptionHandler.
static String 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.
static String getVersion()
static boolean isClient()
Returns true when running inside the normal GWT environment, either in Development Mode or Production Mode.
static boolean isProdMode()
Returns true when running in production mode.
static boolean isScript()
Determines whether or not the running program is script or bytecode.
static void log(String message, Throwable e)
Logs a message to the development shell logger in Development Mode.
static void log(String message)
Logs a message to the development shell logger in Development Mode.
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 as runAsync(RunAsyncCallback), except with an extra parameter to provide a name for the call.
static void setUncaughtExceptionHandler(GWT.UncaughtExceptionHandler handler)
Sets a custom uncaught exception handler.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String HOSTED_MODE_PERMUTATION_STRONG_NAME

This constant is used by getPermutationStrongName() when running in Development Mode.

Constant Value: "HostedMode"

Public Constructors

public GWT ()

Public Methods

public static T create (Class<?> classLiteral)

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 a Class 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 typecast to the requested class.

public static String 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 use getModuleBaseURL() 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

public static String getModuleBaseURL ()

Gets the URL prefix of the module which should be prepended to URLs that are intended to be module-relative, such as RPC entry points and files in the module's public path.

Returns
  • if non-empty, the base URL is guaranteed to end with a slash

public static String getModuleName ()

Gets the name of the running module.

public static String 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 {@value #HOSTED_MODE_PERMUTATION_STRONG_NAME}.

public static String getTypeName (Object o)

This method is deprecated.
Use getClass(), getName()

public static GWT.UncaughtExceptionHandler getUncaughtExceptionHandler ()

Returns the currently active uncaughtExceptionHandler. "Top level" methods that dispatch events from the browser into user code must call this method on entry to get the active handler. If the active handler is null, the entry point must allow exceptions to escape into the browser. If the handler is non-null, exceptions must be caught and routed to the handler. See the source code for DOM.dispatchEvent() for an example of how to handle this correctly.

Returns
  • the currently active handler, or null if no handler is active.

public static String 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.

public static String getVersion ()

public static boolean isClient ()

Returns true when running inside the normal GWT environment, either in Development Mode or Production Mode. Returns false 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.

public static boolean isProdMode ()

Returns true when running in production mode. Returns false when running either in development mode, or when running in a plain JVM.

public static boolean isScript ()

Determines whether or not the running program is script or bytecode.

public static void log (String message, Throwable e)

Logs a message to the development shell logger in Development Mode. Calls are optimized out in Production Mode.

public static void log (String message)

Logs a message to the development shell logger in Development Mode. Calls are optimized out in Production Mode.

public static void runAsync (RunAsyncCallback callback)

Run the specified callback once the necessary code for it has been loaded.

public static void runAsync (Class<?> name, RunAsyncCallback callback)

The same as runAsync(RunAsyncCallback), except with an extra parameter to provide a name for the call. The name parameter should be supplied with a class literal. No two runAsync calls in the same program should use the same name.

public static void setUncaughtExceptionHandler (GWT.UncaughtExceptionHandler handler)

Sets a custom uncaught exception handler. See getUncaughtExceptionHandler() for details.

Parameters
handler the handler that should be called when an exception is about to escape to the browser, or null to clear the handler and allow exceptions to escape.