JSNI is web equivalent of inline assembly code and can use in many ways such as:
Declaring a native method
Calling JSNI from Java
Calling a JSNI method from Java is no different than calling a regular Java method.
The caller can’t really tell if the method is native or not. This gives some flexibility in changing about how the method is implemented.
Calling Java from JSNI
Accessing Java fields
obj: It is the object instance being referenced. For static variables, leave off the instance expression and the trailing period.
Invoking Java methods
Calling methods uses syntax similar to accessing fields, except also supply the signature of the method calling. Java methods can be overloaded, i.e., two methods can have the same name but take different parameters.
obj : It is the object instance being referenced. For static methods,omit the instance expression and the trailing period.
GWT JSNI Method signatures
JSNI method signatures are exactly the same as JNI method signatures except that the method return type is left off. The following table shows type signatures:
GWT JSNI Example