Child pages
  • GWT JSNI inheritance antifeature

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

References to java methods from JSNI must always refer to the class signatures of the defining base class, not the inheriting child class. Compile-time- OR Runtime-Exceptions can occur.

Example: Take the following abstract class...

Code Block
package org.clazzes.example; 
abstract class Parent {

  public void parentMethod() {
    //Do something...


which is extended as follows (factory method added for clarity):

Code Block
package org.clazzes.example;
class Child extends Parent {

  public static Child getInstance() {
    return new Child();


To use parentMethod() from an instance of Child, you must use the following:

Code Block
public native final void callParentMethodFromJSNI() /*-{
  var child = @org.clazzes.example.Child::newInstance()();

  //access to parentMethod() only works like this: