Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT: Native method using JSNI: how to call methods dynamically

I am using GWT and I have created a native method that calls the method cmd_addspace in the class EverlinkedActions and it works fine for now:

private static native String execute(String functionName,  Object[] vParams)/*-{
  try{          
      @es.gwt.client.dash.actions.impl.EverlinkedActions::cmd_addspace([Ljava/lanG/Object;)(vParams);          
  }catch(e){
      alert(e.message);
  }

}-*/;

How can i make the method name dynamic? it means instead of "cmd_addspace" i want to call the method "functionName" which its name is passed as argument in the native method.

And is their a way to make the class name also dynamic? i want to have something like that:

private static native String execute(String className, String functionName,  Object[] vParams)/*-{
  try{          
      @es.gwt.client.dash.actions.impl.className::functionName([Ljava/lanG/Object;)(vParams);          
  }catch(e){
      alert(e.message);
  }

}-*/;

Thanks for any help

like image 278
user2318955 Avatar asked Jun 18 '26 00:06

user2318955


1 Answers

Not sure what you're trying to actually achieve here but I'm afraid JSNI doesn't work like that.

Code such as @es.gwt.client.dash.actions.impl.EverlinkedActions::cmd_addspace([Ljava/lanG/Object;)(vParams); needs to be a fully resolvable symbol at compile time because class and method names get replaced with their minimised versions.

like image 106
funkybro Avatar answered Jun 19 '26 14:06

funkybro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!