Package com.google.gwt.core.shared
Class GWT
- java.lang.Object
-
- com.google.gwt.core.shared.GWT
-
public final class GWT extends java.lang.ObjectSupports core functionality that in some cases requires direct support from the compiler and runtime systems such as runtime type information and deferred binding.
-
-
Constructor Summary
Constructors Constructor Description GWT()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tcreate(java.lang.Class<?> classLiteral)Instantiates a class via deferred binding.static <T> TcreateImpl(java.lang.Class<?> classLiteral)Instantiates a class via deferred binding.static voiddebugger()Emits a JavaScript "debugger" statement on the line that called this method.static java.lang.StringgetUniqueThreadId()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 java.lang.StringgetVersion()Get a human-readable representation of the GWT version used, or null if this is running on the client.static booleanisClient()Returnstruewhen running inside the normal GWT environment, either in Development Mode or Production Mode.static booleanisProdMode()Returnstruewhen running in production mode.static booleanisScript()Determines whether or not the running program is script or bytecode.static voidlog(java.lang.String message)Logs a message to the development shell logger in Development Mode, or to the JavaScript console in Super Dev Mode.static voidlog(java.lang.String message, java.lang.Throwable e)Logs a message to the development shell logger in Development Mode, or to the JavaScript console in Super Dev Mode.static voidsetBridge(GWTBridge bridge)Called via reflection in Development Mode; do not ever call this method in Production Mode.
-
-
-
Method Detail
-
create
public static <T> T create(java.lang.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 aClassvariable 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
-
createImpl
public static <T> T createImpl(java.lang.Class<?> classLiteral)
Instantiates a class via deferred binding.- Parameters:
classLiteral- a class literal specifying the base class to be instantiated- Returns:
- the new instance, which must be cast to the requested class
-
getUniqueThreadId
public static java.lang.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.
-
getVersion
public static java.lang.String getVersion()
Get a human-readable representation of the GWT version used, or null if this is running on the client.- Returns:
- a human-readable version number, such as
"2.5"
-
isClient
public static boolean isClient()
Returnstruewhen running inside the normal GWT environment, either in Development Mode or Production Mode. Returnsfalseif 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()
Returnstruewhen running in production mode. Returnsfalsewhen 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
public static void log(java.lang.String message)
Logs a message to the development shell logger in Development Mode, or to the JavaScript console in Super Dev Mode. Calls are optimized out in Production Mode.
-
log
public static void log(java.lang.String message, java.lang.Throwable e)Logs a message to the development shell logger in Development Mode, or to the JavaScript 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.
-
setBridge
public static void setBridge(GWTBridge bridge)
Called via reflection in Development Mode; do not ever call this method in Production Mode. May be called in server code to initialize server bridge.
-
-