I am wrapping a JS library and one method takes a class/prototype as a parameter. ie:
installPlugin(Prototype)
How would the wrapped JSNI function for this method look?
public final void native installPlugin(Class<?> clazz) /*-{
this.installPlugin(clazz);
}-*/;
This isn't correct but along the lines of what I want to achieve.
This is not possible. In GWT, objects know their class (returned by getClass()
) but Class
instances don't have a reference to the constructors / prototype that would allow creating instances of that class.
If you can pass an instance of the class instead, you should be able to just use obj.prototype
. It wouldn't work in DevMode though, where Java objects are opaque handles when passed to JSNI.